Skip to content

Commit

Permalink
Silent OperationCanceledException during hover eclipse-jdt#1827
Browse files Browse the repository at this point in the history
If Operation is canceled result is just not needed anymore. No need to
log an error.

* also silent BadLocationException

eclipse-jdt#1827
  • Loading branch information
EcljpseB0T committed Dec 4, 2024
1 parent e57bf66 commit cee7c7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,11 @@ private String getBracketHoverInfo(final ITextViewer textViewer, IRegion region)
}
return source;
} catch (BadLocationException e) {
JavaPlugin.log(e);
/*
* This code runs in a separate thread which can
* lead to text offsets being out of bounds when
* computing the hover info (see bug 32848).
*/
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Objects;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.OperationCanceledException;

import org.eclipse.core.resources.IResource;

Expand Down Expand Up @@ -130,6 +131,12 @@ private SelectionUtil() {
private static String lastErrorMsg;

public static void logException(String action, RuntimeException e, String title, IDocument document, int offset) {
if (e instanceof OperationCanceledException ) {
// Be silent if operation is canceled see
// https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1827
return;
}

// log error and keep going
String errorMsg= e.getClass().getSimpleName() + " " + action; //$NON-NLS-1$
if (title != null) {
Expand Down

0 comments on commit cee7c7a

Please sign in to comment.