[jOOQ/jOOQ#8877] fetchSingle() failure does not trigger ExecuteListener#exception() event
This commit is contained in:
parent
06b3e0aecd
commit
45d22cfbed
@ -99,8 +99,8 @@ final class CursorImpl<R extends Record> extends AbstractCursor<R> implements Cu
|
||||
|
||||
private static final JooqLogger log = JooqLogger.getLogger(CursorImpl.class);
|
||||
|
||||
private final ExecuteContext ctx;
|
||||
private final ExecuteListener listener;
|
||||
final ExecuteContext ctx;
|
||||
final ExecuteListener listener;
|
||||
private final boolean[] intern;
|
||||
private final boolean keepResultSet;
|
||||
private final boolean keepStatement;
|
||||
|
||||
@ -2058,7 +2058,7 @@ final class Tools {
|
||||
else if (size == 1)
|
||||
return result.get(0);
|
||||
else
|
||||
throw new TooManyRowsException("Cursor returned more than one result");
|
||||
throw exception((CursorImpl<R>) cursor, new TooManyRowsException("Cursor returned more than one result"));
|
||||
}
|
||||
finally {
|
||||
cursor.close();
|
||||
@ -2106,17 +2106,25 @@ final class Tools {
|
||||
int size = result.size();
|
||||
|
||||
if (size == 0)
|
||||
throw new NoDataFoundException("Cursor returned no rows");
|
||||
throw exception((CursorImpl<R>) cursor, new NoDataFoundException("Cursor returned no rows"));
|
||||
else if (size == 1)
|
||||
return result.get(0);
|
||||
else
|
||||
throw new TooManyRowsException("Cursor returned more than one result");
|
||||
throw exception((CursorImpl<R>) cursor, new TooManyRowsException("Cursor returned more than one result"));
|
||||
}
|
||||
finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static final RuntimeException exception(CursorImpl<?> cursor, RuntimeException e) {
|
||||
|
||||
// [#8877] Make sure these exceptions pass through ExecuteListeners as well
|
||||
cursor.ctx.exception(e);
|
||||
cursor.listener.exception(cursor.ctx);
|
||||
return cursor.ctx.exception();
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit each query part from a collection, given a context.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user