This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
     new fdc39c4  Fixing the warnings mentioned by LGTM. (#17)
fdc39c4 is described below

commit fdc39c402f0428799c8ff7f0e4c55de60db0ec39
Author: Nabarun Nag <[email protected]>
AuthorDate: Thu Dec 6 10:25:36 2018 -0800

    Fixing the warnings mentioned by LGTM. (#17)
---
 .../geode/perftest/jvms/classpath/JarUtil.java     |  4 +--
 .../apache/geode/perftest/jvms/rmi/ChildJVM.java   | 39 +++++++++++-----------
 .../analysis/YardstickPercentileSensorParser.java  | 22 ++++++------
 .../analysis/YardstickThroughputSensorParser.java  | 18 +++++-----
 4 files changed, 44 insertions(+), 39 deletions(-)

diff --git 
a/harness/src/main/java/org/apache/geode/perftest/jvms/classpath/JarUtil.java 
b/harness/src/main/java/org/apache/geode/perftest/jvms/classpath/JarUtil.java
index a8e6adc..eac6ccb 100644
--- 
a/harness/src/main/java/org/apache/geode/perftest/jvms/classpath/JarUtil.java
+++ 
b/harness/src/main/java/org/apache/geode/perftest/jvms/classpath/JarUtil.java
@@ -42,8 +42,8 @@ public class JarUtil {
    */
   static void jar(File file, File outputFile) throws IOException {
     Manifest manifest = new Manifest();
-    try (JarOutputStream outputStream =
-        new JarOutputStream(new FileOutputStream(outputFile), manifest)) {
+    try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
+        JarOutputStream outputStream = new JarOutputStream(fileOutputStream, 
manifest)) {
       Path start = file.toPath();
 
       Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
diff --git 
a/harness/src/main/java/org/apache/geode/perftest/jvms/rmi/ChildJVM.java 
b/harness/src/main/java/org/apache/geode/perftest/jvms/rmi/ChildJVM.java
index 3a25b15..5603cb0 100644
--- a/harness/src/main/java/org/apache/geode/perftest/jvms/rmi/ChildJVM.java
+++ b/harness/src/main/java/org/apache/geode/perftest/jvms/rmi/ChildJVM.java
@@ -65,32 +65,33 @@ public class ChildJVM {
       // Clean up the output directory before the test runs
       FileUtils.deleteQuietly(outputDir);
       outputDir.mkdirs();
-      PrintStream out = new PrintStream(new File(outputDir, "system.log"));
-      system.setOut(out);
-      system.setErr(out);
+      try (PrintStream out = new PrintStream(new File(outputDir, 
"system.log"))) {
+        system.setOut(out);
+        system.setErr(out);
 
-      ControllerRemote controller = (ControllerRemote) rmi
-          .lookup("//" + RMI_HOST + ":" + RMI_PORT + "/" + 
RemoteJVMFactory.CONTROLLER);
+        ControllerRemote controller = (ControllerRemote) rmi
+            .lookup("//" + RMI_HOST + ":" + RMI_PORT + "/" + 
RemoteJVMFactory.CONTROLLER);
 
-      SharedContext sharedContext = controller.getsharedContext();
-      DefaultTestContext context = new DefaultTestContext(sharedContext, 
outputDir, id);
+        SharedContext sharedContext = controller.getsharedContext();
+        DefaultTestContext context = new DefaultTestContext(sharedContext, 
outputDir, id);
 
-      Worker worker = new Worker(context);
+        Worker worker = new Worker(context);
 
-      controller.addWorker(id, worker);
+        controller.addWorker(id, worker);
 
-      // Wait until the controller shuts down
-      // If the controller shuts down, this will throw an exception
-      try {
-        while (controller.ping()) {
-          Thread.sleep(pingTime);
+        // Wait until the controller shuts down
+        // If the controller shuts down, this will throw an exception
+        try {
+          while (controller.ping()) {
+            Thread.sleep(pingTime);
+          }
+        } catch (RemoteException e) {
+          // If we get a RemoteException, the controller has shut down
+          // exit gracefully
         }
-      } catch (RemoteException e) {
-        // If we get a RemoteException, the controller has shut down
-        // exit gracefully
-      }
 
-      system.exit(0);
+        system.exit(0);
+      }
     } catch (Throwable t) {
       t.printStackTrace();
       // Force a system exit. Because we created an RMI object, an exception 
from the main
diff --git 
a/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickPercentileSensorParser.java
 
b/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickPercentileSensorParser.java
index d99a538..7db3fec 100644
--- 
a/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickPercentileSensorParser.java
+++ 
b/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickPercentileSensorParser.java
@@ -57,16 +57,18 @@ public class YardstickPercentileSensorParser implements 
ProbeResultParser {
 
   public void parseResults(File resultDir) throws IOException {
     File sensorData = new File(resultDir, sensorOutputFile);
-    BufferedReader dataStream = new BufferedReader(new FileReader(sensorData));
-    String nextLine;
-
-    while ((nextLine = dataStream.readLine()) != null) {
-      if (nextLine.startsWith("--") ||
-          nextLine.startsWith("@@") ||
-          nextLine.startsWith("**")) {
-        continue;
+    try (FileReader fileReader = new FileReader(sensorData);
+        BufferedReader dataStream = new BufferedReader(fileReader)) {
+      String nextLine;
+
+      while ((nextLine = dataStream.readLine()) != null) {
+        if (nextLine.startsWith("--") ||
+            nextLine.startsWith("@@") ||
+            nextLine.startsWith("**")) {
+          continue;
+        }
+        buckets.add(new SensorBucket(nextLine));
       }
-      buckets.add(new SensorBucket(nextLine));
     }
   }
 
@@ -76,7 +78,7 @@ public class YardstickPercentileSensorParser implements 
ProbeResultParser {
   }
 
   private void normalizeBuckets() {
-    float totalPercentage = 0;
+    double totalPercentage = 0D;
     for (SensorBucket bucket : buckets) {
       totalPercentage += bucket.bucketPercentage;
     }
diff --git 
a/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickThroughputSensorParser.java
 
b/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickThroughputSensorParser.java
index 081b263..ff084b8 100644
--- 
a/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickThroughputSensorParser.java
+++ 
b/harness/src/main/java/org/apache/geode/perftest/yardstick/analysis/YardstickThroughputSensorParser.java
@@ -37,16 +37,18 @@ public class YardstickThroughputSensorParser implements 
ProbeResultParser {
 
   public void parseResults(File resultDir) throws IOException {
     File sensorData = new File(resultDir, sensorOutputFile);
-    BufferedReader dataStream = new BufferedReader(new FileReader(sensorData));
-    String nextLine;
+    try (FileReader fileReader = new FileReader(sensorData);
+        BufferedReader dataStream = new BufferedReader(new 
FileReader(sensorData))) {
+      String nextLine;
 
-    while ((nextLine = dataStream.readLine()) != null) {
-      if (nextLine.startsWith("--") ||
-          nextLine.startsWith("@@") ||
-          nextLine.startsWith("**")) {
-        continue;
+      while ((nextLine = dataStream.readLine()) != null) {
+        if (nextLine.startsWith("--") ||
+            nextLine.startsWith("@@") ||
+            nextLine.startsWith("**")) {
+          continue;
+        }
+        datapoints.add(new SensorDatapoint(nextLine));
       }
-      datapoints.add(new SensorDatapoint(nextLine));
     }
   }
 

Reply via email to