-
Notifications
You must be signed in to change notification settings - Fork 115
Description
When the org.phoebus.applications.alarm/server setting contains multiple servers separated by commas (as expected by Kafka), creating a new alarm tree view fails with the following exception:
2024-07-10 17:36:12 WARNING [org.phoebus.applications.alarm] Cannot create alarm tree for alarm://host1.example.com:9092,host2.example.com:9092,host3.example.com:9092/Accelerator
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.phoebus.applications.alarm.ui.AlarmURI.parseAlarmURI(AlarmURI.java:63)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeInstance.create(AlarmTreeInstance.java:81)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeInstance.<init>(AlarmTreeInstance.java:56)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeApplication.create(AlarmTreeApplication.java:62)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeApplication.create(AlarmTreeApplication.java:54)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeApplication.create(AlarmTreeApplication.java:24)
at org.phoebus.framework.workbench.ApplicationService.createInstance(ApplicationService.java:152)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeMenuEntry.call(AlarmTreeMenuEntry.java:57)
at org.phoebus.applications.alarm.ui.tree.AlarmTreeMenuEntry.call(AlarmTreeMenuEntry.java:23)
at org.phoebus.ui.application.PhoebusApplication.lambda$createMenuItem$38(PhoebusApplication.java:848)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:459)
at com.sun.javafx.scene.control.GlobalMenuAdapter.lambda$bindMenuItemProperties$2(GlobalMenuAdapter.java:150)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:459)
at com.sun.javafx.tk.quantum.GlassSystemMenu$1.action(GlassSystemMenu.java:237)
The alarm area panel and alarm table do not suffer from this problem.
The underlying issue seems to be in the constructor of AlarmTreeInstance: When transforming input to resource, the code uses the URI class’s getHost(), getPort(), and getUserInfo() methods. However, these methods only work for a server-based URI. For a registry-based URI, they return null. As a URI that specifies more than one host / port pair cannot be parsed as a server-based URI, this leads to a URI without a host being generated.
The fix is easy: Instead of using getHost() and getUserInfo(), we have to use getAuthority() and use the URI constructor that takes an authority instead of a host, port, and user info.
I am going to to submit a PR that makes the necessary change (should be a one-liner).