Fix unnecessary exception thrown in Symbol widget#3806
Merged
shroffk merged 2 commits intoMay 21, 2026
Conversation
Even though the exception is caught and ignored, it still slows down the widget creation and can cause a race condition with macro expansion.
The updated if statement will ensure we don't have an out of bounds exception thrown.
|
kasemir
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



We recently came across a warning relating to a macro not being full resolved in the 'name' property.
We tracked this back and found it was coming from a Symbol widget, which had a macro in the 'name' property. We found that when we had more than 2 symbols defined for this widget, then we got this warning and indeed, the macro in the name does not get replaced. If we have 2 or fewer symbols then it works correctly and there is no warning.
In the case of >2 symbols, I found that the 'name' property is being evaluated before the screen macros have been expanded and hence the warning.
I dug a little deeper and found that during construction, the symbol widget allows 'index out of bound' exceptions to be thrown and just catches these to ignore them. Indeed, there is a comment in the code to say that this
will happen if there are more than 2 symbols:
phoebus/app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/SymbolWidget.java
Line 106 in 59ebd24
From what I read, throwing exceptions in Java can be relatively slow as the JVM has to construct the stack trace. It may also be that this suspends the execution of this thread and allows another one to run. Either way, I found that allowing it to throw the exception delays the expansion of the macros and hence allows for the 'name' property to be evaluated before the expansion.
I was able to fix this by simply updating the
ifstatement to ensure that we do not trigger an 'index out of bounds' exception. There is then no need for the try-catch statement.Attached is a simple BOB file example to reproduce the issue: symbolWidgetMacroExample.bob.txt
Start with 3 symbols defined and you will see the warning. Then reduce to 2 and there is no warning. Applying my fix will remove the issue altogether.
I will note that this fixes the issue but hides what might be a race condition happening somewhere that allows the evaluation of widget properties before the DisplayModel runs the macro expansion.
Checklist
Testing:
Documentation: