Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 198215 Details for
Bug 349176
[provider] Allow generic server instantiator to use any port as default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for 4daddd11eeeba5f896ce92e6434b82d3e06f37e4
bug349176.patch (text/plain), 1.96 KB, created by
Alex Blewitt
on 2011-06-17 16:56:41 EDT
(
hide
)
Description:
Patch for 4daddd11eeeba5f896ce92e6434b82d3e06f37e4
Filename:
MIME Type:
Creator:
Alex Blewitt
Created:
2011-06-17 16:56:41 EDT
Size:
1.96 KB
patch
obsolete
>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 98efeee..4d3e46c 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 >@@ -11,6 +11,7 @@ > package org.eclipse.ecf.provider.generic; > > import java.io.IOException; >+import java.net.BindException; > import java.net.ServerSocket; > import java.util.*; > import org.eclipse.core.runtime.*; >@@ -152,7 +153,11 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe > newID = getIDFromArg(args[0]); > } > if (newID == null) { >- int defaultPort = getFreePort(); >+ int defaultPort = TCPServerSOContainer.DEFAULT_PORT; >+ boolean useFallbackPort = TCPServerSOContainer.DEFAULT_FALLBACK_PORT; >+ if (useFallbackPort && !defaultPortIsFree(defaultPort)) { >+ defaultPort = getFreePort(); >+ } > newID = IDFactory.getDefault().createStringID(TCPServerSOContainer.DEFAULT_PROTOCOL + "://" + TCPServerSOContainer.DEFAULT_HOST + ":" + defaultPort + TCPServerSOContainer.DEFAULT_NAME);//$NON-NLS-1$ //$NON-NLS-2$ > } > if (ka == null) >@@ -160,6 +165,26 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe > return new GenericContainerArgs(newID, ka); > } > >+ private boolean defaultPortIsFree(int defaultPort) { >+ ServerSocket ss = null; >+ try { >+ ss = new ServerSocket(defaultPort); >+ ss.close(); >+ } catch (BindException e) { >+ return false; >+ } catch (IOException e) { >+ return false; >+ } finally { >+ if (ss != null) >+ try { >+ ss.close(); >+ } catch (IOException e) { >+ throw new IDCreateException(e); >+ } >+ } >+ return true; >+ } >+ > /** > * @return a free socket port > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 349176
: 198215