I am encountering a java.lang.StringIndexOutOfBoundsException
when receiving data from a TCP server in my Processing application. The error occurs after sending a configuration command and receiving an acknowledgment from the server. Here’s the relevant part of the error message:
My GUI is interacting with an Arduino which is acting as a TCP server.
When I send some command it returns an acknowledgement. My command is being received there properly but I think when I get the ack, I am getting this error
java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 0
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
at java.base/java.lang.String.substring(String.java:2709)
at controlP5.ControlFont.calculateHeight(Unknown Source)
at controlP5.ControlFont.adjust(Unknown Source)
at controlP5.Label$MultilineLabel.draw(Unknown Source)
at controlP5.Label.draw(Unknown Source)
at controlP5.ControllerGroup.draw(Unknown Source)
at controlP5.ControllerGroup.drawControllers(Unknown Source)
at controlP5.ControllerGroup.draw(Unknown Source)
at controlP5.ControlWindow.draw(Unknown Source)
at controlP5.ControlWindow.draw(Unknown Source)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1309)
at processing.core.PApplet.handleMethods(PApplet.java:1456)
at processing.core.PApplet.handleDraw(PApplet.java:2106)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1386)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
StringIndexOutOfBoundsException: begin 0, end -1, length 0
It seems to be related to the ControlFont
class, which is part of the ControlP5 library used for GUI elements. However, I’m not directly interacting with this class in my code. The error occurs in the background while the GUI is being updated.
Has anyone encountered a similar issue with ControlP5 or have any insights into what might be causing this error?
Here is my code :