From 0580656ff81f5b6ca7122c369f3c0194dcb6597b Mon Sep 17 00:00:00 2001 From: Cameron Gregor Date: Mon, 16 May 2016 14:34:39 +1000 Subject: [PATCH] Update JsonJdbcQueryContent.java When returning a jdbc query via json through the Jdbcqueryrest service, there is no check for null when writing the column values. This means if any column values are null it will throw a null pointer exception and get an Error 500. This can be handled by checking for null and outputting null , or alternatively you can just ignore it I guess? in any case it should try to avoid the null pointer exception. --- .../jdbc/services/content/JsonJdbcQueryContent.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.relational/src/com/ibm/xsp/extlib/relational/jdbc/services/content/JsonJdbcQueryContent.java b/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.relational/src/com/ibm/xsp/extlib/relational/jdbc/services/content/JsonJdbcQueryContent.java index 23f3f15..de3d0bc 100644 --- a/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.relational/src/com/ibm/xsp/extlib/relational/jdbc/services/content/JsonJdbcQueryContent.java +++ b/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.relational/src/com/ibm/xsp/extlib/relational/jdbc/services/content/JsonJdbcQueryContent.java @@ -1,5 +1,5 @@ /* - * © Copyright IBM Corp. 2011, 2015 + * © Copyright IBM Corp. 2011, 2015 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -235,7 +235,11 @@ else if (columnValue instanceof Boolean) { writeProperty(jwriter, columnDefs[i].getName(), (Boolean)columnValue); } - else { + else if (columnValue == null) { + jwriter.startProperty(columnDefs[i].getName()); + jwriter.outNull(); + jwriter.endProperty(); + } else { writeProperty(jwriter, columnDefs[i].getName(), columnValue.toString()); } @@ -361,4 +365,4 @@ private String findSqlQuery(JdbcParameters jdcbParameters) { } -} \ No newline at end of file +}