Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-02-23 02:44:52 -0500
committerUwe Stieber2012-02-23 02:44:52 -0500
commit6b7603a0d5456013354456298dd01f2839a6d7d0 (patch)
treee841fd8fe9308b981e5a872809d941441da685c6
parent005675c5f5cf51818e997d23320994cb3b523577 (diff)
downloadorg.eclipse.tcf-6b7603a0d5456013354456298dd01f2839a6d7d0.tar.gz
org.eclipse.tcf-6b7603a0d5456013354456298dd01f2839a6d7d0.tar.xz
org.eclipse.tcf-6b7603a0d5456013354456298dd01f2839a6d7d0.zip
Target Explorer: Fix more exceptions on shutdown
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/activator/UIPlugin.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/PersistenceManager.java45
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java62
3 files changed, 61 insertions, 48 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/activator/UIPlugin.java
index b33eae758..5ff96aede 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/activator/UIPlugin.java
@@ -114,7 +114,7 @@ public class UIPlugin extends AbstractUIPlugin {
*/
@Override
public void stop(BundleContext context) throws Exception {
- PersistenceManager.getInstance().dispose();
+ if (PersistenceManager.needsDisposal()) PersistenceManager.getInstance().dispose();
if (regURLStreamHandlerService != null) {
// When URL stream handler service is unregistered, any URL related operation will be invalid.
regURLStreamHandlerService.unregister();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/PersistenceManager.java
index 99f6fe738..7ee6eed36 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/PersistenceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/utils/PersistenceManager.java
@@ -5,7 +5,7 @@
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
+ * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
* up menu of file system nodes of Target Explorer.
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.internal.utils;
@@ -110,7 +110,7 @@ public class PersistenceManager {
/**
* Get the singleton cache manager.
- *
+ *
* @return The singleton cache manager.
*/
public static PersistenceManager getInstance() {
@@ -131,7 +131,7 @@ public class PersistenceManager {
/**
* If the node is already considered unresolvable.
- *
+ *
* @param node The file node.
* @return true if it is not resolvable or else false.
*/
@@ -141,7 +141,7 @@ public class PersistenceManager {
/**
* Get the resolved content type of the node.
- *
+ *
* @param node The file node.
* @return the content type of the node if it is resolvable or null.
*/
@@ -151,7 +151,7 @@ public class PersistenceManager {
/**
* Add the node and its content type to the resolved list.
- *
+ *
* @param node The file node.
* @param contentType Its content type.
*/
@@ -161,7 +161,7 @@ public class PersistenceManager {
/**
* Add the node as an unresolvable node.
- *
+ *
* @param node The file node.
*/
public void addUnresolved(FSTreeNode node) {
@@ -170,7 +170,7 @@ public class PersistenceManager {
/**
* If the option of "autosaving" is set to on.
- *
+ *
* @return true if it is auto saving or else false.
*/
public boolean isAutoSaving() {
@@ -182,7 +182,7 @@ public class PersistenceManager {
/**
* If the option of "in-place editor" is set to on.
- *
+ *
* @return true if it uses in-place editor when renaming files/folders.
*/
public boolean isInPlaceEditor() {
@@ -194,7 +194,7 @@ public class PersistenceManager {
/**
* If the option of "copy permissions" is set to on.
- *
+ *
* @return true if it should copy source file permissions.
*/
public boolean isCopyPermission() {
@@ -206,7 +206,7 @@ public class PersistenceManager {
/**
* If the option of "copy ownership" is set to on.
- *
+ *
* @return true if it should copy source file ownership.
*/
public boolean isCopyOwnership() {
@@ -303,7 +303,7 @@ public class PersistenceManager {
/**
* Load a file's properties from the memento node.
- *
+ *
* @param memento The memento node.
* @return The properties as a map.
*/
@@ -325,7 +325,7 @@ public class PersistenceManager {
/**
* Read the memento from a memento file using the specified root element name.
- *
+ *
* @param mementoFile The memento file.
* @param mementoRoot The memento's root element name.
* @return A memento of this file or an empty memento if the file does not exist.
@@ -376,7 +376,7 @@ public class PersistenceManager {
/**
* Save the file's properties to a memento.
- *
+ *
* @param memento The memento object.
* @param properties The file properties.
*/
@@ -391,7 +391,7 @@ public class PersistenceManager {
/**
* Write the memento to a memento file.
- *
+ *
* @param memento The memento object.
* @param mementoFile The file to write to.
*/
@@ -420,7 +420,7 @@ public class PersistenceManager {
/**
* Get the file properties of the specified node from the properties map.
- *
+ *
* @param node The file node.
* @return The file properties object or empty properties object if it does not exist.
*/
@@ -506,7 +506,7 @@ public class PersistenceManager {
/**
* Set the time stamp of the FSTreeNode with the specified location.
- *
+ *
* @param uri The FSTreeNode's location URI.
* @param timestamp The new base time stamp to be set.
*/
@@ -516,7 +516,7 @@ public class PersistenceManager {
/**
* Remove the time stamp entry with the specified URI.
- *
+ *
* @param uri The URI key.
*/
public void removeBaseTimestamp(URI uri) {
@@ -525,7 +525,7 @@ public class PersistenceManager {
/**
* Get the time stamp of the FSTreeNode with the specified location.
- *
+ *
* @param uri The FSTreeNode's location URI.
* @return The FSTreeNode's base time stamp.
*/
@@ -543,4 +543,13 @@ public class PersistenceManager {
savePersistentProperties();
saveContentTypes();
}
+
+ /**
+ * Returns if or if not the persistence manager needs to be disposed.
+ *
+ * @return <code>True</code> if the persistence manager needs disposal, <code>false</code> otherwise.
+ */
+ public final static boolean needsDisposal() {
+ return instance != null;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
index 112808ea8..1ebddd911 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
@@ -88,37 +88,41 @@ public class Scanner extends Job implements IScanner {
IPeerModel[] peers = getParentModel().getPeers();
// Do we have something to scan at all
if (peers.length > 0) {
- // The first runnable is setting the thread which will finish
- // the job at the end
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- Scanner.this.setThread(Thread.currentThread());
- }
- });
- // Loop the nodes and try to get an channel
- for (IPeerModel peer : peers) {
- // Check for the progress monitor getting canceled
- if (monitor.isCanceled() || isTerminated()) break;
- // Create the scanner runnable
- Runnable runnable = new ScannerRunnable(this, peer);
- // Submit for execution
- Protocol.invokeLater(runnable);
- }
- // The last runnable will terminate the job as soon all
- // scanner runnable's are processed and will reschedule the job
- final IStatus result = monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- Scanner.this.done(result);
-
- Long delay = (Long)getConfiguration().get(IScanner.PROP_SCHEDULE);
- if (delay != null) {
- Scanner.this.schedule(delay.longValue());
+ try {
+ // The first runnable is setting the thread which will finish
+ // the job at the end
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Scanner.this.setThread(Thread.currentThread());
}
+ });
+ // Loop the nodes and try to get an channel
+ for (IPeerModel peer : peers) {
+ // Check for the progress monitor getting canceled
+ if (monitor.isCanceled() || isTerminated()) break;
+ // Create the scanner runnable
+ Runnable runnable = new ScannerRunnable(this, peer);
+ // Submit for execution
+ Protocol.invokeLater(runnable);
}
- });
+ // The last runnable will terminate the job as soon all
+ // scanner runnable's are processed and will reschedule the job
+ final IStatus result = monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Scanner.this.done(result);
+
+ Long delay = (Long)getConfiguration().get(IScanner.PROP_SCHEDULE);
+ if (delay != null) {
+ Scanner.this.schedule(delay.longValue());
+ }
+ }
+ });
+ } catch (IllegalStateException e) {
+ /* ignored on purpose */
+ }
}
return peers.length > 0 ? ASYNC_FINISH : Status.OK_STATUS;

Back to the top