Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-03-19 19:01:00 +0000
committerslewis2014-03-19 19:01:00 +0000
commit57b2df2315db1b837e9bca428debab3af900813c (patch)
tree29d3e78a70ebb80515f6f3d130da0a204291c741 /providers
parentd0e0dde8ee38450eccf081883a6fbf18fd8a9bec (diff)
downloadorg.eclipse.ecf-57b2df2315db1b837e9bca428debab3af900813c.tar.gz
org.eclipse.ecf-57b2df2315db1b837e9bca428debab3af900813c.tar.xz
org.eclipse.ecf-57b2df2315db1b837e9bca428debab3af900813c.zip
Proposed fix for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=430704 for the httpclient4 provider Change-Id: Ia2d218bcb435ba028ab2a1ce08bd6ab15d119929
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient4/ConnectingSocketMonitor.java47
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientFileSystemBrowser.java26
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java13
4 files changed, 56 insertions, 32 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
index 753e8c6c6..e66e4d225 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.httpclient4;singleton:=true
-Bundle-Version: 1.0.300.qualifier
+Bundle-Version: 1.0.400.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Activator
Require-Bundle: org.eclipse.equinox.common,
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient4/ConnectingSocketMonitor.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient4/ConnectingSocketMonitor.java
index 9aae0dc5e..a95d76d8d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient4/ConnectingSocketMonitor.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient4/ConnectingSocketMonitor.java
@@ -11,8 +11,19 @@
package org.eclipse.ecf.internal.provider.filetransfer.httpclient4;
-import java.util.*;
-import org.eclipse.ecf.filetransfer.events.socket.*;
+import java.io.IOException;
+import java.net.Socket;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.filetransfer.events.socket.ISocketClosedEvent;
+import org.eclipse.ecf.filetransfer.events.socket.ISocketConnectedEvent;
+import org.eclipse.ecf.filetransfer.events.socket.ISocketCreatedEvent;
+import org.eclipse.ecf.filetransfer.events.socket.ISocketEvent;
+import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;
public class ConnectingSocketMonitor implements ISocketListener {
@@ -26,6 +37,16 @@ public class ConnectingSocketMonitor implements ISocketListener {
connectingSockets = Collections.synchronizedMap(new HashMap());
}
+ /**
+ * Callers of this method should not iterate through the returned
+ * Collection, as a CME is possible...as reported by bug
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=430704
+ * Rather than call this method and iterate through the Collection,
+ * to close the connecting sockets call closeConnectingSockets
+ * instead.
+ * @return Collection the existing collection of underlying connecting
+ * Socket instances
+ */
public Collection getConnectingSockets() {
return Collections.unmodifiableCollection(connectingSockets.keySet());
}
@@ -34,6 +55,28 @@ public class ConnectingSocketMonitor implements ISocketListener {
connectingSockets.clear();
}
+ /**
+ * Method added to synchronize access to underlying keySet
+ * to prevent CME as reported in bug
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=430704
+ */
+ public void closeSockets() {
+ // synchronize on the connectingSockets map
+ // so all changes caused by handleSocketEvent
+ // are prevented via synchronized Map
+ synchronized (connectingSockets) {
+ for (Iterator iterator = connectingSockets.keySet().iterator(); iterator.hasNext();) {
+ Socket socket = (Socket) iterator.next();
+ try {
+ Trace.trace(Activator.PLUGIN_ID, "Call socket.close() for socket=" + socket.toString()); //$NON-NLS-1$
+ socket.close();
+ } catch (IOException e) {
+ Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "cancel", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
public void handleSocketEvent(ISocketEvent event) {
if (event instanceof ISocketCreatedEvent) {
connectingSockets.put(event.getFactorySocket(), event);
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientFileSystemBrowser.java
index 1a668b885..af9fec4c0 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientFileSystemBrowser.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientFileSystemBrowser.java
@@ -13,18 +13,10 @@
package org.eclipse.ecf.provider.filetransfer.httpclient4;
-import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Activator;
-import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ConnectingSocketMonitor;
-import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.DebugOptions;
-import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.HttpClientProxyCredentialProvider;
-import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Messages;
-
import java.io.IOException;
import java.net.HttpURLConnection;
-import java.net.Socket;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpHost;
@@ -57,6 +49,11 @@ import org.eclipse.ecf.filetransfer.IRemoteFile;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemRequest;
import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Activator;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ConnectingSocketMonitor;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.DebugOptions;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.HttpClientProxyCredentialProvider;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Messages;
import org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser;
import org.eclipse.ecf.provider.filetransfer.browse.URLRemoteFile;
import org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventSource;
@@ -191,17 +188,10 @@ public class HttpClientFileSystemBrowser extends AbstractFileSystemBrowser {
}
}
if (connectingSockets != null) {
- // this should unblock socket connect calls, if any
- for (Iterator iterator = connectingSockets.getConnectingSockets().iterator(); iterator.hasNext();) {
- Socket socket = (Socket) iterator.next();
- try {
- socket.close();
- } catch (IOException e) {
- Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "cancel", e); //$NON-NLS-1$
- }
- }
+ // Change for preventing CME from bug
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=430704
+ connectingSockets.closeSockets();
}
-
}
protected boolean hasForceNTLMProxyOption() {
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
index 0c14292ff..c14fc6ef3 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
@@ -18,7 +18,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.InetAddress;
-import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
@@ -246,16 +245,8 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
}
}
if (connectingSockets != null) {
- // this should unblock socket connect calls, if any
- for (Iterator iterator = connectingSockets.getConnectingSockets().iterator(); iterator.hasNext();) {
- Socket socket = (Socket) iterator.next();
- try {
- Trace.trace(Activator.PLUGIN_ID, "Call socket.close() for socket=" + socket.toString()); //$NON-NLS-1$
- socket.close();
- } catch (IOException e) {
- Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "cancel", e); //$NON-NLS-1$
- }
- }
+ // Added to prevent CME in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=430704
+ connectingSockets.closeSockets();
}
hardClose();
if (fireDoneEvent) {

Back to the top