From 2d925f28661fb027cdb724421e195ae5a9a89691 Mon Sep 17 00:00:00 2001 From: Svata Dedic Date: Sat, 14 Sep 2024 15:31:39 +0200 Subject: [PATCH] Code improvements from the review. --- .../netbeans/modules/project/dependency/ProjectReload.java | 4 +++- .../netbeans/modules/project/dependency/reload/Reloader.java | 4 +--- .../java/lsp/server/protocol/TextDocumentServiceImpl.java | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ide/project.dependency/src/org/netbeans/modules/project/dependency/ProjectReload.java b/ide/project.dependency/src/org/netbeans/modules/project/dependency/ProjectReload.java index e40fada36fb8..45574a8deaae 100644 --- a/ide/project.dependency/src/org/netbeans/modules/project/dependency/ProjectReload.java +++ b/ide/project.dependency/src/org/netbeans/modules/project/dependency/ProjectReload.java @@ -965,7 +965,9 @@ public static CompletableFuture withProjectState(Project p, final // special case if the state matches & is consistent: if the attempted quality is LESS // than this request's target, the ReloadImplementation might give up if (!doReload && lastKnown.target.isAtLeast(stateRequest.getTargetQuality())) { - LOG.log(Level.FINE, "FINISHED: Reload {0}, request: {1}, state {2} - NOOP, finished", new Object[] { p, stateRequest, lastKnown.toString() }); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "FINISHED: Reload {0}, request: {1}, state {2} - NOOP, finished", new Object[] { p, stateRequest, lastKnown.toString() }); + } return CompletableFuture.completedFuture(lastKnown); } String reason = stateRequest.getReason(); diff --git a/ide/project.dependency/src/org/netbeans/modules/project/dependency/reload/Reloader.java b/ide/project.dependency/src/org/netbeans/modules/project/dependency/reload/Reloader.java index 3efe1d273423..61fdb6b20031 100644 --- a/ide/project.dependency/src/org/netbeans/modules/project/dependency/reload/Reloader.java +++ b/ide/project.dependency/src/org/netbeans/modules/project/dependency/reload/Reloader.java @@ -463,9 +463,7 @@ private CompletableFuture maybeMakeRetry(Collection variant) { if (LOG.isLoggable(Level.FINE)) { String s = Stream.concat(fileInconsistencies.stream(),retries.stream()). map(c -> c.impl.getClass().getName()).collect(Collectors.joining(", ")); - if (LOG.isLoggable(Level.FINE)) { - LOG.log(Level.FINE, "{0} reloads again because of {1}", new Object[]{toString(), s}); - } + LOG.log(Level.FINE, "{0} reloads again because of {1}", new Object[]{toString(), s}); } this.lastRetries = retries; this.lastInconsistent = fileInconsistencies; diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java index 1ba67b9cab3b..5357b99fcae9 100644 --- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java +++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java @@ -1792,7 +1792,9 @@ public void didSave(DidSaveTextDocumentParams savedParams) { org.openide.util.Task t = (org.openide.util.Task)reload.invoke(cake); // wait for a limited time, this could be enough for the reload to complete, blocking LSP queue. We do not want to block LSP queue indefinitely: // in case of an error, the server could become unresponsive. - t.waitFinished(300); + if (!t.waitFinished(300)) { + LOG.log(Level.WARNING, "{0}: document reload did not finish in 300ms", file); + } } catch (ReflectiveOperationException | InterruptedException | SecurityException ex) { // nop }