You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2018/12/06 18:25:38 UTC

[GitHub] nabarunnag closed pull request #17: Fixing the warnings mentioned by LGTM.

nabarunnag closed pull request #17: Fixing the warnings mentioned by LGTM.
URL: https://github.com/apache/geode-benchmarks/pull/17
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 @@
    */
   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 @@ void run() {
       // 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 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 void reset() {
   }
 
   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 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));
     }
   }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services