You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A query that returns an empty resultset (with querySingle and querySingleWithParams) will cause a NullPointerException.
Here's the code in SQLOperations.java:
defaultSQLOperationsquerySingle(Stringsql, Handler<AsyncResult<JsonArray>> handler) {
returnquery(sql, execute -> {
if (execute.failed()) {
handler.handle(Future.failedFuture(execute.cause()));
} else {
finalResultSetrs = execute.result();
if (rs == null) {
handler.handle(Future.succeededFuture());
} else {
// NOTE HERE: // The result set may not be null, but may be empty. The call to results.get(0) will cause an NPE.List<JsonArray> results = rs.getResults();
if (results == null) {
handler.handle(Future.succeededFuture());
} else {
handler.handle(Future.succeededFuture(results.get(0)));
}
}
}
});
}
This fix may be simple in that all that needs to be checked is adding: if (results == null || results.size() == 0) (and then return Future.succeededFuture()), or this may be a bit deeper of an issue in that ResultSet is not expected to return an empty list if there were no results in the database for the query? (I'd imagine this is okay, but checking here to make sure because of the way this was written.) Future.succeededFuture() is going to return a null result, is this desirable?
The text was updated successfully, but these errors were encountered:
Probably because I didn't post it to vertx-dev google groups. Posted it there now. The fix is pretty easy, but I wasn't sure which way they wanted to take it.
Version
3.5.0
Context
A query that returns an empty resultset (with
querySingle
andquerySingleWithParams
) will cause a NullPointerException.Here's the code in
SQLOperations.java
:This fix may be simple in that all that needs to be checked is adding:
if (results == null || results.size() == 0)
(and then returnFuture.succeededFuture()
), or this may be a bit deeper of an issue in that ResultSet is not expected to return an empty list if there were no results in the database for the query? (I'd imagine this is okay, but checking here to make sure because of the way this was written.)Future.succeededFuture()
is going to return anull
result, is this desirable?The text was updated successfully, but these errors were encountered: