Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: Update TaskInWorkerThread.py #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cw2k
Copy link

@cw2k cw2k commented Oct 25, 2024

Now it works again as intended:

Counter: 0
Counter: 1
Counter: 2
The task was interrupted

Before the output was this:

Counter: 0
Counter: 1
Counter: 2
[E] Script execution error: com.pnfsoftware.jeb.client.script.ScriptExecutionException: java.lang.InterruptedException 
[E] 	at java.base/java.lang.Object.wait(Native Method) 
[E] 	at java.base/java.lang.Thread.join(Thread.java:1309) 
[E] 	at com.pnfsoftware.jeb.util.concurrent.ThreadEx.get(SourceFile:88) 
[E] 	at com.pnfsoftware.jeb.rcpclient.extensions.ui.UITask.run(UITask.java:139) 
[E] 	at com.pnfsoftware.jeb.rcpclient.extensions.ui.TaskMonitorDialog$1.run(TaskMonitorDialog.java:214) 
[E] 	at java.base/java.lang.Thread.run(Thread.java:842) [E] java.lang.InterruptedException: java.lang.InterruptedException 
[E] 
Counter: 3
Counter: 4
SimpleTask Done.

Maybe alter the rcpclient in JEB so we don't need that bugfix anymore.

UITask.java run()

 137:           try {
 138:                if (this.runnable != null) {
 139:                    t.get(this.checkTimeoutMs);
 140:                } else {
 142:                    this.result = t.get(this.checkTimeoutMs);
 143:               }
 144:
 145:           } catch (java.lang.InterruptedException e) {
 146:               throw e;

Like this:

 145:           } catch (java.lang.InterruptedException e) {
 146:               t.interrupt()
 147:               throw e;

So the 'lost' interrupted flag from the thread, gets restored there.

Or patch TaskMonitorDialog.java run() in ya private JEB-repo.
That has at lines 271 and 272 (line 107 as paste.bin) a very similar error handler.

... so we don't need that bug fix more.
The code relates to JEB-5.18.0.2024_10_07__1909

However, be aware to not interrupt the 'wrong' thread.
With that

class TaskInWorkerThread(IScript):

  def run(self, ctx):
    Thread.currentThread().interrupt()
    

I successfully 'lock' the entire JEB-Instance and needed to kill and start it again.

Now it works again as intended:
'''
Counter: 0
Counter: 1
Counter: 2
The task was interrupted
'''

Before the output was this:
'''
Counter: 0
Counter: 1
Counter: 2
[E] Script execution error: com.pnfsoftware.jeb.client.script.ScriptExecutionException: java.lang.InterruptedException
[E] 	at java.base/java.lang.Object.wait(Native Method)
[E] 	at java.base/java.lang.Thread.join(Thread.java:1309)
[E] 	at com.pnfsoftware.jeb.util.concurrent.ThreadEx.get(SourceFile:88)
[E] 	at com.pnfsoftware.jeb.rcpclient.extensions.ui.UITask.run(UITask.java:139)
[E] 	at com.pnfsoftware.jeb.rcpclient.extensions.ui.TaskMonitorDialog$1.run(TaskMonitorDialog.java:214)
[E] 	at java.base/java.lang.Thread.run(Thread.java:842)
[E] java.lang.InterruptedException: java.lang.InterruptedException
[E] 
Counter: 3
Counter: 4
SimpleTask Done.
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant