eppleton commented on code in PR #9853:
URL: https://github.com/apache/netbeans/pull/9853#discussion_r4803079917
##########
platform/core.startup/src/org/netbeans/core/startup/NbStartStop.java:
##########
@@ -103,8 +103,9 @@ boolean closing(List<? extends ModuleInfo> modules) {
return false;
}
} catch (Exception ex) {
- Util.err.log(Level.FINE, c.getClass() + " thrown an
exception", ex); // NOI18N
- return false;
+ // A broken hook must not keep the system running: it is
logged and
+ // skipped, as a failing ModuleInstall.closing() is in
NbInstaller.
+ Util.err.log(Level.WARNING, c.getClass() + " thrown an
exception, not treated as a refusal to close", ex); // NOI18N
Review Comment:
This applies in GUI mode as well. Until now, an `@OnStop` `Callable` that
threw an exception vetoed the shutdown; now the exception is logged and the
shutdown continues. That matches how `NbInstaller.closing()` treats a failing
`ModuleInstall.closing()`, which I think is reasonable. The `@OnStop` Javadoc
doesn't say how exceptions are handled, though. Since this goes beyond the
headless case, maybe mention it in the PR description, or add a sentence to the
`@OnStop` Javadoc?
##########
platform/core.execution/src/org/netbeans/core/execution/Install.java:
##########
@@ -226,6 +248,66 @@ private static boolean showPendingTasks() {
return true;
}
+ private static final RequestProcessor RP = new
RequestProcessor(Install.class);
+
+ /** The pending tasks that are still running: a finished progress handle
+ * stays in the model until the progress UI has processed its event. */
+ static Collection<?> runningTasks() {
+ ArrayList<Object> running = new ArrayList<Object>();
+ for (Object t : getPendingTasks()) {
+ if (t instanceof InternalHandle && ((InternalHandle) t).getState()
== InternalHandle.STATE_FINISHED) {
+ continue;
+ }
+ running.add(t);
+ }
+ return running;
+ }
+
+ /** Waits until there is no running task. When called from the event queue
+ * (the exit sequence runs there) the queue keeps dispatching meanwhile, so
+ * the tasks can finish. Progress is logged every 10 s. */
+ static void waitForPendingTasks() {
Review Comment:
This wait has no upper bound. In GUI mode the user can leave the
pending-tasks dialog with "Exit", which runs `killPendingTasks()`: it cancels
the progress handles and stops running `ExecutorTask`s. Without a GUI there is
no equivalent, so exit waits as long as anything listed by `getPendingTasks()`
is running. That list includes:
- a long initial scan, which is the case the test describes;
- an action that never returns;
- an `ExecutorTask`, if something in the LSP session runs through
`ExecutionEngine` (I haven't checked whether it does).
In all of these the process would keep running after
`LifecycleManager.exit()`. Before this PR it stayed alive too, because the exit
was refused, so this isn't a regression. Still, would it make sense to wait for
a limited time and then do what the dialog's "Exit" button does?
--
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.
To unsubscribe, e-mail: [email protected]
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