JaroslavTulach commented on a change in pull request #2427:
URL: https://github.com/apache/netbeans/pull/2427#discussion_r501884025
##########
File path: java/maven/src/org/netbeans/modules/maven/debug/MavenJPDAStart.java
##########
@@ -69,139 +72,126 @@
private ClassPath additionalSourcePath;
- private final Object[] lock = new Object[2];
-
- private Project project;
- private final String actionName;
- private final InputOutput io;
+ private final Project project;
+ private Future<?> lastFuture;
+
+ private MavenJPDAStart(Project p) {
+ this.project = p;
+ }
- JPDAStart(InputOutput inputOutput, String actionName) {
- io = inputOutput;
- this.actionName = actionName;
+ /** Create and place into Project's Lookup.
+ * @param p the project to associate this start with
+ * @return new instance of the start infrastructure
+ */
+ public static MavenJPDAStart create(Project p) {
+ return new MavenJPDAStart(p);
}
/**
* returns the port/address that the debugger listens to..
*/
- public String execute(Project project) throws Throwable {
- this.project = project;
- io.getOut().println("JPDA Listening Start..."); //NOI18N
-// getLog().debug("Entering synch lock"); //NOI18N
- synchronized (lock) {
-// getLog().debug("Entered synch lock"); //NOI18N
- RP.post(this);
-// getLog().debug("Entering wait"); //NOI18N
- lock.wait();
-// getLog().debug("Wait finished"); //NOI18N
- if (lock[1] != null) {
- throw ((Throwable) lock[1]); //NOI18N
+ public String execute(InputOutput io) throws Throwable {
+ Future<?> prev = lastFuture;
+ if (prev != null && !prev.isDone()) {
+ io.getOut().print("Cancelling previous JPDA listening...");
//NOI18N
+ if (prev.cancel(true)) {
+ io.getOut().println("done"); //NOI18N
+ } else {
+ io.getOut().println("failed"); //NOI18N
}
}
- return (String)lock[0];
+ io.getOut().println("JPDA Listening Start..."); //NOI18N
+ Future<String> future = RP.submit(() -> {
+ return startDebugger(io);
+ });
+ lastFuture = future;
Review comment:
Done in 0e6accd
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists