diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java index d31910161b4..04528701c68 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java @@ -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; } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java index 0c82d9ed6a9..25dacce322e 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java @@ -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; @@ -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) {