Skip to content

Conversation

nielsm5
Copy link
Member

@nielsm5 nielsm5 commented Jun 15, 2025

No description provided.

Comment on lines +121 to +129
// The ApplicationContext is practically always an Adapter except when the listener is created directly via the LarvaScenarioContext
private Message formatExceptionUsingErrorMessageFormatter(PipeLineSession session, Message inputMessage, Throwable t) {
if (applicationContext instanceof Adapter adapter) {
return adapter.formatErrorMessage(null, t, inputMessage, session, null);
}

log.warn("unformatted exception while processing input request [{}]", inputMessage, t);
return new Message(t.getMessage());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although over here we can safely assume the ApplicationContext is always an Adapter, I've copied this block from the JavaListener.

@@ -177,7 +178,7 @@ private Message processRequest(@Nonnull MessageWrapper<M> messageWrapper, @Nonnu
} catch (ListenerException e) {
// Message with error contains a String so does not need to be preserved.
// (Trying to preserve means dealing with extra IOException for which there is no reason here)
return handler.formatException(null, session, message, e);
return formatExceptionUsingErrorMessageFormatter(session, message, e);
Copy link
Member Author

@nielsm5 nielsm5 Jun 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is quite strange, this listener should always just throw the exception, it's up to the callee to format it using the correct ErrorMessageFormatter if any.

*/
Message processRequest(IListener<M> origin, RawMessageWrapper<M> rawMessage, Message message, PipeLineSession session) throws ListenerException;
Message processRequest(IPushingListener<M> origin, RawMessageWrapper<M> rawMessage, Message message, PipeLineSession session) throws ListenerException;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this ain't perfect, but for now we are limiting the code-execution flow in implementing to call the correct 'entrypoint' for the receiver.

@nielsm5 nielsm5 requested a review from tnleeuw June 17, 2025 17:32
@tnleeuw
Copy link
Contributor

tnleeuw commented Jun 20, 2025

Initially looks good except a stupid test that fails!

@nielsm5 nielsm5 marked this pull request as ready for review June 23, 2025 07:45
@nielsm5 nielsm5 requested a review from evandongen June 23, 2025 07:45
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
56.2% Coverage on New Code (required ≥ 65%)

See analysis details on SonarQube Cloud

@nielsm5 nielsm5 merged commit a8200b1 into master Jun 23, 2025
32 of 34 checks passed
@nielsm5 nielsm5 deleted the task/remove-format-exception-from-messagehandler branch June 23, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants