Skip to content

CommonDelegatingErrorHandler does not check delegates compatibility correctly #3050

@antonin-arquey

Description

@antonin-arquey

In what version(s) of Spring for Apache Kafka are you seeing this issue?

3.1.0

Describe the bug

When adding a new delegate to a CommonDelegatingErrorHandler, the check for compatibility with ackAfterHandle and seeksAfterHandling is not performed.

The following method does not check the delegatesToCheck but uses the current this.delegates.values() which does not yet contains the new delegates:

@SuppressWarnings("deprecation")
private void checkDelegatesAndUpdateClassifier(Map<Class<? extends Throwable>,
			CommonErrorHandler> delegatesToCheck) {

        boolean ackAfterHandle = this.defaultErrorHandler.isAckAfterHandle();
        boolean seeksAfterHandling = this.defaultErrorHandler.seeksAfterHandling();
        this.delegates.values().forEach(handler -> {
	        Assert.isTrue(ackAfterHandle == handler.isAckAfterHandle(),
			        "All delegates must return the same value when calling 'isAckAfterHandle()'");
	        Assert.isTrue(seeksAfterHandling == handler.seeksAfterHandling(),
			        "All delegates must return the same value when calling 'seeksAfterHandling()'");
        });
        updateClassifier(delegatesToCheck);
}

To Reproduce

Create a CommonDelegatingErrorHandler and add an incompatible CommonErrorHandler, no exception will be thrown.

Expected behavior

The new delegates compatibility should be validated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions