-
Notifications
You must be signed in to change notification settings - Fork 41
Include Channel Name in server log #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
28d08a1
34dbab0
1260098
b42783f
bcee58d
2b555d7
2d118e4
88c452b
790a60e
80e1b2e
74672e6
c28a705
53a85d9
278d2b3
b1623c9
6c5fbc6
9f833e3
a7b0296
9d0946b
d0b358f
b272f5d
6ec3d04
22b0669
f1f1f4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |||||||||
| import org.apache.commons.collections4.MapUtils; | ||||||||||
| import org.apache.commons.lang3.StringUtils; | ||||||||||
| import org.apache.commons.lang3.exception.ExceptionUtils; | ||||||||||
| import org.apache.logging.log4j.CloseableThreadContext; | ||||||||||
| import org.apache.logging.log4j.LogManager; | ||||||||||
| import org.apache.logging.log4j.Logger; | ||||||||||
|
|
||||||||||
|
|
@@ -535,6 +536,7 @@ public synchronized void deploy(DebugOptions debugOptions) throws DeployExceptio | |||||||||
| for (DestinationChainProvider chainProvider : destinationChainProviders) { | ||||||||||
| chainProvider.setDaoFactory(daoFactory); | ||||||||||
| chainProvider.setStorageSettings(storageSettings); | ||||||||||
| chainProvider.setChannelName(name); | ||||||||||
|
|
||||||||||
| for (Integer metaDataId : chainProvider.getMetaDataIds()) { | ||||||||||
| DestinationConnector destinationConnector = chainProvider.getDestinationConnectors().get(metaDataId); | ||||||||||
|
|
@@ -1257,7 +1259,10 @@ protected DispatchResult dispatchRawMessage(RawMessage rawMessage, boolean batch | |||||||||
| boolean lockAcquired = false; | ||||||||||
| Long persistedMessageId = null; | ||||||||||
|
|
||||||||||
| try { | ||||||||||
| try (CloseableThreadContext.Instance ctc = CloseableThreadContext | ||||||||||
| .put("channelId", channelId) | ||||||||||
| .put("channelName", name) | ||||||||||
| ) { | ||||||||||
| synchronized (dispatchThreads) { | ||||||||||
| if (!shuttingDown) { | ||||||||||
| dispatchThreads.add(currentThread); | ||||||||||
|
|
@@ -1933,7 +1938,10 @@ public void processUnfinishedMessages() throws Exception { | |||||||||
|
|
||||||||||
| @Override | ||||||||||
| public void run() { | ||||||||||
| try { | ||||||||||
| try (CloseableThreadContext.Instance ctc = CloseableThreadContext | ||||||||||
| .put("channelId", channelId) | ||||||||||
| .put("channelName", name) | ||||||||||
|
Comment on lines
+1942
to
+1943
|
||||||||||
| .put("channelId", channelId) | |
| .put("channelName", name) | |
| .put("channelId", StringUtils.defaultString(channelId)) | |
| .put("channelName", StringUtils.defaultString(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If null is unacceptable (refer to Log4j docs), then the call to put should be omitted. Empty string does not seem semantically better than null. "fear" of nulls is foolish - equivalent to adding try-catch all over the place. Either null is valid or it is not.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,8 +16,10 @@ | |||||||||
| import java.util.concurrent.Callable; | ||||||||||
|
|
||||||||||
| import org.apache.commons.lang3.StringUtils; | ||||||||||
| import org.apache.logging.log4j.CloseableThreadContext; | ||||||||||
| import org.apache.logging.log4j.LogManager; | ||||||||||
| import org.apache.logging.log4j.Logger; | ||||||||||
| import org.apache.logging.log4j.ThreadContext; | ||||||||||
|
|
||||||||||
| import com.mirth.connect.donkey.model.message.ConnectorMessage; | ||||||||||
| import com.mirth.connect.donkey.model.message.ContentType; | ||||||||||
|
|
@@ -33,11 +35,15 @@ public class DestinationChain implements Callable<List<ConnectorMessage>> { | |||||||||
| private List<Integer> enabledMetaDataIds = new ArrayList<Integer>(); | ||||||||||
| private Logger logger = LogManager.getLogger(getClass()); | ||||||||||
| private String name; | ||||||||||
| private String channelId; | ||||||||||
| private String channelName; | ||||||||||
|
|
||||||||||
| public DestinationChain(DestinationChainProvider chainProvider) { | ||||||||||
| this.chainProvider = chainProvider; | ||||||||||
| enabledMetaDataIds = new ArrayList<Integer>(chainProvider.getMetaDataIds()); | ||||||||||
| name = "Destination Chain Thread on " + chainProvider.getChannelId(); | ||||||||||
| channelId = chainProvider.getChannelId(); | ||||||||||
| channelName = chainProvider.getChannelName(); | ||||||||||
| name = "Destination Chain Thread on " + channelId; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public void setMessage(ConnectorMessage message) { | ||||||||||
|
|
@@ -59,11 +65,17 @@ public void setName(String name) { | |||||||||
| @Override | ||||||||||
| public List<ConnectorMessage> call() throws InterruptedException { | ||||||||||
| String originalThreadName = Thread.currentThread().getName(); | ||||||||||
| try { | ||||||||||
| Thread.currentThread().setName(name + " < " + originalThreadName); | ||||||||||
| return doCall(); | ||||||||||
| } finally { | ||||||||||
| Thread.currentThread().setName(originalThreadName); | ||||||||||
|
|
||||||||||
| try (CloseableThreadContext.Instance ctc = CloseableThreadContext | ||||||||||
| .put("channelId", channelId) | ||||||||||
| .put("channelName", channelName) | ||||||||||
|
Comment on lines
+70
to
+71
|
||||||||||
| .put("channelId", channelId) | |
| .put("channelName", channelName) | |
| .put("channelId", StringUtils.defaultString(channelId)) | |
| .put("channelName", StringUtils.defaultString(channelName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
channelIdornameare null (which can happen in tests or partially initialized channels), passing null values toCloseableThreadContext.put()may cause issues. Consider adding null checks or usingStringUtils.defaultString()to provide empty strings instead of null values.Example: