Workaround JDK-8080094
NPE enountered if http://<server>:19001/webui is requested
Change-Id: I08b29ec0a219bbcba67cd433f2daea4e67fe5ca9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1280
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
index f32e451..4e9bb25 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/APIServlet.java
@@ -177,7 +177,17 @@
InputStreamReader isr = new InputStreamReader(is);
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(isr);
- String line = br.readLine();
+ String line;
+ try {
+ line = br.readLine();
+ } catch (NullPointerException e) {
+ LOGGER.log(Level.WARNING, "NPE reading resource " + resourcePath
+ + ", assuming JDK-8080094; returning 404", e);
+ // workaround lame JDK bug where a broken InputStream is returned in case the resourcePath is a
+ // directory; see https://bugs.openjdk.java.net/browse/JDK-8080094
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
while (line != null) {
sb.append(line);