This is an automated email from the ASF dual-hosted git repository. skygo pushed a commit to branch delivery in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push: new eeaa76483c Avoid dependency on ReferenceQueue internals new f44633889a Merge pull request #4130 from anthonyvdotbe/fix-activequeue eeaa76483c is described below commit eeaa76483c7900a921239e52e3574d925936e8b8 Author: Anthony Vanelverdinghe <d...@anthonyv.be> AuthorDate: Sat May 21 13:30:59 2022 +0200 Avoid dependency on ReferenceQueue internals Signed-off-by: Anthony Vanelverdinghe <d...@anthonyv.be> --- .../openide/util/lookup/implspi/ActiveQueue.java | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/platform/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java b/platform/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java index dd57b504c8..abf380a998 100644 --- a/platform/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java +++ b/platform/openide.util.lookup/src/org/openide/util/lookup/implspi/ActiveQueue.java @@ -57,17 +57,23 @@ public final class ActiveQueue { } @Override - public Reference<Object> remove(long timeout) throws IllegalArgumentException, InterruptedException { - throw new InterruptedException(); + public Reference<? extends Object> remove(long timeout) throws IllegalArgumentException, InterruptedException { + if (timeout < 0) { + throw new IllegalArgumentException("Negative timeout value"); + } else if (Thread.currentThread() != Daemon.running) { + throw new InterruptedException(); + } + + return super.remove(timeout); } @Override - public Reference<Object> remove() throws InterruptedException { - throw new InterruptedException(); - } - - final Reference<? extends Object> removeSuper() throws InterruptedException { - return super.remove(0); + public Reference<? extends Object> remove() throws InterruptedException { + if (Thread.currentThread() != Daemon.running) { + throw new InterruptedException(); + } + + return super.remove(); } } @@ -112,7 +118,7 @@ public final class ActiveQueue { if (impl == null) { return; } - Reference<?> ref = impl.removeSuper(); + Reference<?> ref = impl.remove(); LOGGER.log(Level.FINE, "Got dequeued reference {0}", new Object[] { ref }); if (!(ref instanceof Runnable)) { LOGGER.log(Level.WARNING, "A reference not implementing runnable has been added to the Utilities.activeReferenceQueue(): {0}", ref.getClass()); @@ -131,9 +137,8 @@ public final class ActiveQueue { // to allow GC ref = null; } - } catch (InterruptedException ex) { - // Can happen during VM shutdown, it seems. Ignore. - continue; + } catch (InterruptedException ignored) { + // Can happen during VM shutdown, it seems. } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists