Skip to content
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

[BUG] Hardcoded null in ChannelTableNode will ALWAYS throw an exception #5171

Closed
jonbartels opened this issue May 3, 2022 · 5 comments
Closed
Labels
bug Something isn't working Fix-Commited Issue fixed and will be available in milestone Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-8538 triaged
Milestone

Comments

@jonbartels
Copy link
Contributor

jonbartels commented May 3, 2022

Describe the bug
See -

public void setGroupStatus(ChannelGroupStatus groupStatus) {
this.groupStatus = groupStatus;
this.channelStatus = null;
ChannelGroup group = groupStatus.getGroup();
int i = 0;
for (ChannelColumnPlugin plugin : LoadedExtensions.getInstance().getChannelColumnPlugins().values()) {
if (plugin.isDisplayFirst()) {
row[i++] = plugin.getTableData(group);
}
}
updateStatusColumn();
i++;
row[i++] = null;
row[i++] = new ChannelTableNameEntry(group.getName());
row[i++] = group.getId();
row[i++] = null;
row[i++] = group.getDescription();
row[i++] = null;
row[i++] = null;
row[i++] = group.getLastModified();
for (ChannelColumnPlugin plugin : LoadedExtensions.getInstance().getChannelColumnPlugins().values()) {
if (!plugin.isDisplayFirst()) {
row[i++] = plugin.getTableData(channelStatus.getChannel());
}
}
}

Line 58 sets this.channelStatus = null; then on line 85 row[i++] = plugin.getTableData(channelStatus.getChannel()); will always throw an NPE.

The solution is to change line 85 to plugin.getTableData(groupStatus.getChannelGroup()); which will call the existing plugin method com.mirth.connect.plugins.ChannelColumnPlugin#getTableData(com.mirth.connect.model.ChannelGroup).

To Reproduce

  1. Implement a com.mirth.connect.plugins.ChannelColumnPlugin or grab the one from https://github.com/jonbartels/mirth-connect-dashboard-count
  2. Load the plugin
  3. Launch MC from the Launcher with console enabled
  4. View the Channels view
  5. You'll see the NPE in console.

Environment (please complete the following information):

Workaround(s)
Are there one or more workarounds for this issue currently? - No.

Additional context
Fixing this is required to make #5152 implementable. Once this bug is fixed then implmenting a ChannelColumnPlugin to show listening ports becomes trivial.

#1571 introduced the idea and it was rolled into #1243

@ChristopherSchultz
Copy link
Contributor

Are you good if you set your plugin to "display first"?

@jonbartels
Copy link
Contributor Author

I tried "display first"

This might be solvable but I suspect its got something hardcoded for the first column or index order. It may also be expecting the Image renderer too.

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
	at com.mirth.connect.client.ui.ChannelPanel$15.isHighlighted(ChannelPanel.java:3346)
	at org.jdesktop.swingx.decorator.AbstractHighlighter.highlight(AbstractHighlighter.java:170)
	at org.jdesktop.swingx.decorator.CompoundHighlighter.doHighlight(CompoundHighlighter.java:235)
	at org.jdesktop.swingx.decorator.AbstractHighlighter.highlight(AbstractHighlighter.java:172)
	at org.jdesktop.swingx.JXTable.prepareRenderer(JXTable.java:3555)
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to com.mirth.connect.client.ui.CellData
	at com.mirth.connect.client.ui.ImageCellRenderer.getTableCellRendererComponent(ImageCellRenderer.java:44)
	at javax.swing.JTable.prepareRenderer(JTable.java:5729)
	at org.jdesktop.swingx.JXTable.prepareRenderer(JXTable.java:3545)
	at org.jdesktop.swingx.JXTreeTable.prepareRenderer(JXTreeTable.java:1385)

@twest-mirthconnect
Copy link
Contributor

We are taking a look at the dashboard for 4.3 in March. I have bubbled this one up for the team to look into.

@pladesma pladesma added the Fix-Commited Issue fixed and will be available in milestone label Feb 2, 2023
@pladesma pladesma added this to the 4.3.0 milestone Feb 2, 2023
@pladesma
Copy link
Collaborator

pladesma commented Feb 8, 2023

The fix is pushed to the development branch

@pladesma pladesma closed this as completed Feb 8, 2023
@jonbartels
Copy link
Contributor Author

I did some testing with my plugin. I no longer encounter the error, however my plugin also does not add columns to the Channel list view. I suspect this is a bug in my plugin.

Are there any implementations of com.mirth.connect.plugins.ChannelColumnPlugin that I can review?

I am doing my best to provide testing and updates for this bug since NG devs took the time to fix it!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fix-Commited Issue fixed and will be available in milestone Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-8538 triaged
Projects
None yet
Development

No branches or pull requests

4 participants