Skip to content

Commit

Permalink
[#1668] Throw correct exception when onFlush is called
Browse files Browse the repository at this point in the history
onFlush is not reactive, reactiveOnFlush should be called instead.

For this situations, with have a custom exception in the Logger:
```
throw LOG.nonReactiveMethodCall( "reactiveOnFlush" );
```
  • Loading branch information
DavideD committed Jun 16, 2023
1 parent ea6014c commit 5dea6c7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import org.hibernate.event.spi.FlushEvent;
import org.hibernate.event.spi.FlushEventListener;
import org.hibernate.reactive.event.ReactiveFlushEventListener;
import org.hibernate.reactive.logging.impl.Log;
import org.hibernate.reactive.session.ReactiveSession;
import org.hibernate.stat.spi.StatisticsImplementor;

import static java.lang.invoke.MethodHandles.lookup;
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;

/**
Expand All @@ -24,6 +27,8 @@
public class DefaultReactiveFlushEventListener extends AbstractReactiveFlushingEventListener
implements ReactiveFlushEventListener, FlushEventListener {

private static final Log LOG = make( Log.class, lookup() );

@Override
public CompletionStage<Void> reactiveOnFlush(FlushEvent event) throws HibernateException {
final EventSource source = event.getSession();
Expand Down Expand Up @@ -59,6 +64,6 @@ else if ( ((ReactiveSession) source).getReactiveActionQueue().hasAnyQueuedAction

@Override
public void onFlush(FlushEvent event) throws HibernateException {
throw new UnsupportedOperationException();
throw LOG.nonReactiveMethodCall( "reactiveOnFlush" );
}
}

0 comments on commit 5dea6c7

Please sign in to comment.