Skip to content

Commit

Permalink
Make sure at least on error message is contained
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed May 7, 2024
1 parent 76b9bea commit 0f4a0f7
Showing 1 changed file with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,9 @@ private void _invokeSPIsForIncoming (@Nonnull final HttpHeaderMap aHttpHeaders,
"Only one of User OR Signal Message may be present");

final boolean bIsUserMessage = aEbmsUserMessage != null;
final String sMessageID = bIsUserMessage ? aEbmsUserMessage.getMessageInfo ().getMessageId ()
: aEbmsSignalMessage.getMessageInfo ().getMessageId ();
final String sMessageID = bIsUserMessage ? aEbmsUserMessage.getMessageInfo ().getMessageId () : aEbmsSignalMessage
.getMessageInfo ()
.getMessageId ();

// Get all processors
final ICommonsList <IAS4ServletMessageProcessorSPI> aAllProcessors = m_aProcessorSupplier.get ();
Expand Down Expand Up @@ -723,23 +724,30 @@ private void _invokeSPIsForIncoming (@Nonnull final HttpHeaderMap aHttpHeaders,

if (aProcessingErrorMessages.isNotEmpty () || aResult.isFailure ())
{
if (aProcessingErrorMessages.isNotEmpty ())
if (aResult.isFailure () && aProcessingErrorMessages.isEmpty ())
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("AS4 message processor " +
aProcessor +
" had processing errors - breaking. Details: " +
aProcessingErrorMessages);
// For 2.7.6 - make sure that at least one processing error
// message is contained
aProcessingErrorMessages.add (EEbmsError.EBMS_OTHER.errorBuilder (m_aLocale)
.errorDetail ("An undefined generic error occurred")
.build ());
}

if (aResult.isSuccess ())
LOGGER.warn ("Processing errors are present but success was returned by a previous AS4 message processor " +
aProcessor +
" - considering the whole processing to be failed instead");
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("AS4 message processor " +
aProcessor +
" had processing errors - breaking. Details: " +
aProcessingErrorMessages);

aEbmsErrorMessagesTarget.addAll (aProcessingErrorMessages);
}
if (aResult.isSuccess ())
LOGGER.warn ("Processing errors are present but success was returned by a previous AS4 message processor " +
aProcessor +
" - considering the whole processing to be failed instead");

aEbmsErrorMessagesTarget.addAll (aProcessingErrorMessages);

// Stop processing
aSPIResult.setSuccess (false);
return;
}

Expand Down Expand Up @@ -883,8 +891,8 @@ private void _invokeSPIsForResponse (@Nonnull final IAS4MessageState aState,
byte [] aResponsePayload = null;
if (aResponseFactory != null)
{
final HttpEntity aRealHttpEntity = aHttpEntity != null ? aHttpEntity
: aResponseFactory.getHttpEntityForSending (aMimeType);
final HttpEntity aRealHttpEntity = aHttpEntity != null ? aHttpEntity : aResponseFactory.getHttpEntityForSending (
aMimeType);
if (aRealHttpEntity.isRepeatable ())
{
int nContentLength = (int) aRealHttpEntity.getContentLength ();
Expand Down Expand Up @@ -1632,9 +1640,8 @@ private IAS4ResponseFactory _handleSoapMessage (@Nonnull final HttpHeaderMap aHt
new ResponseHandlerXml ());
}
AS4HttpDebug.debug ( () -> "SEND-RESPONSE [async sent] received: " +
(aAsyncResponse == null ? "null"
: XMLWriter.getNodeAsString (aAsyncResponse,
AS4HttpDebug.getDebugXMLWriterSettings ())));
(aAsyncResponse == null ? "null" : XMLWriter.getNodeAsString (aAsyncResponse,
AS4HttpDebug.getDebugXMLWriterSettings ())));
};

final CompletableFuture <Void> aFuture = PhotonWorkerPool.getInstance ()
Expand Down Expand Up @@ -1851,8 +1858,8 @@ public void handleRequest (@Nonnull @WillClose final InputStream aServletRequest
if (aResponder != null)
{
// Response present -> send back
final IAS4OutgoingDumper aRealOutgoingDumper = m_aOutgoingDumper != null ? m_aOutgoingDumper
: AS4DumpManager.getOutgoingDumper ();
final IAS4OutgoingDumper aRealOutgoingDumper = m_aOutgoingDumper != null ? m_aOutgoingDumper : AS4DumpManager
.getOutgoingDumper ();
aResponder.applyToResponse (aHttpResponse, aRealOutgoingDumper);
}
else
Expand Down

0 comments on commit 0f4a0f7

Please sign in to comment.