Author: max.andersen(a)jboss.com
Date: 2012-04-27 19:32:45 -0400 (Fri, 27 Apr 2012)
New Revision: 40600
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
Log:
JBIDE-11691 fixed another recalc and made 'find free ports' actually work
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java 2012-04-27
23:23:48 UTC (rev 40599)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java 2012-04-27
23:32:45 UTC (rev 40600)
@@ -148,7 +148,9 @@
* @throws OpenShiftSSHOperationException
*/
public void setUseFreePorts(Boolean useFreePorts) throws OpenShiftSSHOperationException
{
- updateLocalPortBindings(useFreePorts);
+ if(!application.isPortFowardingStarted()) { // do not change the current bindings if
port forwarding is already started.
+ updateLocalPortBindings(useFreePorts);
+ }
firePropertyChange(PROPERTY_USE_DEFAULT_LOCAL_IP_ADDRESS, this.useFreePorts,
this.useFreePorts = useFreePorts);
}
@@ -164,14 +166,19 @@
final List<String> bindings = new ArrayList<String>();
// update local bindings while avoiding duplicates
for (IApplicationPortForwarding port : ports) {
- // find duplicate
- port.setLocalPort(port.getRemotePort());
- String key = computeKey(port);
- while (bindings.contains(key)) {
+ if(useFreePorts) {
+ // find free port for every port
port.setLocalPort(SocketUtil.findFreePort());
- key = computeKey(port);
+ } else {
+ // find duplicates and if match we find free port for those until stops.
+ port.setLocalPort(port.getRemotePort());
+ String key = computeKey(port);
+ while (bindings.contains(key)) {
+ port.setLocalPort(SocketUtil.findFreePort());
+ key = computeKey(port);
+ }
+ bindings.add(key);
}
- bindings.add(key);
}
}