[java] Using the same name for a filed and a local variable is ambiguous
@@ -47,18 +47,16 @@ public BaseServerOptions(Config config) {
}
public int getPort() {
- if (port != -1) {
- return port;
- }
-
- int port = config.getInt(SERVER_SECTION, "port")
+ if (port == -1) {
+ int newPort = config.getInt(SERVER_SECTION, "port")
.orElseGet(PortProber::findFreePort);
- if (port < 0) {
- throw new ConfigException("Port cannot be less than 0: " + port);
+ if (newPort < 0) {
+ throw new ConfigException("Port cannot be less than 0: " + newPort);
}
- this.port = port;
+ port = newPort;
+ }
return port;
}
