Fix port parsing in SocketServerLauncher

Fixes #1749

Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
This commit is contained in:
Christian Dietrich 2021-08-30 10:50:02 +02:00
parent c84a013c1d
commit a37a8bc2d5

View file

@ -1,5 +1,5 @@
/**
* Copyright (c) 2019, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* Copyright (c) 2019, 2021 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@ -106,12 +106,15 @@ public class SocketServerLauncher {
}
protected int getPort(String... args) {
Integer port = Integer.getInteger(getValue(args, PORT));
if (port != null) {
return port;
} else {
return DEFAULT_PORT;
String value = getValue(args, PORT);
if (value != null) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return DEFAULT_PORT;
}
}
return DEFAULT_PORT;
}
protected String getValue(String[] args, String argName) {