pfalstad / circuitjs1

Electronic Circuit Simulator in the Browser
GNU General Public License v2.0
1.64k stars 279 forks source link

Uncaught Error: java.lang.StringIndexOutOfBoundsException #72

Closed monoglo closed 4 months ago

monoglo commented 4 months ago

In latest master branch,after build get below outputs

Uncaught Error: java.lang.StringIndexOutOfBoundsException: Index: 0, Size: 0
    at V5e_g$.BC_g$ [as createError_0_g$] (Throwable.java:116:1)
    at V5e_g$.MC_g$ [as initializeBackingError_0_g$] (Throwable.java:108:1)
    at V5e_g$.uC_g$ (Throwable.java:68:1)
    at V5e_g$.aD_g$ (Exception.java:29:1)
    at V5e_g$.iD_g$ (RuntimeException.java:29:1)
    at V5e_g$.VRe_g$ (IndexOutOfBoundsException.java:29:1)
    at new V5e_g$ (StringIndexOutOfBoundsException.java:30:1)
    at ysg_g$ (InternalPreconditions.java:487:1)
    at Lsg_g$ (InternalPreconditions.java:475:1)
    at d0e_g$ (String.java:359:1)
    at L1e_g$ (String.java:358:1)
    at g2d_g$.w4d_g$ [as processSetupList_0_g$] (CirSim.java:3788:1)
    at fDg_g$.hDg_g$ [as onResponseReceived_0_g$] (CirSim.java:3756:1)
    at umc_g$.xmc_g$ [as fireOnResponseReceived_0_g$] (Request.java:227:1)
    at jnc_g$.knc_g$ [as onReadyStateChange_0_g$] (RequestBuilder.java:412:1)
    at XMLHttpRequest.<anonymous> (XMLHttpRequest.java:329:1)
    at uL_g$ (Impl.java:299:1)
    at xL_g$ (Impl.java:358:1)
    at XMLHttpRequest.<anonymous> (Impl.java:78:1)

The problem occurs on https://github.com/pfalstad/circuitjs1/blob/c192b71e325624e56d7ed9db71456b48d2e48871/src/com/lushprojects/circuitjs1/client/CirSim.java#L3788 whenline is empty String. I'm not good at debugging in GWT, and I don't know why it would be empty, but after I turn it to

if (line.isEmpty() || line.charAt(0) == '#')

, it's gone.

pfalstad commented 4 months ago

fixed