Skip to content

Commit 3738c97

Browse files
committed
[java] Removing host info for most cases, except SessionNotCreatedException
Host info is not adding much value nowadays in Grid because most of the time the infrastructure is containerized, which means that the wrong host info is reported. In the local use case, showing the user their own local IP, does not add much value either. Fixes #9792
1 parent 9f4f47e commit 3738c97

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

java/src/org/openqa/selenium/SessionNotCreatedException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
*/
2323
public class SessionNotCreatedException extends WebDriverException {
2424
public SessionNotCreatedException(String msg) {
25-
super("Could not start a new session. " + msg);
25+
super("Could not start a new session. " + msg +
26+
(msg != null && msg.contains("Host info") ? "" : " \n" + getHostInformation()));
2627
}
2728

2829
public SessionNotCreatedException(String msg, Throwable cause) {
29-
super("Could not start a new session. " + msg, cause);
30+
super("Could not start a new session. " + msg +
31+
(msg != null && msg.contains("Host info") ? "" : " \n" + getHostInformation()), cause);
3032
}
3133
}

java/src/org/openqa/selenium/WebDriverException.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.openqa.selenium.net.HostIdentifier;
2121

22-
import java.util.HashMap;
2322
import java.util.Map;
2423
import java.util.Optional;
2524
import java.util.concurrent.ConcurrentHashMap;
@@ -54,7 +53,6 @@ public WebDriverException(String message, Throwable cause) {
5453
* Returns the detail message string of this exception that includes not only the original
5554
* message passed to the exception constructor but also driver information, system
5655
* information and extra information added by {@link #addInfo(String, String)} method.
57-
*
5856
* To get the original message use {@link #getRawMessage()}
5957
*
6058
* @return the detail message string of this exception.
@@ -91,12 +89,17 @@ private String createMessage(String originalMessageString) {
9189

9290
public String getSystemInformation() {
9391
return String.format(
94-
"System info: host: '%s', ip: '%s', os.name: '%s', os.arch: '%s', os.version: '%s', java.version: '%s'",
95-
HostIdentifier.getHostName(), HostIdentifier.getHostAddress(),
92+
"System info: os.name: '%s', os.arch: '%s', os.version: '%s', java.version: '%s'",
9693
System.getProperty("os.name"), System.getProperty("os.arch"),
9794
System.getProperty("os.version"), System.getProperty("java.version"));
9895
}
9996

97+
public static String getHostInformation() {
98+
return String.format(
99+
"Host info: host: '%s', ip: '%s'",
100+
HostIdentifier.getHostName(), HostIdentifier.getHostAddress());
101+
}
102+
100103
public String getSupportUrl() {
101104
return null;
102105
}

java/src/org/openqa/selenium/remote/ErrorCodes.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public class ErrorCodes {
7979
public static final int UNEXPECTED_ALERT_PRESENT = 26;
8080
public static final int NO_ALERT_PRESENT = 27;
8181
public static final int ASYNC_SCRIPT_TIMEOUT = 28;
82-
public static final int IME_NOT_AVAILABLE = 30;
83-
public static final int IME_ENGINE_ACTIVATION_FAILED = 31;
8482
public static final int INVALID_SELECTOR_ERROR = 32;
8583
public static final int SESSION_NOT_CREATED = 33;
8684
public static final int MOVE_TARGET_OUT_OF_BOUNDS = 34;

0 commit comments

Comments
 (0)