Browse Source

issue #1663, silly NPE when input parameter is omitted

denka 10 years ago
parent
commit
7d176d72fd

+ 2 - 2
frameworks/Java/grizzly-jersey/src/main/java/hello/DbResource.java

@@ -66,11 +66,11 @@ public class DbResource {
   private int getQueries(String proto) {
     int result = 1;
     try {
-      if (proto != null) {
+      if (proto != null && !proto.trim().isEmpty()) {
         result = Integer.parseInt(proto);
       }
     } catch (NumberFormatException e) {
-      e.printStackTrace();
+      throw new IllegalArgumentException(e);
     }
 
     return Math.min(500, Math.max(1, result));