Skip to content

Commit

Permalink
Close SenderResult to avoid leaks (frankframework#5342)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkosternl authored Sep 7, 2023
1 parent d6522df commit eb8a0a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void run() {
session.put(PipeLineSession.CORRELATION_ID_KEY, correlationId);
SenderResult result = sender.sendMessage(new Message(request), session);
response = result.getResult().asString();
result.getResult().close();
} catch(SenderException e) {
if (convertExceptionToMessage) {
response = Util.throwableToXml(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.NoSuchElementException;
import java.util.Properties;

import lombok.extern.log4j.Log4j2;
import nl.nn.adapterframework.configuration.ConfigurationException;
import nl.nn.adapterframework.core.IConfigurable;
import nl.nn.adapterframework.core.IListener;
Expand All @@ -37,6 +38,7 @@
import nl.nn.adapterframework.core.ListenerException;
import nl.nn.adapterframework.core.PipeLineSession;
import nl.nn.adapterframework.core.SenderException;
import nl.nn.adapterframework.core.SenderResult;
import nl.nn.adapterframework.core.TimeoutException;
import nl.nn.adapterframework.http.WebServiceListener;
import nl.nn.adapterframework.parameters.Parameter;
Expand All @@ -54,6 +56,7 @@
import nl.nn.adapterframework.util.DomBuilderException;
import nl.nn.adapterframework.util.XmlUtils;

@Log4j2
public class QueueWrapper extends HashMap<String, Object> implements Queue {
private static final String CONVERT_MESSAGE_TO_EXCEPTION_KEY = "convertExceptionToMessage";
private static final String PIPELINESESSION_KEY = "session";
Expand Down Expand Up @@ -303,9 +306,14 @@ public int executeWrite(String stepDisplayName, String fileContent, String corre
fileSender.sendMessage(fileContent);
return TestTool.RESULT_OK;
}
if(get() instanceof DelaySender) {
DelaySender delaySender = (DelaySender)get();
delaySender.sendMessage(new Message(fileContent), null);
if (get() instanceof DelaySender) {
DelaySender delaySender = (DelaySender) get();
SenderResult senderResult = delaySender.sendMessage(new Message(fileContent), null);
try {
senderResult.getResult().close();
} catch (IOException e) {
log.warn("Could not close senderResult for queue {}", get(), e);
}
return TestTool.RESULT_OK;
}
if(get() instanceof XsltProviderListener) {
Expand Down

0 comments on commit eb8a0a1

Please sign in to comment.