aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-05-30 17:16:34 -0400
committerDawid Pakuła2018-05-30 17:16:34 -0400
commite2885431d6767250689abdc9b35f4c5e02f450fc (patch)
tree4c59422c5affc4759ba559fba15cf29361ff0ebb
parent473a9f2b4c6a02ecd0a6a62d1c32941b422e3898 (diff)
downloadorg.eclipse.pdt-e2885431d6767250689abdc9b35f4c5e02f450fc.zip
org.eclipse.pdt-e2885431d6767250689abdc9b35f4c5e02f450fc.tar.gz
org.eclipse.pdt-e2885431d6767250689abdc9b35f4c5e02f450fc.tar.xz
Bug 533928 - Use random unprivileged port for PHP Internal Server
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.builtin.server.core/src/org/eclipse/php/internal/server/core/builtin/DefaultPHPServerConfiguration.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.builtin.server.core/src/org/eclipse/php/internal/server/core/builtin/DefaultPHPServerConfiguration.java b/plugins/org.eclipse.php.builtin.server.core/src/org/eclipse/php/internal/server/core/builtin/DefaultPHPServerConfiguration.java
index 03e3d9d..5273f5e 100644
--- a/plugins/org.eclipse.php.builtin.server.core/src/org/eclipse/php/internal/server/core/builtin/DefaultPHPServerConfiguration.java
+++ b/plugins/org.eclipse.php.builtin.server.core/src/org/eclipse/php/internal/server/core/builtin/DefaultPHPServerConfiguration.java
@@ -17,6 +17,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -42,8 +43,9 @@ import org.eclipse.wst.server.core.ServerPort;
@SuppressWarnings("restriction")
public class DefaultPHPServerConfiguration extends PHPServerConfiguration {
- private final static String DEFAULT_SERVER_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Server>\n\t<Port name=\"HTTP/1.1\" protocol=\"HTTP\">80</Port>\n</Server>"; //$NON-NLS-1$
-
+ private final static String DEFAULT_SERVER_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Server>\n\t<Port name=\"HTTP/1.1\" protocol=\"HTTP\">%PORT%</Port>\n</Server>"; //$NON-NLS-1$
+ private final static String PORT_VAR = "%PORT%"; //$NON-NLS-1$
+
protected String fPhpIniFile;
protected Server server;
protected ServerInstance serverInstance;
@@ -154,7 +156,7 @@ public class DefaultPHPServerConfiguration extends PHPServerConfiguration {
serverFactory = new Factory();
serverFactory.setPackageName("org.eclipse.php.internal.server.core.builtin.xml"); //$NON-NLS-1$
- server = (Server) serverFactory.loadDocument(DEFAULT_SERVER_XML);
+ server = (Server) serverFactory.loadDocument(DEFAULT_SERVER_XML.replaceAll(PORT_VAR, String.valueOf(ThreadLocalRandom.current().nextInt(8000, 9000))));
serverInstance = new ServerInstance(server);
monitor.worked(1);