-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Expected Behavior
null check once
Current Behavior
check twice
Context
DefaultKafkaProducerFactory class
method abortTransaction()
There are two null checks on the producerFailed variable.
@Override
public void abortTransaction() throws ProducerFencedException {
LOGGER.debug(() -> toString() + " abortTransaction()");
if (this.producerFailed != null) {
LOGGER.debug(() -> {
String message = this.producerFailed == null ? "" : this.producerFailed.getMessage();
return "abortTransaction ignored - previous txFailed: " + message
+ ": " + this;
});
}
else {
try {
this.delegate.abortTransaction();
}
catch (RuntimeException e) {
LOGGER.error(e, () -> "Abort failed: " + this);
this.producerFailed = e;
throw e;
}
}
}
What do you think about changing it like this?
if (this.producerFailed != null) {
LOGGER.debug(() -> "abortTransaction ignored - previous txFailed: " + this.producerFailed.getMessage()
+ ": " + this);
}
thanks for reading.