accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [1/2] git commit: ACCUMULO-1362 Ensure resources are closed and warnings removed
Date Wed, 16 Apr 2014 22:01:38 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master 121cb5f1d -> ecfdf8d7c


ACCUMULO-1362 Ensure resources are closed and warnings removed


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/082d43d6
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/082d43d6
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/082d43d6

Branch: refs/heads/master
Commit: 082d43d690ef30dee79d3230ec5eba4ac795a361
Parents: 121cb5f
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Wed Apr 16 17:44:57 2014 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Wed Apr 16 18:01:25 2014 -0400

----------------------------------------------------------------------
 .../client/mapreduce/lib/impl/ConfiguratorBase.java     |  8 +-------
 .../apache/accumulo/minicluster/MiniAccumuloRunner.java |  5 +++--
 .../minicluster/impl/MiniAccumuloClusterImpl.java       | 12 ++++++------
 .../start/classloader/vfs/AccumuloVFSClassLoader.java   |  3 +--
 4 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
index c86623a..4610556 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
@@ -250,8 +250,7 @@ public class ConfiguratorBase {
     } catch (IOException e) {
       throw new IllegalArgumentException("Couldn't open password file called \"" + tokenFile
+ "\".");
     }
-    java.util.Scanner fileScanner = new java.util.Scanner(in);
-    try {
+    try (java.util.Scanner fileScanner = new java.util.Scanner(in)) {
       while (fileScanner.hasNextLine()) {
         Credentials creds = Credentials.deserialize(fileScanner.nextLine());
         if (principal.equals(creds.getPrincipal())) {
@@ -259,11 +258,6 @@ public class ConfiguratorBase {
         }
       }
       throw new IllegalArgumentException("Couldn't find token for user \"" + principal +
"\" in file \"" + tokenFile + "\"");
-    } finally {
-      if (fileScanner != null && fileScanner.ioException() == null)
-        fileScanner.close();
-      else if (fileScanner.ioException() != null)
-        throw new RuntimeException(fileScanner.ioException());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
index ab84d37..a7e2a3c 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
@@ -203,8 +203,9 @@ public class MiniAccumuloRunner {
     printInfo(accumulo, shutdownPort);
 
     // start a socket on the shutdown port and block- anything connected to this port will
activate the shutdown
-    ServerSocket shutdownServer = new ServerSocket(shutdownPort);
-    shutdownServer.accept();
+    try (ServerSocket shutdownServer = new ServerSocket(shutdownPort)) {
+      shutdownServer.accept();
+    }
 
     System.exit(0);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index d054718..6934a1b 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -131,7 +131,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
     }
   }
 
-  private static final long ZOOKEEPER_STARTUP_WAIT = 20*1000;
+  private static final long ZOOKEEPER_STARTUP_WAIT = 20 * 1000;
 
   private boolean initialized = false;
   private Process zooKeeperProcess = null;
@@ -210,9 +210,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
 
           if (classLoader instanceof URLClassLoader) {
 
-            URLClassLoader ucl = (URLClassLoader) classLoader;
-
-            for (URL u : ucl.getURLs()) {
+            for (URL u : ((URLClassLoader) classLoader).getURLs()) {
               append(classpathBuilder, u);
             }
 
@@ -251,7 +249,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
     for (Entry<String,String> sysProp : config.getSystemProperties().entrySet()) {
       argList.add(String.format("-D%s=%s", sysProp.getKey(), sysProp.getValue()));
     }
-    argList.addAll(Arrays.asList("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75",
"-Dapple.awt.UIElement=true", Main.class.getName(), className));
+    argList.addAll(Arrays.asList("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75",
"-Dapple.awt.UIElement=true", Main.class.getName(),
+        className));
     argList.addAll(Arrays.asList(args));
 
     ProcessBuilder builder = new ProcessBuilder(argList);
@@ -457,7 +456,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
             break;
         } catch (Exception e) {
           if (System.currentTimeMillis() - startTime >= ZOOKEEPER_STARTUP_WAIT) {
-            throw new RuntimeException("Zookeeper did not start within " + (ZOOKEEPER_STARTUP_WAIT/1000)
+ " seconds. Check the logs in " + config.getLogDir() + " for errors.  Last exception: " +
e);
+            throw new RuntimeException("Zookeeper did not start within " + (ZOOKEEPER_STARTUP_WAIT
/ 1000) + " seconds. Check the logs in "
+                + config.getLogDir() + " for errors.  Last exception: " + e);
           }
           UtilWaitThread.sleep(250);
         } finally {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
index fa20725..ccd27b1 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
@@ -322,10 +322,9 @@ public class AccumuloVFSClassLoader {
 
         if (classLoader instanceof URLClassLoader) {
           // If VFS class loader enabled, but no contexts defined.
-          URLClassLoader ucl = (URLClassLoader) classLoader;
           out.print("Level " + classLoaderDescription + " URL classpath items are:");
 
-          for (URL u : ucl.getURLs()) {
+          for (URL u : ((URLClassLoader) classLoader).getURLs()) {
             out.print("\t" + u.toExternalForm());
           }
 


Mime
View raw message