From 66a4aa924f5a114d9e3820551f0d3f84033f59d3 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Feb 2025 06:42:57 +0700 Subject: [PATCH 1/5] replace equals with isEmpty --- java/src/org/openqa/selenium/Cookie.java | 2 +- java/src/org/openqa/selenium/Platform.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/Cookie.java b/java/src/org/openqa/selenium/Cookie.java index e5b98a0d6cd9f..94009d6d64d7c 100644 --- a/java/src/org/openqa/selenium/Cookie.java +++ b/java/src/org/openqa/selenium/Cookie.java @@ -275,7 +275,7 @@ public String toString() { + "=" + value + (expiry == null ? "" : "; expires=" + sdf.format(expiry)) - + ("".equals(path) ? "" : "; path=" + path) + + (path.isEmpty() ? "" : "; path=" + path) + (domain == null ? "" : "; domain=" + domain) + (isSecure ? ";secure;" : "") + (sameSite == null ? "" : "; sameSite=" + sameSite); diff --git a/java/src/org/openqa/selenium/Platform.java b/java/src/org/openqa/selenium/Platform.java index e4bc941cdfd4e..072c35df47686 100644 --- a/java/src/org/openqa/selenium/Platform.java +++ b/java/src/org/openqa/selenium/Platform.java @@ -447,7 +447,7 @@ public static Platform extractFromSysProperty(String osName, String osVersion) { String previousMatch = null; for (Platform os : Platform.values()) { for (String matcher : os.partOfOsName) { - if ("".equals(matcher)) { + if (matcher.isEmpty()) { continue; } matcher = matcher.toLowerCase(Locale.ENGLISH); From 07dab26dd4bb3df5a514023cef4cf46516559fd0 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Feb 2025 06:48:54 +0700 Subject: [PATCH 2/5] removed redundant String operation --- java/src/dev/selenium/tools/modules/ModuleGenerator.java | 2 +- .../openqa/selenium/remote/codec/AbstractHttpCommandCodec.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/dev/selenium/tools/modules/ModuleGenerator.java b/java/src/dev/selenium/tools/modules/ModuleGenerator.java index 409d233eb2e9e..4490e78bd8dbf 100644 --- a/java/src/dev/selenium/tools/modules/ModuleGenerator.java +++ b/java/src/dev/selenium/tools/modules/ModuleGenerator.java @@ -216,7 +216,7 @@ public static void main(String[] args) throws IOException { + "jdeps " + String.join(" ", jdepsArgs) + "\n" - + new String(bos.toByteArray())); + + bos); } AtomicReference moduleInfo = new AtomicReference<>(); diff --git a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java index df6318a11ed14..43a43b50edcff 100644 --- a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java +++ b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java @@ -237,7 +237,7 @@ public HttpRequest encode(Command command) { byte[] data = content.getBytes(UTF_8); request.setHeader(HttpHeader.ContentLength.getName(), String.valueOf(data.length)); - request.setHeader(HttpHeader.ContentType.getName(), JSON_UTF_8.toString()); + request.setHeader(HttpHeader.ContentType.getName(), JSON_UTF_8); request.setContent(bytes(data)); } From b07731b3665fb7cf27bde418109bb28b6d285f33 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Feb 2025 06:56:54 +0700 Subject: [PATCH 3/5] formatting --- java/src/dev/selenium/tools/modules/ModuleGenerator.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/java/src/dev/selenium/tools/modules/ModuleGenerator.java b/java/src/dev/selenium/tools/modules/ModuleGenerator.java index 4490e78bd8dbf..ebe4a9bf6bbb7 100644 --- a/java/src/dev/selenium/tools/modules/ModuleGenerator.java +++ b/java/src/dev/selenium/tools/modules/ModuleGenerator.java @@ -212,11 +212,7 @@ public static void main(String[] args) throws IOException { } if (result != 0) { throw new RuntimeException( - "Unable to process module:\n" - + "jdeps " - + String.join(" ", jdepsArgs) - + "\n" - + bos); + "Unable to process module:\n" + "jdeps " + String.join(" ", jdepsArgs) + "\n" + bos); } AtomicReference moduleInfo = new AtomicReference<>(); From 56869411aa9c93205dd4824bf1e1ca0b86e14e29 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 3 Mar 2025 16:46:32 +0700 Subject: [PATCH 4/5] revert string comapre to empty string --- java/src/org/openqa/selenium/Cookie.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/Cookie.java b/java/src/org/openqa/selenium/Cookie.java index 94009d6d64d7c..e5b98a0d6cd9f 100644 --- a/java/src/org/openqa/selenium/Cookie.java +++ b/java/src/org/openqa/selenium/Cookie.java @@ -275,7 +275,7 @@ public String toString() { + "=" + value + (expiry == null ? "" : "; expires=" + sdf.format(expiry)) - + (path.isEmpty() ? "" : "; path=" + path) + + ("".equals(path) ? "" : "; path=" + path) + (domain == null ? "" : "; domain=" + domain) + (isSecure ? ";secure;" : "") + (sameSite == null ? "" : "; sameSite=" + sameSite); From 47add761d0af2db214af4f2185a1d387cd4caa6b Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Mar 2025 12:40:32 +0700 Subject: [PATCH 5/5] replace concat with string format + format.sh --- java/src/dev/selenium/tools/modules/ModuleGenerator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/dev/selenium/tools/modules/ModuleGenerator.java b/java/src/dev/selenium/tools/modules/ModuleGenerator.java index ebe4a9bf6bbb7..41e180aadc508 100644 --- a/java/src/dev/selenium/tools/modules/ModuleGenerator.java +++ b/java/src/dev/selenium/tools/modules/ModuleGenerator.java @@ -60,6 +60,7 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -212,7 +213,9 @@ public static void main(String[] args) throws IOException { } if (result != 0) { throw new RuntimeException( - "Unable to process module:\n" + "jdeps " + String.join(" ", jdepsArgs) + "\n" + bos); + String.format( + "Unable to process module:%njdeps %s%n%s", + String.join(" ", jdepsArgs), bos.toString(StandardCharsets.UTF_8))); } AtomicReference moduleInfo = new AtomicReference<>();