Repository: incubator-juneau
Updated Branches:
  refs/heads/master 36dbf821c -> f6b85eff2


FindBugs issues.

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/f6b85eff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/f6b85eff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/f6b85eff

Branch: refs/heads/master
Commit: f6b85eff286d425f1781de5de74d391cc0a89d05
Parents: 36dbf82
Author: jamesbognar <jamesbog...@gmail.com>
Authored: Mon Sep 19 10:15:24 2016 -0400
Committer: jamesbognar <jamesbog...@gmail.com>
Committed: Mon Sep 19 10:15:24 2016 -0400

----------------------------------------------------------------------
 .../juneau/microservice/Microservice.java       | 57 ++++++++++----------
 .../resources/DirectoryResource.java            | 19 ++++---
 .../microservice/resources/LogsResource.java    |  9 ++--
 3 files changed, 47 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f6b85eff/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
----------------------------------------------------------------------
diff --git 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
index ec77824..2998282 100755
--- 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
+++ 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
@@ -180,35 +180,6 @@ public abstract class Microservice {
                                onConfigChange(cf, changes);
                        }
                });
-
-               // 
--------------------------------------------------------------------------------
-               // Add exit listeners.
-               // 
--------------------------------------------------------------------------------
-               new Thread() {
-                       @Override /* Thread */
-                       public void run() {
-                               Console c = System.console();
-                               if (c == null)
-                                       System.out.println("No available 
console.");
-                               else {
-                                       while (true) {
-                                               String l = c.readLine("\nEnter 
'exit' to exit.\n");
-                                               if (l == null || 
l.equals("exit")) {
-                                                       
Microservice.this.stop();
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }.start();
-               Runtime.getRuntime().addShutdownHook(
-                       new Thread() {
-                               @Override /* Thread */
-                               public void run() {
-                                       Microservice.this.stop();
-                               }
-                       }
-               );
        }
 
        /**
@@ -434,6 +405,34 @@ public abstract class Microservice {
         * @throws Exception
         */
        protected Microservice start() throws Exception {
+               // 
--------------------------------------------------------------------------------
+               // Add exit listeners.
+               // 
--------------------------------------------------------------------------------
+               new Thread() {
+                       @Override /* Thread */
+                       public void run() {
+                               Console c = System.console();
+                               if (c == null)
+                                       System.out.println("No available 
console.");
+                               else {
+                                       while (true) {
+                                               String l = c.readLine("\nEnter 
'exit' to exit.\n");
+                                               if (l == null || 
l.equals("exit")) {
+                                                       
Microservice.this.stop();
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }.start();
+               Runtime.getRuntime().addShutdownHook(
+                       new Thread() {
+                               @Override /* Thread */
+                               public void run() {
+                                       Microservice.this.stop();
+                               }
+                       }
+               );
                onStart();
                return this;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f6b85eff/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
----------------------------------------------------------------------
diff --git 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
index 642a23b..657521e 100755
--- 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
+++ 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
@@ -129,9 +129,12 @@ public class DirectoryResource extends Resource {
 
                if (f.isDirectory()) {
                        List<FileResource> l = new LinkedList<FileResource>();
-                       for (File fc : f.listFiles()) {
-                               URL fUrl = new 
URL(req.getRequestURL().append("/").append(fc.getName()).toString());
-                               l.add(new FileResource(fc, fUrl));
+                       File[] files = f.listFiles();
+                       if (files != null) {
+                               for (File fc : files) {
+                                       URL fUrl = new 
URL(req.getRequestURL().append("/").append(fc.getName()).toString());
+                                       l.add(new FileResource(fc, fUrl));
+                               }
                        }
                        return l;
                }
@@ -346,9 +349,13 @@ public class DirectoryResource extends Resource {
        /** Utility method */
        private void deleteFile(File f) {
                try {
-                       if (f.isDirectory())
-                               for (File fc : f.listFiles())
-                                       deleteFile(fc);
+                       if (f.isDirectory()) {
+                               File[] files = f.listFiles();
+                               if (files != null) {
+                                       for (File fc : files)
+                                               deleteFile(fc);
+                               }
+                       }
                        f.delete();
                } catch (Exception e) {
                        logger.log(WARNING, "Cannot delete file '" + 
f.getAbsolutePath() + "'", e);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f6b85eff/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
----------------------------------------------------------------------
diff --git 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
index 7ecd154..b1bfeb1 100755
--- 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
+++ 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
@@ -85,9 +85,12 @@ public class LogsResource extends Resource {
 
                if (f.isDirectory()) {
                        Set<FileResource> l = new TreeSet<FileResource>(new 
FileResourceComparator());
-                       for (File fc : f.listFiles(filter)) {
-                               URL fUrl = new 
URL(req.getTrimmedRequestURL().append('/').append(fc.getName()).toString());
-                               l.add(new FileResource(fc, fUrl));
+                       File[] files = f.listFiles(filter);
+                       if (files != null) {
+                               for (File fc : files) {
+                                       URL fUrl = new 
URL(req.getTrimmedRequestURL().append('/').append(fc.getName()).toString());
+                                       l.add(new FileResource(fc, fUrl));
+                               }
                        }
                        properties.put(HTMLDOC_description, "Contents of " + 
f.getAbsolutePath());
                        return l;

Reply via email to