Workarounding thread hostile debugger.jpda.
authorTomas Zezula <tzezula@netbeans.org>
Fri, 31 Jan 2014 09:46:45 +0100
changeset 18144dbbdd23d6343
parent 18143 c51357ce5b6f
child 18145 9ad62b2c9ecb
child 18146 fa96cc8bfc88
Workarounding thread hostile debugger.jpda.
dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java
     1.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java	Thu Jan 30 19:12:26 2014 +0100
     1.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java	Fri Jan 31 09:46:45 2014 +0100
     1.3 @@ -117,10 +117,18 @@
     1.4              }
     1.5              try {
     1.6                  jpda.waitRunning();
     1.7 -            } catch (DebuggerStartException ex) {
     1.8 +                //Hack:
     1.9 +                //Now comes the fun, JPDADebuggerImpl is full of races
    1.10 +                //so after wait we need to busy wait. Inverted spin-park :-)
    1.11 +                while (jpda.getState() < 2) {
    1.12 +                    Thread.sleep(500);
    1.13 +                }
    1.14 +            } catch (DebuggerStartException | InterruptedException ex) {
    1.15                  return -1;
    1.16              }
    1.17 -            return id;
    1.18 +            return jpda.getState() == JPDADebugger.STATE_RUNNING ?
    1.19 +                id :
    1.20 +                -1;
    1.21          }            
    1.22          return -1;
    1.23      }