Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ea410d1
[java] Make selenium.debug/webdriver.verbose configure the real logger
MohabMohie Jul 28, 2026
7fcf6b6
[java] Fix review findings in the debug logging mechanism change
MohabMohie Jul 28, 2026
a30865b
[java] Add javadoc to LoggingOptions#setLoggingLevel and RemoteWebDri…
MohabMohie Jul 28, 2026
e732035
[java] Address qodo review findings: Debug logger verbosity, RetryReq…
MohabMohie Jul 28, 2026
31ea2ca
[java] Fix logger-field lint finding and de-mock a RemoteWebDriver test
MohabMohie Jul 28, 2026
d44ad4e
Merge branch 'SeleniumHQ:trunk' into debug-logging-consistency-mechanism
MohabMohie Jul 28, 2026
cdf85f7
[java] Configure debug logger before driver discovery in DriverFinder
MohabMohie Jul 28, 2026
63b0e87
[java] Migrate grid distributor logging off deprecated getDebugLogLev…
MohabMohie Jul 28, 2026
fb70a79
[java] Migrate node/netty/remote logging off deprecated getDebugLogLe…
MohabMohie Jul 28, 2026
1f03c23
[java] Migrate devtools/bidi Connection logging off deprecated getDeb…
MohabMohie Jul 28, 2026
9c3f4ff
[java] Fix RetryRequestTest for the getDebugLogLevel() migration
MohabMohie Jul 28, 2026
6b86a19
Fix qodo-code-review round-2 findings: null-capabilities NPE, retry/r…
MohabMohie Jul 28, 2026
f46f340
[java] Fix LoggingOptions.configureLogging() stripping Debug's just-i…
MohabMohie Jul 28, 2026
ad47d32
[java] Add regression test proving devtools.Connection configures the…
MohabMohie Jul 28, 2026
a4abcb7
[java] De-mock constructorTreatsNullCapabilitiesAsEmptyCapabilities
MohabMohie Jul 28, 2026
b030733
[java] Add regression test for RedisBackedNodeRegistry's WARNING log …
MohabMohie Jul 28, 2026
a3e7dc3
[java] Fix duplicate FINE-range org.openqa.selenium output on Grid's …
MohabMohie Jul 28, 2026
2fba7ef
[java] De-mock secondDiscoveryPicksUpADebugPropertyChangedAfterTheFirst
MohabMohie Jul 28, 2026
d864d0c
[java] Close the live-property race in isHandledBySeleniumDebugHandler()
MohabMohie Jul 29, 2026
71be924
[java] Do not suppress Selenium debug records from a configured Grid …
MohabMohie Jul 29, 2026
f8129c5
[java] Check the real handler list in isHandlerCurrentlyInstalled(), …
MohabMohie Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions java/src/org/openqa/selenium/bidi/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openqa.selenium.bidi;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
import static org.openqa.selenium.json.Json.MAP_TYPE;
import static org.openqa.selenium.remote.http.HttpMethod.GET;

