Skip to content

Commit f6fba27

Browse files
committed
fix problem with exception handling reported in #1682
1 parent de384b2 commit f6fba27

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/spi/ReactiveAbstractSelectionQuery.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,18 @@ public CompletionStage<R> getReactiveSingleResultOrNull() {
184184
}
185185

186186
private R convertException(Throwable t) {
187-
if ( t instanceof CompletionException ) {
188-
t = t.getCause();
187+
if ( t instanceof CompletionException && t.getCause() != null ) {
188+
return convertException( t.getCause() );
189189
}
190-
if ( t instanceof HibernateException ) {
190+
else if ( t instanceof HibernateException ) {
191191
throw getSession().getExceptionConverter().convert( (HibernateException) t, getLockOptions() );
192192
}
193-
throw getSession().getExceptionConverter().convert( (RuntimeException) t, getLockOptions() );
193+
else if ( t instanceof RuntimeException ) {
194+
throw getSession().getExceptionConverter().convert( (RuntimeException) t, getLockOptions() );
195+
}
196+
else {
197+
throw new CompletionException( t );
198+
}
194199
}
195200

196201
private LockOptions getLockOptions() {

0 commit comments

Comments
 (0)