oscerd opened a new pull request, #26778:
URL: https://github.com/apache/camel/pull/26778
## What
`PulsarConsumer.PulsarConsumerLoop.run()` reported its own errors through
the **endpoint's** exception
handler:
```java
} else {
endpoint.getExceptionHandler().handleException(e);
}
} catch (Exception e) {
endpoint.getExceptionHandler().handleException(e);
}
```
`DefaultEndpoint.getExceptionHandler()` returns an `@UriParam` field that
stays `null` unless the route
sets `?exceptionHandler=#bean`. `bridgeErrorHandler=true` does not help
either — `configureConsumer`
installs both the bridging handler and a custom handler on the **consumer**,
never on the endpoint.
So any `PulsarClientException` from `consumer.receive()` whose cause is not
an interrupt — a broker
reconnect, a topic unload, a timeout — and any other `Exception`, threw a
`NullPointerException` from
inside the catch block. It propagated out of `run()` into the `Future`
returned by `executor.submit(...)`,
which is discarded, so nothing was logged at all: the thread was gone, the
loop was never restarted, and
that consumer stopped consuming for the life of the route.
Only reachable with `messageListener=false` (the default is `true`), which
is why it has gone unnoticed.
The `messageListener=true` path already does the right thing —
`PulsarMessageListener` calls
`pulsarConsumer.getExceptionHandler()`.
## Change
Use the consumer's exception handler, which `DefaultConsumer` always
initialises to a
`LoggingExceptionHandler`, and give it a message so the log says where the
failure came from.
## Test
`PulsarConsumerReceiveErrorTest` drives the loop with a mocked
`PulsarClient` (Mockito `RETURNS_SELF` for
the fluent `ConsumerBuilder`), makes the first `receive()` throw and
deliberately configures **no**
endpoint `exceptionHandler` — the exact shape that used to NPE. It asserts
the error reaches the
consumer's handler and that a second `receive()` happens, which proves the
loop did not die.
Verified by reverting the fix and re-running: the test then fails on *"the
receive error should be handed
to the consumer exception handler"*. Module unit suite green (24 tests).
_Claude Code on behalf of oscerd_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]