What happened?
While running tests on recent versions of Selenium/SeleniumGrid/ChromeDriver/Chrome, we have noticed an intermittent problem, which may be unrelated to this bug report, but I have noticed an issue with the use of ImmutableMap that generates a stack trace (included as the log output).
From a quick check of the code in java/src/org/openqa/selenium/remote/ErrorCodec.java, which looks like:
public Map<String, Object> encode(Throwable throwable) {
Require.nonNull("Throwable to encode", throwable);
W3CError err = fromThrowable(throwable);
return ImmutableMap.of(
"value", ImmutableMap.of(
"error", err.w3cErrorString,
"message", throwable.getMessage(),
"stacktrace", Throwables.getStackTraceAsString(throwable)));
}
if throwable.getMessage() returns a null pointer (which according to spec it can: https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#getMessage() ), the ImmutableMap will fail to be constructed with the exception shown.
This might want to be updated to something like StringUtils.defaultIfNull(throwable.getMessage(), "<no message in throwable>") to avoid this issue.
How can we reproduce the issue?
At this point, I cannot recreate on demand, or with a small set of code. However, I can regularly reproduce in our environment.
The configuration was as follows:
Ubuntu Linux server, running Java 11, with Selenium 4.8.1 running from a JUnit 4 test case, using the jdk-http-client connecting via a Selenium grid hub (version 4.7.2) to a Selenium Grid node running on Windows 2016 Server running Java 11, with Selenium 4.8.0 (with default Netty HTTP client) connecting to our server under test.
I am in the process of re-running the tests after updating the Selenium node to Selenium 4.8.1 with the jdk-http-client. I am not confident it will "fix" the issue, but it's worth trying first, and then I'll need to look into updating the Hub as well.
Relevant log output
2023-03-20 21:38:08.143 [FINE ] org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec decode - Decoding response. Response code was: 500 and content: {
"value": {
"error": "unknown error",
"message": "null value in entry: message=null",
"stacktrace": "java.lang.NullPointerException: null value in entry: message=null\n\tat com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)\n\tat com.google.common.collect.ImmutableMapEntry.\u003cinit>(ImmutableMapEntry.java:54)\n\tat com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:339)\n\tat com.google.common.collect.ImmutableMap.of(ImmutableMap.java:146)\n\tat org.openqa.selenium.remote.ErrorCodec.encode(ErrorCodec.java:101)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:50)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"
}
}
Operating System
Windows + Linux
Selenium version
4.8.1 Java 11, 4.8.0 Java 11, 4.7.2 Java 8
What are the browser(s) and version(s) where you see this issue?
Chrome 111
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver
Are you using Selenium Grid?
Yes; 4.7.2
What happened?
While running tests on recent versions of Selenium/SeleniumGrid/ChromeDriver/Chrome, we have noticed an intermittent problem, which may be unrelated to this bug report, but I have noticed an issue with the use of ImmutableMap that generates a stack trace (included as the log output).
From a quick check of the code in
java/src/org/openqa/selenium/remote/ErrorCodec.java, which looks like:if
throwable.getMessage()returns a null pointer (which according to spec it can: https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#getMessage() ), theImmutableMapwill fail to be constructed with the exception shown.This might want to be updated to something like
StringUtils.defaultIfNull(throwable.getMessage(), "<no message in throwable>")to avoid this issue.How can we reproduce the issue?
Relevant log output
2023-03-20 21:38:08.143 [FINE ] org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec decode - Decoding response. Response code was: 500 and content: { "value": { "error": "unknown error", "message": "null value in entry: message=null", "stacktrace": "java.lang.NullPointerException: null value in entry: message=null\n\tat com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)\n\tat com.google.common.collect.ImmutableMapEntry.\u003cinit>(ImmutableMapEntry.java:54)\n\tat com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:339)\n\tat com.google.common.collect.ImmutableMap.of(ImmutableMap.java:146)\n\tat org.openqa.selenium.remote.ErrorCodec.encode(ErrorCodec.java:101)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:50)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n" } }Operating System
Windows + Linux
Selenium version
4.8.1 Java 11, 4.8.0 Java 11, 4.7.2 Java 8
What are the browser(s) and version(s) where you see this issue?
Chrome 111
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver
Are you using Selenium Grid?
Yes; 4.7.2