Expand Down Expand Up @@ -47,6 +46,7 @@
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.Beta;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.internal.Debug;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
Expand Down Expand Up @@ -78,6 +78,11 @@ public class Connection implements Closeable {
private final AtomicBoolean underlyingSocketClosed = new AtomicBoolean(false);

public Connection(HttpClient client, String url) {
// Reflect the current debug switches before this connection starts logging its wire
// diagnostics at FINE -- callers that construct a Connection directly (never going through
// RemoteWebDriver or DriverFinder) would otherwise never trigger the raise. Idempotent and
// cheap, same pattern as DriverFinder.getBinaryPaths().
Debug.configureLogger();
Comment thread
MohabMohie marked this conversation as resolved.
Require.nonNull("HTTP client", client);
Require.nonNull("URL to connect to", url);

Expand Down Expand Up @@ -147,7 +152,7 @@ public String toString() {
try (JsonOutput out = JSON.newOutput(json).writeClassName(false)) {
out.write(serialized);
}
LOG.log(getDebugLogLevel(), "-> {0}", json);
LOG.log(Level.FINE, "-> {0}", json);
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
socket.sendText(json);

if (!command.getSendsResponse()) {
Expand Down Expand Up @@ -302,7 +307,7 @@ private void handle(CharSequence data) {
// TODO: decode once, and once only

String asString = String.valueOf(data);
LOG.log(getDebugLogLevel(), "<- {0}", asString);
LOG.log(Level.FINE, "<- {0}", asString);

Map<String, Object> raw = JSON.toType(asString, MAP_TYPE);
if (raw.get("id") instanceof Number
Expand Down Expand Up @@ -346,7 +351,7 @@ private void handleResponse(String rawDataString, Map<String, Object> rawDataMap

private void handleEventResponse(Map<String, Object> rawDataMap) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
() ->
String.format(
"Method %s called with %s callbacks available",
Expand All @@ -365,7 +370,7 @@ private void handleEventResponse(Map<String, Object> rawDataMap) {
.filter(
event -> {
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Matching {0} with {1}",
new Object[] {rawDataMap.get("method"), event.getKey().getMethod()});
return rawDataMap.get("method").equals(event.getKey().getMethod());
Expand All @@ -387,7 +392,7 @@ private void handleEventResponse(Map<String, Object> rawDataMap) {
@SuppressWarnings("unchecked")
Consumer<Object> obj = (Consumer<Object>) action;
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Calling callback for {0} using {1} being passed {2}",
new Object[] {event.getKey(), obj, finalValue});
obj.accept(finalValue);
Expand Down
18 changes: 12 additions & 6 deletions java/src/org/openqa/selenium/devtools/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openqa.selenium.devtools;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
import static org.openqa.selenium.json.Json.MAP_TYPE;
import static org.openqa.selenium.remote.http.HttpMethod.GET;

Expand Down Expand Up @@ -51,6 +50,7 @@
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.devtools.idealized.target.model.SessionID;
import org.openqa.selenium.internal.Debug;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
Expand Down Expand Up @@ -92,6 +92,12 @@ public Connection(HttpClient client, String url) {
}

public Connection(HttpClient client, String url, ClientConfig clientConfig) {
// Reflect the current debug switches before this connection starts logging its wire
// diagnostics at FINE -- callers that construct a Connection directly (never going through
// RemoteWebDriver or DriverFinder) would otherwise never trigger the raise. Idempotent and
// cheap, same pattern as DriverFinder.getBinaryPaths(). The deprecated 2-arg constructor
// delegates here, so this single call point covers both.
Debug.configureLogger();
this.client = Require.nonNull("HTTP client", client);
this.wsConfig = wsClientConfig(clientConfig, url);
this.socket = this.client.openSocket(new HttpRequest(GET, wsConfig.baseUri()), new Listener());
Expand Down Expand Up @@ -182,7 +188,7 @@ public <X> CompletableFuture<X> send(@Nullable SessionID sessionId, Command<X> c
try (JsonOutput out = JSON.newOutput(json).writeClassName(false)) {
out.write(Map.copyOf(serialized));
}
LOG.log(getDebugLogLevel(), "-> {0}", json);
LOG.log(Level.FINE, "-> {0}", json);
socket.sendText(json);

if (!command.getSendsResponse()) {
Expand Down Expand Up @@ -267,7 +273,7 @@ private void handle(long sequence, CharSequence data) {
// TODO: decode once, and once only

String asString = String.valueOf(data);
LOG.log(getDebugLogLevel(), "<- {0}", asString);
LOG.log(Level.FINE, "<- {0}", asString);

Map<String, Object> raw = JSON.toType(asString, MAP_TYPE);
if (raw.get("id") instanceof Number
Expand Down Expand Up @@ -300,7 +306,7 @@ private void handle(long sequence, CharSequence data) {
}
} else if (raw.get("method") instanceof String && raw.get("params") instanceof Map) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Method {0} called with {1} callbacks available",
new Object[] {raw.get("method"), eventCallbacks.size()});
Lock lock = callbacksLock.readLock();
Expand All @@ -320,7 +326,7 @@ private void handle(long sequence, CharSequence data) {
.peek(
event ->
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Matching {0} with {1}",
new Object[] {raw.get("method"), event.getKey().getMethod()}))
.filter(event -> raw.get("method").equals(event.getKey().getMethod()))
Expand Down Expand Up @@ -358,7 +364,7 @@ private void handle(long sequence, CharSequence data) {
@SuppressWarnings("unchecked")
BiConsumer<Long, Object> obj = (BiConsumer<Long, Object>) action;
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Calling callback for {0} using {1} being passed {2}",
new Object[] {event.getKey(), obj, params});
obj.accept(sequence, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openqa.selenium.grid.distributor.local;

import static org.openqa.selenium.concurrent.ExecutorServices.shutdownGracefully;
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES;
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT;
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
Expand Down Expand Up @@ -464,7 +463,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) {

if (slotIds.isEmpty()) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
String.format("No slots found for request %s and capabilities %s", requestId, caps));
return null;
}
Expand Down Expand Up @@ -574,7 +573,7 @@ public void run() {
sessionCreatorExecutor.execute(() -> handleNewSessionRequest(req));
} catch (RejectedExecutionException e) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Dropping session creation task while shutting down distributor",
e);
}
Expand Down Expand Up @@ -632,9 +631,7 @@ private void handleNewSessionRequest(SessionRequest sessionRequest) {

if (response.isLeft() && response.left() instanceof RetrySessionRequestException) {
try (Span childSpan = span.createSpan("distributor.retry")) {
if (LOG.isLoggable(getDebugLogLevel())) {
LOG.log(getDebugLogLevel(), "Retrying {0}", sessionRequest.getDesiredCapabilities());
}
LOG.log(Level.FINE, "Retrying {0}", sessionRequest.getDesiredCapabilities());
boolean retried = sessionQueue.retryAddToQueue(sessionRequest);

attributeMap.put("request.retry_add", retried);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.events.EventBus;
Expand All @@ -49,7 +50,6 @@
import org.openqa.selenium.grid.data.SlotId;
import org.openqa.selenium.grid.distributor.GridModel;
import org.openqa.selenium.grid.server.EventBusOptions;
import org.openqa.selenium.internal.Debug;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.SessionId;

Expand Down Expand Up @@ -101,7 +101,7 @@ public void add(NodeStatus node) {
&& next.getExternalUri().equals(node.getExternalUri())) {
iterator.remove();

LOG.log(Debug.getDebugLogLevel(), "Refreshing node with id {0}", node.getNodeId());
LOG.log(Level.FINE, "Refreshing node with id {0}", node.getNodeId());
NodeStatus refreshed = rewrite(node, next.getAvailability());
nodes.add(refreshed);
nodePurgeTimes.put(refreshed.getNodeId(), Instant.now());
Expand Down Expand Up @@ -140,7 +140,7 @@ public void add(NodeStatus node) {

// Nodes are initially added in the "down" state until something changes their availability
LOG.log(
Debug.getDebugLogLevel(),
Level.FINE,
"Adding node with id {0} and URI {1}",
new Object[] {node.getNodeId(), node.getExternalUri()});
NodeStatus refreshed = rewrite(node, DOWN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.openqa.selenium.grid.data.Availability.DOWN;
import static org.openqa.selenium.grid.data.Availability.DRAINING;
import static org.openqa.selenium.grid.data.Availability.UP;
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;

import java.net.URI;
import java.time.Duration;
Expand Down Expand Up @@ -228,7 +227,7 @@ public void add(Node node) {
}
} catch (Exception e) {
LOG.log(
getDebugLogLevel(), String.format("Exception while adding Node %s", node.getUri()), e);
Level.WARNING, String.format("Exception while adding Node %s", node.getUri()), e);
return;
}

Expand Down Expand Up @@ -298,7 +297,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi
writeLock.lock();
try {
LOG.log(
getDebugLogLevel(),
Level.FINE,
String.format("Health check result for %s was %s", nodeUri, availability));
model.setAvailability(id, availability);
model.updateHealthCheckCount(id, availability);
Expand All @@ -310,7 +309,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi
@Override
public void runHealthChecks() {
if (!healthChecksInProgress.compareAndSet(false, true)) {
LOG.log(getDebugLogLevel(), "Skipping health checks because previous cycle is still running");
LOG.log(Level.FINE, "Skipping health checks because previous cycle is still running");
return;
}

Expand All @@ -335,7 +334,7 @@ public void runHealthChecks() {
futures.add(nodeHealthCheckExecutor.submit(() -> runHealthCheck(nodeId, check)));
} catch (RejectedExecutionException e) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
String.format(
"Unable to schedule health check for node %s, running in caller thread",
nodeId),
Expand All @@ -351,7 +350,7 @@ public void runHealthChecks() {
Thread.currentThread().interrupt();
break;
} catch (Exception e) {
LOG.log(getDebugLogLevel(), "Error waiting for health check execution", e);
LOG.log(Level.FINE, "Error waiting for health check execution", e);
}
}
} finally {
Expand Down Expand Up @@ -452,7 +451,7 @@ private void runHealthCheck(NodeId nodeId, Runnable check) {
try {
check.run();
} catch (Throwable t) {
LOG.log(getDebugLogLevel(), "Health check execution failed for node " + nodeId, t);
LOG.log(Level.FINE, "Health check execution failed for node " + nodeId, t);
}
}

Expand All @@ -462,7 +461,7 @@ private Runnable asRunnableHealthCheck(Node node) {
return () -> {
boolean checkFailed = false;
Exception failedCheckException = null;
LOG.log(getDebugLogLevel(), "Running healthcheck for Node " + node.getUri());
LOG.log(Level.FINE, "Running healthcheck for Node " + node.getUri());

HealthCheck.Result result;
try {
Expand Down Expand Up @@ -500,7 +499,7 @@ public boolean reserve(SlotId slotId) {
NodeId nodeId = slotId.getOwningNodeId();
Node node = nodes.get(nodeId);
if (node == null) {
LOG.log(getDebugLogLevel(), String.format("Unable to find node with id %s", slotId));
LOG.log(Level.FINE, String.format("Unable to find node with id %s", slotId));
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openqa.selenium.grid.distributor.redis;

import static org.openqa.selenium.concurrent.ExecutorServices.shutdownGracefully;
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES;
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT;
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
Expand Down Expand Up @@ -506,7 +505,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) {

if (slotIds.isEmpty()) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
String.format("No slots found for request %s and capabilities %s", requestId, caps));
return null;
}
Expand Down Expand Up @@ -629,7 +628,7 @@ public void run() {
sessionCreatorExecutor.execute(() -> handleNewSessionRequest(req));
} catch (RejectedExecutionException e) {
LOG.log(
getDebugLogLevel(),
Level.FINE,
"Dropping session creation task while shutting down distributor",
e);
}
Expand Down Expand Up @@ -684,9 +683,7 @@ private void handleNewSessionRequest(SessionRequest sessionRequest) {

if (response.isLeft() && response.left() instanceof RetrySessionRequestException) {
try (Span childSpan = span.createSpan("distributor.retry")) {
if (LOG.isLoggable(getDebugLogLevel())) {
LOG.log(getDebugLogLevel(), "Retrying {0}", sessionRequest.getDesiredCapabilities());
}
LOG.log(Level.FINE, "Retrying {0}", sessionRequest.getDesiredCapabilities());
boolean retried = sessionQueue.retryAddToQueue(sessionRequest);
attributeMap.put("request.retry_add", retried);
childSpan.addEvent("Retry adding to front of queue. No slot available.", attributeMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.events.EventBus;
Expand All @@ -40,7 +41,6 @@
import org.openqa.selenium.grid.data.Slot;
import org.openqa.selenium.grid.data.SlotId;
import org.openqa.selenium.grid.distributor.GridModel;
import org.openqa.selenium.internal.Debug;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.redis.GridRedisClient;
Expand Down Expand Up @@ -197,7 +197,7 @@ public void add(NodeStatus node) {
if (existing.getNodeId().equals(node.getNodeId())
&& existing.getExternalUri().equals(node.getExternalUri())) {
// Same node refreshing β€” keep existing availability.
LOG.log(Debug.getDebugLogLevel(), "Refreshing node with id {0}", node.getNodeId());
LOG.log(Level.FINE, "Refreshing node with id {0}", node.getNodeId());
NodeStatus refreshed = rewrite(node, existing.getAvailability());
writeNodeBlob(refreshed);
redis.set(lastTouchKey(node.getNodeId()), String.valueOf(Instant.now().toEpochMilli()));
Expand Down Expand Up @@ -229,7 +229,7 @@ public void add(NodeStatus node) {

// Add as DOWN until health check promotes it.
LOG.log(
Debug.getDebugLogLevel(),
Level.FINE,
"Adding node with id {0} and URI {1}",
new Object[] {node.getNodeId(), node.getExternalUri()});
NodeStatus asDown = rewrite(node, DOWN);
Expand Down
Loading