Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-10-13 19:01:45 +0000
committerChris Goldthorpe2011-10-13 19:01:45 +0000
commit6a242651757dd301cb6f41ba927ebfe7d690ec57 (patch)
treea4c59282ef83c6c19f2fedfdc90d4243ae03465c /org.eclipse.help.base
parent673b49e2a9561cd1c82717523e29da497c91c804 (diff)
downloadeclipse.platform.ua-6a242651757dd301cb6f41ba927ebfe7d690ec57.tar.gz
eclipse.platform.ua-6a242651757dd301cb6f41ba927ebfe7d690ec57.tar.xz
eclipse.platform.ua-6a242651757dd301cb6f41ba927ebfe7d690ec57.zip
Bug 360706 - [Help] Warnings about resources not closed
Diffstat (limited to 'org.eclipse.help.base')
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpApplication.java10
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java5
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java21
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseController.java12
4 files changed, 42 insertions, 6 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpApplication.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpApplication.java
index cbdc218c9..7da7752d3 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpApplication.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/HelpApplication.java
@@ -40,6 +40,7 @@ public class HelpApplication implements IApplication, IExecutableExtension {
private static boolean shutdownOnClose = false; // Shutdown help when the embedded browser is closed
private File metadata;
private FileLock lock;
+ private RandomAccessFile raf;
/* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
@@ -150,7 +151,7 @@ public class HelpApplication implements IApplication, IExecutableExtension {
private void obtainLock() {
File lockFile = new File(metadata, APPLICATION_LOCK_FILE);
try {
- RandomAccessFile raf = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
+ raf = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
lock = raf.getChannel().lock();
} catch (IOException ioe) {
lock = null;
@@ -164,6 +165,13 @@ public class HelpApplication implements IApplication, IExecutableExtension {
} catch (IOException ioe) {
}
}
+ if (raf != null) {
+ try {
+ raf.close();
+ } catch (IOException ioe) {
+ }
+ raf = null;
+ }
}
public static boolean isRunning() {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
index 590d7290a..b5a30d655 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/TestConnectionUtility.java
@@ -74,9 +74,12 @@ public class TestConnectionUtility {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
while (( line = reader.readLine())!=null){
- if (line.indexOf("<tocContributions>")>-1) //$NON-NLS-1$
+ if (line.indexOf("<tocContributions>")>-1) { //$NON-NLS-1$
+ reader.close();
return true;
+ }
}
+ reader.close();
}
}catch (Exception ex){}
finally{
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index e47a6e294..916d58a65 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -128,6 +128,7 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
private Collection<Thread> searches = new ArrayList<Thread>();
private FileLock lock;
+ private RandomAccessFile raf = null;
/**
* Constructor.
@@ -952,17 +953,26 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
File lockFile = getLockFile();
lockFile.getParentFile().mkdirs();
try {
- RandomAccessFile raf = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
+ raf = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
FileLock l = raf.getChannel().tryLock();
if (l != null) {
+ // The RandomAccessFile raf cannot be closed yet because closing it will release the
+ // lock. It will be closed when the lock is released.
lock = l;
- return true;
+ return true;
}
logLockFailure(null);
} catch (IOException ioe) {
lock = null;
logLockFailure(ioe);
}
+ if ( raf != null ) {
+ try {
+ raf.close();
+ } catch (IOException e) {
+ }
+ raf = null;
+ }
return false;
}
@@ -1002,6 +1012,13 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
}
lock = null;
}
+ if (raf != null ) {
+ try {
+ raf.close();
+ } catch (IOException ioe) {
+ }
+ raf = null;
+ }
}
public static String getIndexableHref(String url) {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseController.java b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseController.java
index f9bd222e8..59d125564 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseController.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/EclipseController.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -52,6 +52,7 @@ public class EclipseController implements EclipseLifeCycleListener {
// Inter process lock
private FileLock lock;
+ private RandomAccessFile raf;
private boolean eclipseEnded = false;
@@ -248,7 +249,7 @@ public class EclipseController implements EclipseLifeCycleListener {
if (!Options.getLockFile().exists()) {
Options.getLockFile().getParentFile().mkdirs();
}
- RandomAccessFile raf = new RandomAccessFile(Options.getLockFile(), "rw"); //$NON-NLS-1$
+ raf = new RandomAccessFile(Options.getLockFile(), "rw"); //$NON-NLS-1$
lock = raf.getChannel().lock();
if (Options.isDebug()) {
System.out.println("Lock obtained."); //$NON-NLS-1$
@@ -266,6 +267,13 @@ public class EclipseController implements EclipseLifeCycleListener {
} catch (IOException ioe) {
}
}
+ if (raf != null) {
+ try {
+ raf.close();
+ } catch (IOException ioe) {
+ }
+ raf = null;
+ }
}
/**

Back to the top