[#2373] Cursor.close() doesn't terminate the ExecuteListener life cycle
- Cursor should always be closed
This commit is contained in:
parent
f13fd3524a
commit
3648e2fc50
@ -471,6 +471,8 @@ public abstract class jOOQAbstractTest<
|
||||
m.toString().replace("public void ", "").replaceAll("( throws.*)?", "")));
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Unbalanced test: ", LifecycleWatcherListener.START_COUNT.size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@ -693,7 +693,10 @@ final class Utils {
|
||||
|
||||
/**
|
||||
* Get the only element from a cursor or <code>null</code>, or throw an
|
||||
* exception
|
||||
* exception.
|
||||
* <p>
|
||||
* [#2373] This method will always close the argument cursor, as it is
|
||||
* supposed to be completely consumed by this method.
|
||||
*
|
||||
* @param cursor The cursor
|
||||
* @return The only element from the cursor or <code>null</code>
|
||||
@ -701,13 +704,18 @@ final class Utils {
|
||||
* element
|
||||
*/
|
||||
static final <R extends Record> R fetchOne(Cursor<R> cursor) throws InvalidResultException {
|
||||
R record = cursor.fetchOne();
|
||||
|
||||
if (cursor.hasNext()) {
|
||||
throw new InvalidResultException("Cursor returned more than one result");
|
||||
try {
|
||||
R record = cursor.fetchOne();
|
||||
|
||||
if (cursor.hasNext()) {
|
||||
throw new InvalidResultException("Cursor returned more than one result");
|
||||
}
|
||||
|
||||
return record;
|
||||
}
|
||||
finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user