diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInfo.java b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInfo.java index 1edb9627798bc..6e80e72a825cb 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInfo.java +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInfo.java @@ -95,37 +95,14 @@ public static BrowsingContextInfo fromJson(JsonInput input) { input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { - case "context": - id = input.read(String.class); - break; - - case "url": - url = input.read(String.class); - break; - - case "children": - children = input.read(LIST_OF_BROWSING_CONTEXT_INFO); - break; - - case "parent": - parentBrowsingContext = input.read(String.class); - break; - - case "clientWindow": - clientWindow = input.read(String.class); - break; - - case "originalOpener": - originalOpener = input.read(String.class); - break; - - case "userContext": - userContext = input.read(String.class); - break; - - default: - input.skipValue(); - break; + case "context" -> id = input.read(String.class); + case "url" -> url = input.read(String.class); + case "children" -> children = input.read(LIST_OF_BROWSING_CONTEXT_INFO); + case "parent" -> parentBrowsingContext = input.read(String.class); + case "clientWindow" -> clientWindow = input.read(String.class); + case "originalOpener" -> originalOpener = input.read(String.class); + case "userContext" -> userContext = input.read(String.class); + default -> input.skipValue(); } } diff --git a/java/src/org/openqa/selenium/support/ThreadGuard.java b/java/src/org/openqa/selenium/support/ThreadGuard.java index ecf4d7d97c697..cb293619261cd 100644 --- a/java/src/org/openqa/selenium/support/ThreadGuard.java +++ b/java/src/org/openqa/selenium/support/ThreadGuard.java @@ -16,14 +16,15 @@ // under the License. package org.openqa.selenium.support; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebDriverException; /** * Multithreaded client code should use this to assert that it accesses webdriver in a thread-safe @@ -44,10 +45,10 @@ public class ThreadGuard { public static WebDriver protect(WebDriver actualWebDriver) { WebDriverInvocationHandler invocationHandler = new WebDriverInvocationHandler(actualWebDriver); return (WebDriver) - java.lang.reflect.Proxy.newProxyInstance( - actualWebDriver.getClass().getClassLoader(), - getInterfaces(actualWebDriver), - invocationHandler); + java.lang.reflect.Proxy.newProxyInstance( + actualWebDriver.getClass().getClassLoader(), + getInterfaces(actualWebDriver), + invocationHandler); } private static Class[] getInterfaces(Object target) { @@ -82,11 +83,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl if (Thread.currentThread().getId() != threadId) { Thread currentThread = Thread.currentThread(); throw new WebDriverException( - String.format( - "Thread safety error; this instance of WebDriver was constructed on " - + "thread %s (id %d) and is being accessed by thread %s (id %d)" - + "This is not permitted and *will* cause undefined behaviour", - threadName, threadId, currentThread.getName(), currentThread.getId())); + String.format( + """ + Thread safety error; this instance of WebDriver was constructed on + thread %s (id %d) and is being accessed by thread %s (id %d) + This is not permitted and *will* cause undefined behaviour + """, threadName, threadId, currentThread.getName(), currentThread.getId())); } return invokeUnderlying(method, args); } catch (InvocationTargetException e) { @@ -95,7 +97,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } protected Object invokeUnderlying(Method method, Object[] args) - throws IllegalAccessException, InvocationTargetException { + throws IllegalAccessException, InvocationTargetException { return method.invoke(underlying, args); } }