From afaf332ad2f7d4128e00bf4e8c62c073c466f83d Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Tue, 24 May 2022 19:43:50 +0530 Subject: [PATCH] [java] Lazily concatenate string while logging --- .../org/openqa/selenium/remote/ProtocolHandshake.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/java/src/org/openqa/selenium/remote/ProtocolHandshake.java b/java/src/org/openqa/selenium/remote/ProtocolHandshake.java index 3f6c2489ad61a..ac71031257525 100644 --- a/java/src/org/openqa/selenium/remote/ProtocolHandshake.java +++ b/java/src/org/openqa/selenium/remote/ProtocolHandshake.java @@ -41,12 +41,14 @@ import java.util.Map; import java.util.Objects; import java.util.function.Function; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.google.common.net.HttpHeaders.CONTENT_LENGTH; import static com.google.common.net.HttpHeaders.CONTENT_TYPE; +import static com.google.common.net.HttpHeaders.WARNING; import static java.nio.charset.StandardCharsets.UTF_8; import static org.openqa.selenium.json.Json.JSON_UTF_8; import static org.openqa.selenium.remote.CapabilityType.PROXY; @@ -73,10 +75,11 @@ public Result createSession(HttpHandler client, Command command) throws IOExcept .collect(Collectors.toList()); if (!invalid.isEmpty()) { - LOG.warning(String.format("Support for Legacy Capabilities is deprecated; " + - "You are sending the following invalid capabilities: %s; " + - "Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/", - invalid)); + LOG.log(Level.WARNING, + () -> String.format("Support for Legacy Capabilities is deprecated; " + + "You are sending the following invalid capabilities: %s; " + + "Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/", + invalid)); } return toReturn; } else {