Fix error setting breakpoints. See #308

This commit is contained in:
Alexey Andreev 2018-01-08 14:44:43 +03:00
parent a24d628603
commit 2ae6c872db
2 changed files with 22 additions and 0 deletions

View File

@ -322,6 +322,20 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
}
breakpointLocationMap.remove(breakpoint.getLocation());
breakpoints.remove(breakpoint);
if (breakpoint.chromeId == null) {
synchronized (breakpoint.updateMonitor) {
while (breakpoint.updating.get()) {
try {
breakpoint.updateMonitor.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
}
}
if (breakpoint.chromeId != null) {
breakpointsByChromeId.remove(breakpoint.chromeId);
if (logger.isInfoEnabled()) {
@ -371,10 +385,15 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
}
breakpoint.chromeId = null;
}
synchronized (breakpoint.updateMonitor) {
breakpoint.updating.set(false);
breakpoint.updateMonitor.notifyAll();
}
for (JavaScriptDebuggerListener listener : getListeners()) {
listener.breakpointChanged(breakpoint);
}
});
breakpoint.updating.set(true);
sendMessage(message);
}

View File

@ -15,6 +15,7 @@
*/
package org.teavm.chromerdp;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.teavm.debugging.javascript.JavaScriptBreakpoint;
import org.teavm.debugging.javascript.JavaScriptLocation;
@ -24,6 +25,8 @@ public class RDPBreakpoint implements JavaScriptBreakpoint {
ChromeRDPDebugger debugger;
private JavaScriptLocation location;
AtomicInteger referenceCount = new AtomicInteger();
final Object updateMonitor = new Object();
AtomicBoolean updating = new AtomicBoolean(true);
RDPBreakpoint(ChromeRDPDebugger debugger, JavaScriptLocation location) {
this.debugger = debugger;