diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java b/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java
index e174b896cb9c8c6a0b8cdb076a9072e5b6bb329b..393977059ebe34b4e30d491ba776f9b62564388d 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/PortUtils.java
@@ -26,11 +26,11 @@ public final class PortUtils {
public static int allocateRandomPort() {
try {
- ServerSocket server = new ServerSocket(0);
- int port = server.getLocalPort();
+ final ServerSocket server = new ServerSocket(0);
+ final int port = server.getLocalPort();
server.close();
return port;
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Failed to acquire a random free port", e);
}
}
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
index 84cf476201461ca955bfb035bf6674bdba9ca62b..292797a47644836fd962abaa3b144af4f05a4b6c 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
@@ -224,7 +224,7 @@ public class StartMongoMojo extends AbstractMojo {
this.addProxySelector();
}
- MongodExecutable executable;
+ final MongodExecutable executable;
try {
final ICommandLinePostProcessor commandLinePostProcessor;
@@ -241,7 +241,7 @@ public class StartMongoMojo extends AbstractMojo {
commandLinePostProcessor = new ICommandLinePostProcessor.Noop();
}
- IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
+ final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.MongoD)
.processOutput(getOutputConfig())
.artifactStore(getArtifactStore())
@@ -253,36 +253,36 @@ public class StartMongoMojo extends AbstractMojo {
}
savePortToProjectProperties();
- IMongodConfig config = new MongodConfigBuilder()
+ final IMongodConfig config = new MongodConfigBuilder()
.version((getVersion() == null || getVersion().equals("") ? Version.Main.PRODUCTION : getVersion()))
.net(new Net(bindIp, port, Network.localhostIsIPv6()))
.replication(new Storage(getDataDirectory(), replSet, oplogSize))
.build();
executable = MongodStarter.getInstance(runtimeConfig).prepare(config);
- } catch (UnknownHostException e) {
+ } catch (final UnknownHostException e) {
throw new MojoExecutionException("Unable to determine if localhost is ipv6", e);
- } catch (DistributionException e) {
+ } catch (final DistributionException e) {
throw new MojoExecutionException("Failed to download MongoDB distribution: " + e.withDistribution(), e);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MojoExecutionException("Unable to Config MongoDB: ", e);
}
try {
- MongodProcess mongod = executable.start();
+ final MongodProcess mongod = executable.start();
if (wait) {
while (true) {
try {
TimeUnit.MINUTES.sleep(5);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
break;
}
}
}
getPluginContext().put(MONGOD_CONTEXT_PROPERTY_NAME, mongod);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MojoExecutionException("Unable to start the mongod", e);
}
}
@@ -298,7 +298,7 @@ public class StartMongoMojo extends AbstractMojo {
private ProcessOutput getOutputConfig() throws MojoFailureException {
- LoggingStyle loggingStyle = LoggingStyle.valueOf(logging.toUpperCase());
+ final LoggingStyle loggingStyle = LoggingStyle.valueOf(logging.toUpperCase());
switch (loggingStyle) {
case CONSOLE:
@@ -315,7 +315,7 @@ public class StartMongoMojo extends AbstractMojo {
}
private IArtifactStore getArtifactStore() {
- IDownloadConfig downloadConfig = new DownloadConfigBuilder().defaultsForCommand(Command.MongoD).downloadPath(downloadPath).build();
+ final IDownloadConfig downloadConfig = new DownloadConfigBuilder().defaultsForCommand(Command.MongoD).downloadPath(downloadPath).build();
return new ArtifactStoreBuilder().defaults(Command.MongoD).download(downloadConfig).build();
}
@@ -334,7 +334,7 @@ public class StartMongoMojo extends AbstractMojo {
final ProxySelector defaultProxySelector = ProxySelector.getDefault();
ProxySelector.setDefault(new ProxySelector() {
@Override
- public List<Proxy> select(URI uri) {
+ public List<Proxy> select(final URI uri) {
if (uri.getHost().equals("fastdl.mongodb.org")) {
return singletonList(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)));
} else {
@@ -343,7 +343,7 @@ public class StartMongoMojo extends AbstractMojo {
}
@Override
- public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
+ public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
}
});
}
@@ -357,7 +357,7 @@ public class StartMongoMojo extends AbstractMojo {
try {
return Version.valueOf(versionEnumName);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
getLog().warn("Unrecognised MongoDB version '" + this.version + "', this might be a new version that we don't yet know about. Attemping download anyway...");
return Versions.withFeatures(new IVersion() {
@Override
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java
index 4a40bedeff965ad046bce83454ecb3740b6997c6..427d2809ce80df35c6b0476a2364cbfa1267a483 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StopMongoMojo.java
@@ -41,7 +41,7 @@ public class StopMongoMojo extends AbstractMojo {
return;
}
- MongodProcess mongod = (MongodProcess) getPluginContext().get(StartMongoMojo
+ final MongodProcess mongod = (MongodProcess) getPluginContext().get(StartMongoMojo
.MONGOD_CONTEXT_PROPERTY_NAME);
if (mongod != null) {
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java
index da58d1a804e3f44e9e2abdc5bd5812954b1baad1..ca7cb7b1037ddf34662e85e1a4c14eadd1b186fe 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/FileOutputStreamProcessor.java
@@ -29,13 +29,13 @@ public class FileOutputStreamProcessor implements IStreamProcessor {
private String logFile;
private String encoding;
- public FileOutputStreamProcessor(String logFile, String encoding) {
+ public FileOutputStreamProcessor(final String logFile, final String encoding) {
setLogFile(logFile);
setEncoding(encoding);
}
@Override
- public synchronized void process(String block) {
+ public synchronized void process(final String block) {
try {
if (stream == null) {
@@ -45,7 +45,7 @@ public class FileOutputStreamProcessor implements IStreamProcessor {
stream.write(block);
stream.flush();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException(e);
}
}
@@ -55,14 +55,14 @@ public class FileOutputStreamProcessor implements IStreamProcessor {
process("\n");
}
- private void setLogFile(String logFile) {
+ private void setLogFile(final String logFile) {
if (logFile == null || logFile.trim().length() == 0) {
throw new IllegalArgumentException("no logFile given");
}
this.logFile = logFile;
}
- private void setEncoding(String encoding) {
+ private void setEncoding(final String encoding) {
if (encoding == null || encoding.trim().length() == 0) {
throw new IllegalArgumentException("no encoding given");
}
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java
index a84a2449f6215e5e2e73e0bce2eeccdc80d03771..78b3b37b657d2b72842fcab1354cc5ebe2a1b77b 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/Loggers.java
@@ -23,8 +23,8 @@ import de.flapdoodle.embed.process.io.NamedOutputStreamProcessor;
public class Loggers {
- public static ProcessOutput file(String logFile, String encoding) {
- FileOutputStreamProcessor file = new FileOutputStreamProcessor(logFile, encoding);
+ public static ProcessOutput file(final String logFile, final String encoding) {
+ final FileOutputStreamProcessor file = new FileOutputStreamProcessor(logFile, encoding);
return new ProcessOutput(
new NamedOutputStreamProcessor("[mongod output]", file),
@@ -37,7 +37,7 @@ public class Loggers {
}
public static ProcessOutput none() {
- NoopStreamProcessor noop = new NoopStreamProcessor();
+ final NoopStreamProcessor noop = new NoopStreamProcessor();
return new ProcessOutput(noop, noop, noop);
}
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java b/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java
index 7eb817d2a84824bb31e468e94b94f35b58c804ec..5f8641b269a84d8e3a7a670908aed3725d2944db 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/log/NoopStreamProcessor.java
@@ -21,7 +21,7 @@ import de.flapdoodle.embed.process.io.IStreamProcessor;
public class NoopStreamProcessor implements IStreamProcessor {
@Override
- public void process(String block) {
+ public void process(final String block) {
}
@Override
diff --git a/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java b/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java
index fd63f1ff21ac96fc8fd08bb52c1d0073fca3fc31..0f9e63f22b7581fd34cdda8d471359f233301dcd 100644
--- a/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java
+++ b/src/test/java/com/syncleus/maven/plugins/mongodb/PortUtilsTest.java
@@ -55,7 +55,7 @@ public class PortUtilsTest {
port = PortUtils.allocateRandomPort();
new ServerSocket(port);
// port has been bound successfully
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Port " + port + " cannot be bind!");
} finally {
allocationsCounter.countDown();