redhat-developer / redhat-developer/vscode-java

Extension hangs with org.eclipse.jface.text.BadLocationException

Open
#602 16 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ls-error/crash stale
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Pretty often when I am refactoring my code and there (one or two files contain pretty broken code) - extension hangs and all it's features stop working.

Restarting VSCode fixes the issue.

My project is super simple (5 classes), has rudimentary pom.xml.

Output window for Language Support for Java shows this error:

[Error - 9:07:53 PM] Aug 1, 2018 9:07:02 PM 
null
org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.TreeLineTracker.fail(TreeLineTracker.java:1051)
	at org.eclipse.jface.text.TreeLineTracker.lineByOffset(TreeLineTracker.java:265)
	at org.eclipse.jface.text.TreeLineTracker.getLineNumberOfOffset(TreeLineTracker.java:1119)
	at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:151)
	at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:868)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineOfOffset(SynchronizableDocument.java:331)
	at org.eclipse.jdt.ls.core.internal.handlers.JsonRpcHelpers.toLine(JsonRpcHelpers.java:60)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.toRange(JDTUtils.java:466)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.toLocation(JDTUtils.java:380)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.toLocation(JDTUtils.java:342)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.collectChildren(DocumentSymbolHandler.java:75)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.collectChildren(DocumentSymbolHandler.java:68)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.getOutline(DocumentSymbolHandler.java:52)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentSymbolHandler.documentSymbol(DocumentSymbolHandler.java:44)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$12(JDTLanguageServer.java:532)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$23(JDTLanguageServer.java:732)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Same error and stack dump can be found in the log that I open with "Java: Open Java Language Server log file".

(related?) Dev Tools console log contains quite a lot copies of this warning:

 WARN Error: listener failed
    at workbench.main.js:sourcemap:4061
    at Object.g [as _notify] (workbench.main.js:sourcemap:150)
    at Object.enter (workbench.main.js:sourcemap:154)
    at n.Class.derive._oncancel._run (workbench.main.js:sourcemap:155)
    at n.Class.derive._oncancel._completed (workbench.main.js:sourcemap:155)
    at e.resolveOk (workbench.main.js:sourcemap:3060)
    at e._receiveReply (workbench.main.js:sourcemap:3127)
    at e._receiveOneMessage (workbench.main.js:sourcemap:3126)
    at workbench.main.js:sourcemap:3125
    at workbench.main.js:sourcemap:3128
    at e.fire (workbench.main.js:sourcemap:171)
    at c (workbench.main.js:sourcemap:302)
    at Socket.<anonymous> (workbench.main.js:sourcemap:303)
    at emitOne (events.js:96)
    at Socket.emit (events.js:191)
    at readableAddChunk (_stream_readable.js:178)
    at Socket.Readable.push (_stream_readable.js:136)
    at Pipe.onread (net.js:560)

I was experiencing the same issue with the previous version of the extension.

When extension hangs, VSCode status bar usually says "Validating document - 0%"

Environment
  • Operating System: Win10 v1803
  • JDK version: 1.8.0_181
  • Visual Studio Code version: 1.25.1
  • Java extension version: 0.29.0
Steps To Reproduce

Not quite sure about the pattern or repro yet, but happens like every hour (=pretty often).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack trace entries in DocumentSymbolHandler, JDTUtils, and JsonRpcHelpers, then reproduce the hang using broken Java files and inspect the Java Language Server log. The issue is resolved when document validation and extension features continue working without the BadLocationException hang.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.