Browse Source

issue #1663, silly NPE when input parameter is omitted

denka 10 years ago
parent
commit
8d05702fb2

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

@@ -11,7 +11,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.Future;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.ThreadLocalRandom;
 
 
-import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.Produces;
@@ -67,7 +66,9 @@ public class DbResource {
   private int getQueries(String proto) {
   private int getQueries(String proto) {
     int result = 1;
     int result = 1;
     try {
     try {
-      result = Integer.parseInt(proto);
+      if (proto != null) {
+        result = Integer.parseInt(proto);
+      }
     } catch (NumberFormatException e) {
     } catch (NumberFormatException e) {
       e.printStackTrace();
       e.printStackTrace();
     }
     }