Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2011-06-19 18:51:28 -0400
committerslewis2011-06-19 18:51:28 -0400
commitc9f6bbbd80e7962f352766999764da27a942ba05 (patch)
tree8a34dd568eb622cda8d62f5416404eaf7d6fa7bd
parentdbcd7204366daad29b3144ddfa1e71ed5e2b2f51 (diff)
downloadorg.eclipse.ecf-c9f6bbbd80e7962f352766999764da27a942ba05.tar.gz
org.eclipse.ecf-c9f6bbbd80e7962f352766999764da27a942ba05.tar.xz
org.eclipse.ecf-c9f6bbbd80e7962f352766999764da27a942ba05.zip
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349176
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java18
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPServerSOContainer.java2
2 files changed, 13 insertions, 7 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
index 4d3e46c81..c5941b950 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
@@ -154,10 +154,15 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
}
if (newID == null) {
int defaultPort = TCPServerSOContainer.DEFAULT_PORT;
+ // The default value for DEFAULT_FALLBACK_PORT is now true
boolean useFallbackPort = TCPServerSOContainer.DEFAULT_FALLBACK_PORT;
+ // if useFallbackPort and the DEFAULT_PORT is
+ // not available, then a free port is selected
if (useFallbackPort && !defaultPortIsFree(defaultPort)) {
defaultPort = getFreePort();
}
+ if (defaultPort < 0)
+ throw new IDCreateException("Server port for server cannot be -1"); //$NON-NLS-1$
newID = IDFactory.getDefault().createStringID(TCPServerSOContainer.DEFAULT_PROTOCOL + "://" + TCPServerSOContainer.DEFAULT_HOST + ":" + defaultPort + TCPServerSOContainer.DEFAULT_NAME);//$NON-NLS-1$ //$NON-NLS-2$
}
if (ka == null)
@@ -204,15 +209,16 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
boolean isClient = isClient(description);
try {
GenericContainerArgs gcargs = null;
- if (isClient)
- gcargs = getClientArgs(args);
- else
- gcargs = getServerArgs(args);
- // new ID must not be null
if (isClient) {
+ gcargs = getClientArgs(args);
return new TCPClientSOContainer(new SOContainerConfig(gcargs.getID()), gcargs.getKeepAlive().intValue());
}
- return new TCPServerSOContainer(new SOContainerConfig(gcargs.getID()), gcargs.getKeepAlive().intValue());
+ // This synchronized block is to prevent issues with
+ // multithreaded access to ServerPort (to find available port)
+ synchronized (this) {
+ gcargs = getServerArgs(args);
+ return new TCPServerSOContainer(new SOContainerConfig(gcargs.getID()), gcargs.getKeepAlive().intValue());
+ }
} catch (Exception e) {
Trace.catching(ProviderPlugin.PLUGIN_ID, ECFProviderDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "createInstance", e); //$NON-NLS-1$
ProviderPlugin.getDefault().log(new Status(IStatus.ERROR, ProviderPlugin.PLUGIN_ID, CREATE_INSTANCE_ERROR_CODE, "createInstance", e)); //$NON-NLS-1$
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPServerSOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPServerSOContainer.java
index eb9da752e..27303d5b2 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPServerSOContainer.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/TCPServerSOContainer.java
@@ -32,7 +32,7 @@ public class TCPServerSOContainer extends ServerSOContainer implements IConnectR
/**
* @since 4.2
*/
- public static final boolean DEFAULT_FALLBACK_PORT = Boolean.valueOf(System.getProperty("org.eclipse.ecf.provider.generic.port.fallback", "false")).booleanValue(); //$NON-NLS-1$//$NON-NLS-2$
+ public static final boolean DEFAULT_FALLBACK_PORT = Boolean.valueOf(System.getProperty("org.eclipse.ecf.provider.generic.port.fallback", "true")).booleanValue(); //$NON-NLS-1$//$NON-NLS-2$
static {
final Boolean useHostname = Boolean.valueOf(System.getProperty("org.eclipse.ecf.provider.generic.host.useHostName", "true")); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top