diff --git a/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java b/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java index c68fb15e2584d2..74779b9adcc45b 100644 --- a/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java +++ b/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java @@ -111,8 +111,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) } private static class Model { - private List domains = new ArrayList<>(); - private String basePackage; + private final List domains = new ArrayList<>(); + private final String basePackage; public Model(String basePackage) { this.basePackage = basePackage; @@ -148,7 +148,7 @@ public void dumpTo(Path target) { } private static class Parser { - private Map> processors; + private final Map> processors; public Parser(Map> processors) { this.processors = processors; @@ -246,11 +246,11 @@ public TypedSpecParser(boolean inline, Map> extraP } private static class Domain extends BaseSpec { - private Model model; + private final Model model; - private List types = new ArrayList<>(); - private List commands = new ArrayList<>(); - private List events = new ArrayList<>(); + private final List types = new ArrayList<>(); + private final List commands = new ArrayList<>(); + private final List events = new ArrayList<>(); public Domain(Model model) { this.model = model; @@ -776,8 +776,8 @@ public String getMapper() { } private static class SimpleType implements IType { - private String name; - private String type; + private final String name; + private final String type; public SimpleType(String name, String type) { this.name = name; @@ -1034,9 +1034,9 @@ public String getJavaType() { private static class ObjectType implements IType { - private TypedSpec parent; - private String name; - private List properties; + private final TypedSpec parent; + private final String name; + private final List properties; public ObjectType(TypedSpec parent, String name, List properties) { this.parent = parent; @@ -1184,7 +1184,7 @@ public String getMapper() { private static class ArrayType implements IType { private IType itemType; - private String name; + private final String name; public ArrayType(String name) { this.name = name; @@ -1263,9 +1263,9 @@ public void parse(Domain domain, Map json) { } private static class RefType implements IType { - private String name; - private Domain domain; - private String type; + private final String name; + private final Domain domain; + private final String type; public RefType(String name, Domain domain, String type) { this.name = name; diff --git a/java/src/org/openqa/selenium/devtools/noop/NoOpDomains.java b/java/src/org/openqa/selenium/devtools/noop/NoOpDomains.java index de901714236adf..dc73af95fb3730 100644 --- a/java/src/org/openqa/selenium/devtools/noop/NoOpDomains.java +++ b/java/src/org/openqa/selenium/devtools/noop/NoOpDomains.java @@ -28,7 +28,7 @@ public class NoOpDomains implements Domains { - private static BuildInfo INFO = new BuildInfo(); + private static final BuildInfo INFO = new BuildInfo(); private static final String WARNING = String.format( diff --git a/java/src/org/openqa/selenium/events/zeromq/UnboundZmqEventBus.java b/java/src/org/openqa/selenium/events/zeromq/UnboundZmqEventBus.java index d29fc4a318184e..6e68a12e2c76d1 100644 --- a/java/src/org/openqa/selenium/events/zeromq/UnboundZmqEventBus.java +++ b/java/src/org/openqa/selenium/events/zeromq/UnboundZmqEventBus.java @@ -68,7 +68,7 @@ class UnboundZmqEventBus implements EventBus { private final Map>> listeners = new ConcurrentHashMap<>(); private final Queue recentMessages = EvictingQueue.create(128); private final String encodedSecret; - private ZMQ.Poller poller; + private final ZMQ.Poller poller; private ZMQ.Socket pub; private ZMQ.Socket sub; diff --git a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java index ef05248ab8f265..0202f849ca2f2f 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -90,7 +90,7 @@ public class FirefoxDriver extends RemoteWebDriver private final Optional biDiUri; private Connection connection; private DevTools devTools; - private Optional biDi; + private final Optional biDi; /** * Creates a new FirefoxDriver using the {@link GeckoDriverService#createDefaultService)} server diff --git a/java/src/org/openqa/selenium/firefox/Preferences.java b/java/src/org/openqa/selenium/firefox/Preferences.java index 984d200508cfea..ec8a270448aff2 100644 --- a/java/src/org/openqa/selenium/firefox/Preferences.java +++ b/java/src/org/openqa/selenium/firefox/Preferences.java @@ -58,8 +58,8 @@ class Preferences { private static final Pattern PREFERENCE_PATTERN = Pattern.compile("user_pref\\(\"([^\"]+)\", (\"?.+?\"?)\\);"); - private Map immutablePrefs = new HashMap<>(); - private Map allPrefs = new HashMap<>(); + private final Map immutablePrefs = new HashMap<>(); + private final Map allPrefs = new HashMap<>(); public Preferences() {} diff --git a/java/src/org/openqa/selenium/firefox/ProfilesIni.java b/java/src/org/openqa/selenium/firefox/ProfilesIni.java index e7f4113b6ea9ce..1bd5380e8e0afb 100644 --- a/java/src/org/openqa/selenium/firefox/ProfilesIni.java +++ b/java/src/org/openqa/selenium/firefox/ProfilesIni.java @@ -34,7 +34,7 @@ import org.openqa.selenium.io.TemporaryFilesystem; public class ProfilesIni { - private Map profiles; + private final Map profiles; public ProfilesIni() { File appData = locateAppDataDirectory(Platform.getCurrent()); diff --git a/java/src/org/openqa/selenium/json/JsonInput.java b/java/src/org/openqa/selenium/json/JsonInput.java index 9334bff9fe1e3f..22dce783a53a78 100644 --- a/java/src/org/openqa/selenium/json/JsonInput.java +++ b/java/src/org/openqa/selenium/json/JsonInput.java @@ -38,7 +38,7 @@ public class JsonInput implements Closeable { private final Reader source; // FIXME: This flag is never set - private volatile boolean readPerformed = false; + private final boolean readPerformed = false; private JsonTypeCoercer coercer; private PropertySetting setter; private final Input input; diff --git a/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java b/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java index 89f9f446f99a8f..45d4dd1f703531 100644 --- a/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java +++ b/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java @@ -28,8 +28,8 @@ * LocalLogs instance. */ class CompositeLocalLogs extends LocalLogs { - private LocalLogs predefinedTypeLogger; - private LocalLogs allTypesLogger; + private final LocalLogs predefinedTypeLogger; + private final LocalLogs allTypesLogger; protected CompositeLocalLogs(LocalLogs predefinedTypeLogger, LocalLogs allTypesLogger) { super(); diff --git a/java/src/org/openqa/selenium/netty/server/MessageInboundConverter.java b/java/src/org/openqa/selenium/netty/server/MessageInboundConverter.java index 67e4da296e1867..377362972472bb 100644 --- a/java/src/org/openqa/selenium/netty/server/MessageInboundConverter.java +++ b/java/src/org/openqa/selenium/netty/server/MessageInboundConverter.java @@ -46,8 +46,8 @@ private enum Continuation { private static final Logger LOG = Logger.getLogger(MessageInboundConverter.class.getName()); private Continuation next; - private StringBuilder builder; - private ByteArrayOutputStream buffer; + private final StringBuilder builder; + private final ByteArrayOutputStream buffer; public MessageInboundConverter() { next = Continuation.None; diff --git a/java/src/org/openqa/selenium/netty/server/SeleniumHttpInitializer.java b/java/src/org/openqa/selenium/netty/server/SeleniumHttpInitializer.java index 389776bdcdbcf7..7e9785f54967f6 100644 --- a/java/src/org/openqa/selenium/netty/server/SeleniumHttpInitializer.java +++ b/java/src/org/openqa/selenium/netty/server/SeleniumHttpInitializer.java @@ -34,10 +34,10 @@ class SeleniumHttpInitializer extends ChannelInitializer { - private static AttributeKey> KEY = AttributeKey.newInstance("se-ws-handler"); - private HttpHandler seleniumHandler; + private static final AttributeKey> KEY = AttributeKey.newInstance("se-ws-handler"); + private final HttpHandler seleniumHandler; private final BiFunction, Optional>> webSocketHandler; - private SslContext sslCtx; + private final SslContext sslCtx; private final boolean allowCors; SeleniumHttpInitializer( diff --git a/java/src/org/openqa/selenium/os/OsProcess.java b/java/src/org/openqa/selenium/os/OsProcess.java index 54847a94371a05..e8097e122c5493 100644 --- a/java/src/org/openqa/selenium/os/OsProcess.java +++ b/java/src/org/openqa/selenium/os/OsProcess.java @@ -54,7 +54,7 @@ class OsProcess { private final Executor executor = new DaemonExecutor(); private volatile OutputStream drainTo; - private SeleniumWatchDog executeWatchdog = new SeleniumWatchDog(ExecuteWatchdog.INFINITE_TIMEOUT); + private final SeleniumWatchDog executeWatchdog = new SeleniumWatchDog(ExecuteWatchdog.INFINITE_TIMEOUT); private PumpStreamHandler streamHandler; private final org.apache.commons.exec.CommandLine cl; diff --git a/java/src/org/openqa/selenium/remote/ErrorHandler.java b/java/src/org/openqa/selenium/remote/ErrorHandler.java index ae5d0f8bbbad50..59efe5abc7b39b 100644 --- a/java/src/org/openqa/selenium/remote/ErrorHandler.java +++ b/java/src/org/openqa/selenium/remote/ErrorHandler.java @@ -47,7 +47,7 @@ public class ErrorHandler { private static final String UNKNOWN_METHOD = ""; private static final String UNKNOWN_FILE = null; - private ErrorCodes errorCodes; + private final ErrorCodes errorCodes; private boolean includeServerErrors; diff --git a/java/src/org/openqa/selenium/remote/http/Contents.java b/java/src/org/openqa/selenium/remote/http/Contents.java index 2962f229f23dce..f0e48e2f868d3b 100644 --- a/java/src/org/openqa/selenium/remote/http/Contents.java +++ b/java/src/org/openqa/selenium/remote/http/Contents.java @@ -157,7 +157,7 @@ private static final class MemoizedSupplier implements Supplier { private volatile boolean initialized; private volatile FileBackedOutputStream fos; - private Supplier delegate; + private final Supplier delegate; private MemoizedSupplier(Supplier delegate) { this.delegate = delegate; diff --git a/java/src/org/openqa/selenium/support/ByIdOrName.java b/java/src/org/openqa/selenium/support/ByIdOrName.java index 469e71d04a2c92..e83d8b38c51221 100644 --- a/java/src/org/openqa/selenium/support/ByIdOrName.java +++ b/java/src/org/openqa/selenium/support/ByIdOrName.java @@ -29,9 +29,9 @@ public class ByIdOrName extends By implements Serializable { private static final long serialVersionUID = 3986638402799576701L; - private By idFinder; - private By nameFinder; - private String idOrName; + private final By idFinder; + private final By nameFinder; + private final String idOrName; public ByIdOrName(String idOrName) { this.idOrName = idOrName; diff --git a/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java b/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java index adc3477506f510..e9ef9c85686e06 100644 --- a/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java +++ b/java/src/org/openqa/selenium/support/events/EventFiringWebDriver.java @@ -592,9 +592,9 @@ public void refresh() { } } - private class EventFiringOptions implements Options { + private static class EventFiringOptions implements Options { - private Options options; + private final Options options; private EventFiringOptions(Options options) { this.options = options; @@ -647,7 +647,7 @@ public Window window() { } } - private class EventFiringTimeouts implements Timeouts { + private static class EventFiringTimeouts implements Timeouts { private final Timeouts timeouts; @@ -710,7 +710,7 @@ public Duration getPageLoadTimeout() { private class EventFiringTargetLocator implements TargetLocator { - private TargetLocator targetLocator; + private final TargetLocator targetLocator; private EventFiringTargetLocator(TargetLocator targetLocator) { this.targetLocator = targetLocator; @@ -769,7 +769,7 @@ public Alert alert() { } @Beta - private class EventFiringWindow implements Window { + private static class EventFiringWindow implements Window { private final Window window; EventFiringWindow(Window window) { diff --git a/java/src/org/openqa/selenium/support/pagefactory/ByAll.java b/java/src/org/openqa/selenium/support/pagefactory/ByAll.java index 933924a1f9b893..0a9e0988bc0fc9 100644 --- a/java/src/org/openqa/selenium/support/pagefactory/ByAll.java +++ b/java/src/org/openqa/selenium/support/pagefactory/ByAll.java @@ -40,7 +40,7 @@ public class ByAll extends By implements Serializable { private static final long serialVersionUID = 4573668832699497306L; - private By[] bys; + private final By[] bys; public ByAll(By... bys) { this.bys = bys; diff --git a/java/src/org/openqa/selenium/support/pagefactory/ByChained.java b/java/src/org/openqa/selenium/support/pagefactory/ByChained.java index 34f7e1ee30ced1..5d631cc254c243 100644 --- a/java/src/org/openqa/selenium/support/pagefactory/ByChained.java +++ b/java/src/org/openqa/selenium/support/pagefactory/ByChained.java @@ -42,7 +42,7 @@ public class ByChained extends By implements Serializable { private static final long serialVersionUID = 1563769051170172451L; - private By[] bys; + private final By[] bys; public ByChained(By... bys) { this.bys = bys; diff --git a/java/src/org/openqa/selenium/support/ui/FluentWait.java b/java/src/org/openqa/selenium/support/ui/FluentWait.java index 76619788de1372..e76c5faa4c5e80 100644 --- a/java/src/org/openqa/selenium/support/ui/FluentWait.java +++ b/java/src/org/openqa/selenium/support/ui/FluentWait.java @@ -76,7 +76,7 @@ public class FluentWait implements Wait { private Duration interval = DEFAULT_WAIT_DURATION; private Supplier messageSupplier = () -> null; - private List> ignoredExceptions = new ArrayList<>(); + private final List> ignoredExceptions = new ArrayList<>(); /** * @param input The input value to pass to the evaluated conditions. diff --git a/java/test/org/openqa/selenium/grid/web/ReverseProxyHandlerTest.java b/java/test/org/openqa/selenium/grid/web/ReverseProxyHandlerTest.java index 757099ac290571..f44775e2b7b413 100644 --- a/java/test/org/openqa/selenium/grid/web/ReverseProxyHandlerTest.java +++ b/java/test/org/openqa/selenium/grid/web/ReverseProxyHandlerTest.java @@ -32,8 +32,8 @@ import org.openqa.selenium.remote.tracing.Tracer; class ReverseProxyHandlerTest { - private Tracer tracer = DefaultTestTracer.createTracer(); - private HttpClient.Factory factory = HttpClient.Factory.createDefault(); + private final Tracer tracer = DefaultTestTracer.createTracer(); + private final HttpClient.Factory factory = HttpClient.Factory.createDefault(); @Test void shouldForwardRequestsToEndPoint() diff --git a/java/test/org/openqa/selenium/json/JsonOutputTest.java b/java/test/org/openqa/selenium/json/JsonOutputTest.java index 154ec858db6b9a..f85897e35b9813 100644 --- a/java/test/org/openqa/selenium/json/JsonOutputTest.java +++ b/java/test/org/openqa/selenium/json/JsonOutputTest.java @@ -844,7 +844,7 @@ public List getList() { } class JsonAware { - private String convertedValue; + private final String convertedValue; public JsonAware(String convertedValue) { this.convertedValue = convertedValue; @@ -856,7 +856,7 @@ public String toJson() { } class MappableJsonAware { - private String convertedValue; + private final String convertedValue; public MappableJsonAware(String convertedValue) { this.convertedValue = convertedValue; @@ -872,8 +872,8 @@ public Map asMap() { } class Mappable1 { - private String key; - private Object value; + private final String key; + private final Object value; public Mappable1(String key, Object value) { this.key = key; @@ -886,8 +886,8 @@ public Map asMap() { } class Mappable2 { - private String key; - private Object value; + private final String key; + private final Object value; public Mappable2(String key, Object value) { this.key = key; diff --git a/java/test/org/openqa/selenium/json/JsonTest.java b/java/test/org/openqa/selenium/json/JsonTest.java index 25c50680dfd5c9..23e484e237f1d2 100644 --- a/java/test/org/openqa/selenium/json/JsonTest.java +++ b/java/test/org/openqa/selenium/json/JsonTest.java @@ -561,7 +561,7 @@ public void setBean(SimpleBean bean) { } public static class JsonAware { - private String convertedValue; + private final String convertedValue; public JsonAware(String convertedValue) { this.convertedValue = convertedValue; @@ -573,7 +573,7 @@ public static JsonAware fromJson(String json) { } public static class PrivatelyAware { - private String convertedValue; + private final String convertedValue; public PrivatelyAware(String convertedValue) { this.convertedValue = convertedValue; diff --git a/java/test/org/openqa/selenium/netty/server/SimpleHttpServer.java b/java/test/org/openqa/selenium/netty/server/SimpleHttpServer.java index cdc9222375b08c..2aafc3a8b6010b 100644 --- a/java/test/org/openqa/selenium/netty/server/SimpleHttpServer.java +++ b/java/test/org/openqa/selenium/netty/server/SimpleHttpServer.java @@ -79,7 +79,7 @@ public class SimpleHttpServer implements Closeable { private final Channel channel; - private Map, Function> endpoints; + private final Map, Function> endpoints; public SimpleHttpServer() throws InterruptedException, URISyntaxException { this(PortProber.findFreePort()); diff --git a/java/test/org/openqa/selenium/remote/ErrorCodecTest.java b/java/test/org/openqa/selenium/remote/ErrorCodecTest.java index ea9b3334d08352..67b79c3b7ec68b 100644 --- a/java/test/org/openqa/selenium/remote/ErrorCodecTest.java +++ b/java/test/org/openqa/selenium/remote/ErrorCodecTest.java @@ -54,7 +54,7 @@ @Tag("UnitTests") public class ErrorCodecTest { - private ErrorCodec errorCodec = ErrorCodec.createDefault(); + private final ErrorCodec errorCodec = ErrorCodec.createDefault(); @Test void encodeW3cSpecExceptions() { diff --git a/java/test/org/openqa/selenium/support/ui/SlowLoadableComponentTest.java b/java/test/org/openqa/selenium/support/ui/SlowLoadableComponentTest.java index d64b98f4ffb467..c14b676c35f625 100644 --- a/java/test/org/openqa/selenium/support/ui/SlowLoadableComponentTest.java +++ b/java/test/org/openqa/selenium/support/ui/SlowLoadableComponentTest.java @@ -78,7 +78,7 @@ protected void isLoaded() throws Error { private static class SlowLoading extends SlowLoadableComponent { - private int counts; + private final int counts; private long loopCount; public SlowLoading(Clock clock, int timeOutInSeconds, int counts) { diff --git a/java/test/org/openqa/selenium/testing/Safely.java b/java/test/org/openqa/selenium/testing/Safely.java index e155daf526e9c3..b679323d133aad 100644 --- a/java/test/org/openqa/selenium/testing/Safely.java +++ b/java/test/org/openqa/selenium/testing/Safely.java @@ -55,7 +55,7 @@ public static void safelyCall(TearDownFixture... fixtures) { try { CompletableFuture.allOf(futures.toArray(new CompletableFuture[] {})).get(2, TimeUnit.MINUTES); } catch (TimeoutException ex) { - LOG.log(Level.WARNING, "tear down timed out"); + LOG.log(Level.WARNING, "tear down timed out: {}", ex.toString()); } catch (Exception ex) { LOG.log(Level.WARNING, "tear down failed", ex); } diff --git a/java/test/org/openqa/selenium/testing/StaticResources.java b/java/test/org/openqa/selenium/testing/StaticResources.java index c8b7c8c8d533ee..03b46fbe4f4bf6 100644 --- a/java/test/org/openqa/selenium/testing/StaticResources.java +++ b/java/test/org/openqa/selenium/testing/StaticResources.java @@ -28,7 +28,7 @@ import org.openqa.selenium.build.InProject; class StaticResources { - private static Logger LOG = Logger.getLogger(StaticResources.class.getName()); + private static final Logger LOG = Logger.getLogger(StaticResources.class.getName()); static void ensureAvailable() { if (!isInDevMode()) { diff --git a/java/test/org/openqa/selenium/testing/TestIgnorance.java b/java/test/org/openqa/selenium/testing/TestIgnorance.java index 764c27fc23be1b..8bc09fd987ef72 100644 --- a/java/test/org/openqa/selenium/testing/TestIgnorance.java +++ b/java/test/org/openqa/selenium/testing/TestIgnorance.java @@ -34,11 +34,11 @@ /** Class that decides whether a test class or method should be ignored. */ class TestIgnorance { - private IgnoreComparator ignoreComparator = new IgnoreComparator(); - private Set methods = new HashSet<>(); - private Set only = new HashSet<>(); - private Set ignoreMethods = new HashSet<>(); - private Set ignoreClasses = new HashSet<>(); + private final IgnoreComparator ignoreComparator = new IgnoreComparator(); + private final Set methods = new HashSet<>(); + private final Set only = new HashSet<>(); + private final Set ignoreMethods = new HashSet<>(); + private final Set ignoreClasses = new HashSet<>(); public TestIgnorance(Browser driver) { ignoreComparator.addDriver( diff --git a/java/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java b/java/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java index b41083cb33b069..45e63e07d40c7a 100644 --- a/java/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java +++ b/java/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java @@ -28,9 +28,9 @@ class RemoteSupplier implements Supplier { - private static OutOfProcessSeleniumServer server = new OutOfProcessSeleniumServer(); + private static final OutOfProcessSeleniumServer server = new OutOfProcessSeleniumServer(); private static volatile boolean started; - private Capabilities desiredCapabilities; + private final Capabilities desiredCapabilities; public RemoteSupplier(Capabilities desiredCapabilities) { this.desiredCapabilities = desiredCapabilities; diff --git a/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java b/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java index ecf709c20559d7..8a7731a3184c10 100644 --- a/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java +++ b/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java @@ -22,7 +22,7 @@ import org.openqa.selenium.WebDriver; class TestInternetExplorerSupplier implements Supplier { - private Capabilities caps; + private final Capabilities caps; public TestInternetExplorerSupplier(Capabilities caps) { this.caps = caps;