Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't recognize original exception when abortTransaction() failed #2981

Closed
chanhyeong opened this issue Jan 11, 2024 · 1 comment · Fixed by #2982
Closed

Can't recognize original exception when abortTransaction() failed #2981

chanhyeong opened this issue Jan 11, 2024 · 1 comment · Fixed by #2982

Comments

@chanhyeong
Copy link
Contributor

chanhyeong commented Jan 11, 2024

If an exception occur in the below code block producer.abortTransaction(), the original Exception e is discarded.

catch (Exception e) {
producer.abortTransaction();
throw e;
}

I recently encountered this case, and I think the original was raised while processing upper line T result = callback.doInOperations(this);.

Is there any way to know about the original exception?
If not, it would be nice add logging of the exception or rethrowing composite exception.

@chanhyeong chanhyeong changed the title Can' recognize original exception when abortTransaction() failed Can't recognize original exception when abortTransaction() failed Jan 11, 2024
@artembilan
Copy link
Member

Confirming as a bug.
That supposed to use addSuppressed() for the original exception where we catch the one from abortTransaction().

@artembilan artembilan added this to the 3.1.2 milestone Jan 11, 2024
@artembilan artembilan self-assigned this Jan 11, 2024
artembilan added a commit to artembilan/spring-kafka that referenced this issue Jan 11, 2024
Fixes: spring-projects#2981

When `producer.abortTransaction()` fails, the original exception is lost

* Catch an exception on `producer.abortTransaction()` and `ex.addSuppressed(abortException)`

**Cherry-pick to `3.0.x`**
artembilan added a commit to artembilan/spring-kafka that referenced this issue Jan 11, 2024
Fixes: spring-projects#2981

When `producer.abortTransaction()` fails, the original exception is lost

* Catch an exception on `producer.abortTransaction()` and `ex.addSuppressed(abortException)`

**Cherry-pick to `3.0.x`**
sobychacko pushed a commit that referenced this issue Jan 17, 2024
Fixes: #2981

When `producer.abortTransaction()` fails, the original exception is lost in `KafkaTemplate`.

* Catch an exception on `producer.abortTransaction()` and `ex.addSuppressed(abortException)`

**Cherry-pick to `3.0.x`**
sobychacko pushed a commit that referenced this issue Jan 17, 2024
Fixes: #2981

When `producer.abortTransaction()` fails, the original exception is lost in `KafkaTemplate`.

* Catch an exception on `producer.abortTransaction()` and `ex.addSuppressed(abortException)`

**Cherry-pick to `3.0.x`**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants