Skip to content

Commit

Permalink
Improve backwards compatibility of new Message composition
Browse files Browse the repository at this point in the history
When getAckWithMetadata or getNackWithMetadata are not implemented composition still works with fallback to getAck/getNack methods
  • Loading branch information
ozangunalp committed Jan 8, 2024
1 parent ba6904b commit b43f780
Show file tree
Hide file tree
Showing 3 changed files with 389 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ private static BiFunction<Throwable, Metadata, CompletionStage<Void>> validateNa

private static Function<Metadata, CompletionStage<Void>> wrapAck(Message<?> message) {
var ackM = message.getAckWithMetadata();
return ackM != EMPTY_ACK ? ackM : validateAck(message.getAck());
return ackM != null ? ackM : validateAck(message.getAck());
}

private static BiFunction<Throwable, Metadata, CompletionStage<Void>> wrapNack(Message<?> message) {
var nackM = message.getNackWithMetadata();
return nackM != EMPTY_NACK ? nackM : validateNack(message.getNack());
return nackM != null ? nackM : validateNack(message.getNack());
}

private static <T> Message<T> newMessage(T payload, Metadata metadata) {
Expand Down Expand Up @@ -502,7 +502,7 @@ default Supplier<CompletionStage<Void>> getAck() {
*/
@Experimental("metadata propagation is a SmallRye-specific feature")
default Function<Metadata, CompletionStage<Void>> getAckWithMetadata() {
return EMPTY_ACK;
return null;
}

/**
Expand All @@ -517,7 +517,7 @@ default Function<Throwable, CompletionStage<Void>> getNack() {
*/
@Experimental("metadata propagation is a SmallRye-specific feature")
default BiFunction<Throwable, Metadata, CompletionStage<Void>> getNackWithMetadata() {
return EMPTY_NACK;
return null;
}

/**
Expand Down
Loading

0 comments on commit b43f780

Please sign in to comment.