cbuschka / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

beanshell desktop freezes #80

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. start BeanShell Desktop with command 
  java -jar bsh-2.1b5.jar 

2. copy and paste example script into BeanShell Desktop Workspace

foo = "Foo";    
four = (2 + 2)*2/2;
print( foo + " = " + four );  // print() is a BeanShell command

// Do a loop
for (i=0; i<5; i++)
    print(i);   

// Pop up a frame with a button in it
button = new JButton( "My Button" );
frame = new JFrame( "My Frame" );
frame.getContentPane().add( button, "Center" );
frame.pack();
frame.setVisible(true);

3. press Enter

What is the expected output? What do you see instead?
BeanShell Desktop freezes

What version of the product are you using? On what operating system?
java "1.6.0_31"
bsh-2.1b5
Win7 x64

Original issue reported on code.google.com by michal.b...@gmail.com on 31 Oct 2012 at 4:29

GoogleCodeExporter commented 8 years ago
cannot reproduce - window pops up, key events are still handled

Original comment by pejob...@gmail.com on 5 Nov 2012 at 4:14

GoogleCodeExporter commented 8 years ago
Please look at threaddump http://pastebin.com/Ar29KTjd created when beanshell 
is frozen. 

The issue occurs when pasted block of code is large enough, so that Interpreter 
running in Thread-3 starts to send output before the block of code is sent to 
PipedOutputStream.

In the threaddump, AWT-EventQueue-0 thread is blocked, it's trying to send 
large command to PipedOutputStream, therefore it's unable update user 
interface. Thread-3 is blocked as well, it's trying to execute some code in 
Swing UI thread (by calling SwingUtilities.invokeAndWait method). These two 
threads are waiting for each other.

Original comment by michal.b...@gmail.com on 5 Nov 2012 at 8:42

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
In Issue #81 the following comment concerning this issue was added by Michael 
Bergmann:

<snip>
I've also loaded beanshell console into eclipse and looked at source code. 
There are actually two bugs in Beanshell Console code, fixing either one of 
them (preferably both) should resolve the issue.

   1st bug  : method bsh.util.JConsole.acceptLine - Text inputted by user is written to PipedOutputStream in Swing UI thread - that should happen in another thread.

  2nd bug  : methods bsh.util.JConsole.print - response from Interpreter should be printed to console using SwingUtilities.invokeLater method instead of SwingUtilities.invokeAndWait
</snip>

Original comment by pejob...@gmail.com on 6 Nov 2012 at 7:33

GoogleCodeExporter commented 8 years ago

Original comment by pejob...@gmail.com on 6 Nov 2012 at 7:33

GoogleCodeExporter commented 8 years ago
As mentioned a timing issue. "SwingUtilities.invokeAndWait" is evil (deadlock 
prone).

Original comment by pejob...@gmail.com on 6 Nov 2012 at 7:41

GoogleCodeExporter commented 8 years ago
Issue 81 has been merged into this issue.

Original comment by pejob...@gmail.com on 6 Nov 2012 at 7:41