Skip to content

Commit

Permalink
[#1904] Small refactoring
Browse files Browse the repository at this point in the history
With this change we avoid the creation of a couple of CompletionStage objects
  • Loading branch information
dreab8 authored and DavideD committed Jan 23, 2025
1 parent 8f00411 commit 89f7cf2
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,21 @@ private CompletionStage<Object> generateId(
EntityPersister persister) {
return generator
.generate( (ReactiveConnectionSupplier) source, entity )
.thenApply( id -> castToIdentifierType( id, persister ) )
.thenCompose( generatedId -> {
if ( generatedId == null ) {
return failedFuture( new IdentifierGenerationException( "null id generated for: " + entity.getClass() ) );
}
if ( LOG.isDebugEnabled() ) {
LOG.debugf(
"Generated identifier: %s, using strategy: %s",
persister.getIdentifierType().toLoggableString( generatedId, source.getFactory() ),
generator.getClass().getName()
);
}
return completedFuture( generatedId );
} );
.thenApply( id -> {
final Object generatedId = castToIdentifierType( id, persister );
if ( generatedId == null ) {
throw new IdentifierGenerationException( "null id generated for: " + entity.getClass() );
}
if ( LOG.isDebugEnabled() ) {
LOG.debugf(
"Generated identifier: %s, using strategy: %s",
persister.getIdentifierType().toLoggableString( generatedId, source.getFactory() ),
generator.getClass().getName()
);
}
return generatedId;
}
);
}

/**
Expand Down

0 comments on commit 89f7cf2

Please sign in to comment.