Skip to content

Commit 323ab04

Browse files
committed
[#1904] Small refactoring
With this change we avoid the creation of a couple of CompletionStage objects
1 parent 5a83fb1 commit 323ab04

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/AbstractReactiveSaveEventListener.java

+15-14
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,21 @@ private CompletionStage<Object> generateId(
182182
EntityPersister persister) {
183183
return generator
184184
.generate( (ReactiveConnectionSupplier) source, entity )
185-
.thenApply( id -> castToIdentifierType( id, persister ) )
186-
.thenCompose( generatedId -> {
187-
if ( generatedId == null ) {
188-
return failedFuture( new IdentifierGenerationException( "null id generated for: " + entity.getClass() ) );
189-
}
190-
if ( LOG.isDebugEnabled() ) {
191-
LOG.debugf(
192-
"Generated identifier: %s, using strategy: %s",
193-
persister.getIdentifierType().toLoggableString( generatedId, source.getFactory() ),
194-
generator.getClass().getName()
195-
);
196-
}
197-
return completedFuture( generatedId );
198-
} );
185+
.thenApply( id -> {
186+
final Object generatedId = castToIdentifierType( id, persister );
187+
if ( generatedId == null ) {
188+
return failedFuture( new IdentifierGenerationException( "null id generated for: " + entity.getClass() ) );
189+
}
190+
if ( LOG.isDebugEnabled() ) {
191+
LOG.debugf(
192+
"Generated identifier: %s, using strategy: %s",
193+
persister.getIdentifierType().toLoggableString( generatedId, source.getFactory() ),
194+
generator.getClass().getName()
195+
);
196+
}
197+
return generatedId;
198+
}
199+
);
199200
}
200201

201202
/**

0 commit comments

Comments
 (0)