Skip to content

Commit 5ab281c

Browse files
committed
Use CloseableThreadContext
1 parent 0e7d54f commit 5ab281c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

donkey/src/main/java/com/mirth/connect/donkey/server/channel/DestinationConnector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.commons.collections4.MapUtils;
2323
import org.apache.commons.lang3.StringUtils;
2424
import org.apache.commons.lang3.exception.ExceptionUtils;
25+
import org.apache.logging.log4j.CloseableThreadContext;
2526
import org.apache.logging.log4j.LogManager;
2627
import org.apache.logging.log4j.Logger;
2728
import org.apache.logging.log4j.ThreadContext;
@@ -615,10 +616,8 @@ public void processPendingConnectorMessage(DonkeyDao dao, ConnectorMessage messa
615616
@Override
616617
public void run() {
617618
// Add channel info to ThreadContext
618-
ThreadContext.put("channelId", getChannelId());
619-
ThreadContext.put("channelName", channel.getName());
620-
621-
DonkeyDao dao = null;
619+
try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put("channelId", getChannelId()).put("channelName", channel.getName())) {
620+
DonkeyDao dao = null;
622621
boolean commitSuccess = false;
623622
Serializer serializer = channel.getSerializer();
624623
ConnectorMessage connectorMessage = null;
@@ -897,9 +896,7 @@ public void run() {
897896
}
898897
}
899898
} while ((getCurrentState() == DeployedState.STARTED || getCurrentState() == DeployedState.STARTING) && !stopQueue.get());
900-
901-
ThreadContext.remove("channelId");
902-
ThreadContext.remove("channelName");
899+
}
903900
}
904901

905902
private Response handleSend(ConnectorProperties connectorProperties, ConnectorMessage message) throws InterruptedException {

0 commit comments

Comments
 (0)