kasemir / org.csstudio.display.builder

Update of org.csstudio.opibuilder.*
Eclipse Public License 1.0
2 stars 10 forks source link

Problems closing an OPI plenty of Embedded Displays using JavaScript scripts #522

Closed claudio-rosati closed 5 years ago

claudio-rosati commented 5 years ago

The problem appears when the window containing the running OPI is closed:


2019-03-27 12:40:25.765 WARNING [Thread 121] org.csstudio.vtype.pv.PV (notifyListenersOfValue) - ISrc-010:Vac-VVMC-01100:FlwR-STR PVListener error
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@179c0d4c rejected from java.util.concurrent.ThreadPoolExecutor@4e39c35a[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 978]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:681)
    at org.csstudio.display.builder.runtime.script.internal.ScriptSupport.submit(ScriptSupport.java:135)
    at org.csstudio.display.builder.runtime.script.internal.JavaScriptSupport.submit(JavaScriptSupport.java:72)
    at org.csstudio.display.builder.runtime.script.internal.JavaScript.submit(JavaScript.java:55)
    at org.csstudio.display.builder.runtime.script.internal.RuntimeScriptHandler.valueChanged(RuntimeScriptHandler.java:240)
    at org.csstudio.display.builder.runtime.pv.vtype_pv.VTypePV.valueChanged(VTypePV.java:92)
    at org.csstudio.vtype.pv.PV.notifyListenersOfValue(PV.java:185)
    at org.csstudio.vtype.pv.jca.JCA_PV.monitorChanged(JCA_PV.java:343)
    at gov.aps.jca.event.DirectEventDispatcher.dispatch(DirectEventDispatcher.java:84)
    at com.cosylab.epics.caj.CAJMonitor.monitorChanged(CAJMonitor.java:248)
    at gov.aps.jca.event.DirectEventDispatcher.dispatch(DirectEventDispatcher.java:155)
    at com.cosylab.epics.caj.impl.requests.EventAddRequest.response(EventAddRequest.java:213)
    at com.cosylab.epics.caj.impl.handlers.EventAddResponse.internalHandleResponse(EventAddResponse.java:61)
    at com.cosylab.epics.caj.impl.handlers.AbstractCAResponseHandler.handleResponse(AbstractCAResponseHandler.java:110)
    at com.cosylab.epics.caj.impl.CAResponseHandler.handleResponse(CAResponseHandler.java:139)
    at com.cosylab.epics.caj.impl.CATransport.processRead(CATransport.java:549)
    at com.cosylab.epics.caj.impl.CATransport.processRead(CATransport.java:431)
    at com.cosylab.epics.caj.impl.CATransport.handleEvent(CATransport.java:369)
    at com.cosylab.epics.caj.impl.reactor.lf.LeaderFollowersHandler.handleEvent(LeaderFollowersHandler.java:77)
    at com.cosylab.epics.caj.impl.reactor.Reactor.processInternal(Reactor.java:400)
    at com.cosylab.epics.caj.impl.reactor.Reactor.process(Reactor.java:284)
    at com.cosylab.epics.caj.impl.reactor.lf.LeaderFollowersHandler.run(LeaderFollowersHandler.java:91)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)```
kasemir commented 5 years ago

I've seen the message, but don't think it's a problem. Because of the asynchronous nature of PV updates, a PV update enters the pipeline of being handled, this one happens to trigger a script or rule, but by the time we actually submit the script for execution, the display has closed, so the script is no longer accepting executions. ScriptSupport.submit could catch the RejectedExecutionException and log a FINE level message to change what you see in the log. Wouldn't make any functional difference.

claudio-rosati commented 5 years ago

Is it possible before calling ScriptSupport.submit to check by if the widget is disposed, in which case the call is not done?

kasemir commented 5 years ago

Sure, but that doesn't help because the very nature of asynchronous threads is that when you check, the display may still be active, but when you then submit, it's been closed. I'll catch and suppress the exception so you no longer see it.

claudio-rosati commented 5 years ago

Thank you.