Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class ServerLogPanel extends javax.swing.JPanel {

private static final String ID_COLUMN_HEADER = "Id";
private static final String CHANNEL_COLUMN_HEADER = "Channel";
private static final String LOG_INFO_COLUMN_HEADER = "Log Information";
private JPopupMenu rightclickPopup;
private static final int PAUSED = 0;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
if (evt.getClickCount() >= 2) {
// synchronizing this to prevent ArrayIndexOutOfBoundsException since the server log table is constantly being redrawn.
synchronized (this) {
new ViewServerLogContentDialog(parent, String.valueOf(logTable.getModel().getValueAt(logTable.convertRowIndexToModel(logTable.getSelectedRow()), 1)));
new ViewServerLogContentDialog(parent, String.valueOf(logTable.getModel().getValueAt(logTable.convertRowIndexToModel(logTable.getSelectedRow()), 2)));
}
}
}
Expand Down Expand Up @@ -185,24 +186,26 @@ public synchronized void updateTable(LinkedList<ServerLogItem> serverLogs) {

for (ServerLogItem item : serverLogs) {
if (serverId == null || serverId.equals(item.getServerId())) {
dataList.add(new Object[] { item.getId(), item });
dataList.add(new Object[] { item.getId(), item.getChannelName(), item });
}
}

tableData = dataList.toArray(new Object[dataList.size()][]);
} else {
tableData = new Object[0][2];
tableData = new Object[0][3];
}

if (logTable != null) {
RefreshTableModel model = (RefreshTableModel) logTable.getModel();
model.refreshDataVector(tableData);
} else {
logTable = new MirthTable();
logTable.setModel(new RefreshTableModel(tableData, new String[] { ID_COLUMN_HEADER,
LOG_INFO_COLUMN_HEADER }) {

boolean[] canEdit = new boolean[] { false, false };
logTable.setModel(new RefreshTableModel(tableData, new String[] {
ID_COLUMN_HEADER,
CHANNEL_COLUMN_HEADER,
LOG_INFO_COLUMN_HEADER
}) {
boolean[] canEdit = new boolean[] { false, false, false };

public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Comment thread
NicoPiel marked this conversation as resolved.
Resolved
) {
synchronized (dispatchThreads) {
if (!shuttingDown) {
dispatchThreads.add(currentThread);
Expand Down Expand Up @@ -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 thread
NicoPiel marked this conversation as resolved.
Resolved
) {
do {
processSourceQueue(Constants.SOURCE_QUEUE_POLL_TIMEOUT_MILLIS);
} while (isActive() && !stopSourceQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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

Copilot AI Dec 9, 2025

Copy link

Choose a reason for hiding this comment

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

When channelId or channelName are null (which can happen in tests or if the DestinationChainProvider wasn't properly initialized), passing null values to CloseableThreadContext.put() may cause issues. Consider adding null checks or using StringUtils.defaultString() to provide empty strings instead of null values.

Example:

try (CloseableThreadContext.Instance ctc = CloseableThreadContext
        .put("channelId", StringUtils.defaultString(channelId))
        .put("channelName", StringUtils.defaultString(channelName))
) {
Suggested change
.put("channelId", channelId)
.put("channelName", channelName)
.put("channelId", StringUtils.defaultString(channelId))
.put("channelName", StringUtils.defaultString(channelName))

Copilot uses AI. Check for mistakes.
) {
try {
Thread.currentThread().setName(name + " < " + originalThreadName);
return doCall();
} finally {
Thread.currentThread().setName(originalThreadName);
}
}
}

Expand Down Expand Up @@ -210,4 +222,4 @@ private List<ConnectorMessage> doCall() throws InterruptedException {

return messages;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class DestinationChainProvider {
private Integer chainId;
private String channelId;
private String channelName;
private List<Integer> metaDataIds = new ArrayList<Integer>();
private Map<Integer, DestinationConnector> destinationConnectors = new LinkedHashMap<Integer, DestinationConnector>();
private DonkeyDaoFactory daoFactory;
Expand All @@ -40,6 +41,14 @@ public void setChannelId(String channelId) {
this.channelId = channelId;
}

public String getChannelName() {
return channelName;
}

public void setChannelName(String channelName) {
this.channelName = channelName;
}

public void addDestination(int metaDataId, DestinationConnector connector) {
if (!metaDataIds.contains(metaDataId)) {
metaDataIds.add(metaDataId);
Expand Down Expand Up @@ -76,4 +85,4 @@ protected void setStorageSettings(StorageSettings storageSettings) {
public DestinationChain getChain() {
return new DestinationChain(this);
}
}
}
Loading