sdedic opened a new pull request #3019:
URL: https://github.com/apache/netbeans/pull/3019
When LSP client runs "compile workspace" operation, the (gradle) compiler's
I/O is bound to the LSP `WorkspaceIOContext`. Then after Gradle finishes, the
`GradleExecutor` thread remains stuck:
```
"exec_Build (3)_1" #51 prio=5 os_prio=0 tid=0x00007f04a1187800 nid=0x67d2
waiting for monitor entry [0x00007f0510afa000]
java.lang.Thread.State: BLOCKED (on object monitor)
at sun.nio.cs.StreamDecoder.close(StreamDecoder.java:191)
- waiting to lock <0x0000000719a499a8> (a
org.netbeans.modules.java.lsp.server.ui.AbstractLspInputOutputProvider$LspIO$1)
at java.io.InputStreamReader.close(InputStreamReader.java:199)
at
org.netbeans.modules.java.lsp.server.ui.AbstractLspInputOutputProvider$LspIO$1.close(AbstractLspInputOutputProvider.java:152)
at
org.openide.util.io.ReaderInputStream.close(ReaderInputStream.java:130)
at
org.netbeans.modules.gradle.execute.GradleDaemonExecutor.closeInOutErr(GradleDaemonExecutor.java:348)
- locked <0x000000071984cba0> (a
org.netbeans.modules.gradle.execute.GradleDaemonExecutor)
at
org.netbeans.modules.gradle.execute.GradleDaemonExecutor.run(GradleDaemonExecutor.java:275)
at
org.netbeans.core.execution.RunClassThread.doRun(RunClassThread.java:132)
at
org.netbeans.core.execution.RunClassThread$$Lambda$311/594242913.run(Unknown
Source)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:81)
```
since it is waiting on the gradle's input stream to return something that
could be eventually forwarded to Gradle build:
```
"DisconnectableInputStream source reader" #54 daemon prio=5 os_prio=0
tid=0x00007f045574b800 nid=0x67dd in Object.wait() [0x00007f0508386000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at
org.netbeans.modules.java.lsp.server.protocol.WorkspaceIOContext$EmptyBlockingInputStream.read(WorkspaceIOContext.java:76)
- locked <0x00000005cc7bc980> (a
org.netbeans.modules.java.lsp.server.protocol.WorkspaceIOContext$EmptyBlockingInputStream)
at java.io.InputStream.read(InputStream.java:170)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
- locked <0x0000000719a499a8> (a
org.netbeans.modules.java.lsp.server.ui.AbstractLspInputOutputProvider$LspIO$1)
at sun.nio.cs.StreamDecoder.read0(StreamDecoder.java:127)
- locked <0x0000000719a499a8> (a
org.netbeans.modules.java.lsp.server.ui.AbstractLspInputOutputProvider$LspIO$1)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:112)
at java.io.InputStreamReader.read(InputStreamReader.java:168)
at
org.openide.util.io.ReaderInputStream.read(ReaderInputStream.java:65)
at
org.openide.util.io.ReaderInputStream.read(ReaderInputStream.java:88)
at
org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:98)
at java.lang.Thread.run(Thread.java:748)
```
LSP progress handle was not finished released, bcs the GradleExecutor thread
did not finish its work (it was blocked). An additional `Cancel` request from
LSP client blocked the entire communication:
```
"pool-1-thread-1" #41 prio=5 os_prio=0 tid=0x00007f818c0af800 nid=0x5ee3
waiting for monitor entry [0x00007f8244b25000]
java.lang.Thread.State: BLOCKED (on object monitor)
at
org.netbeans.modules.gradle.execute.GradleDaemonExecutor.closeInOutErr(GradleDaemonExecutor.java:348)
- waiting to lock <0x000000072e135f58> (a
org.netbeans.modules.gradle.execute.GradleDaemonExecutor)
at
org.netbeans.modules.gradle.execute.GradleDaemonExecutor.cancel(GradleDaemonExecutor.java:368)
at
org.netbeans.modules.progress.spi.InternalHandle.requestCancel(InternalHandle.java:364)
at
org.netbeans.modules.java.lsp.server.protocol.Server$ConsumeWithLookup$1.lambda$consume$0(Server.java:219)
at
org.netbeans.modules.java.lsp.server.protocol.Server$ConsumeWithLookup$1$$Lambda$48/138253834.run(Unknown
Source)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
at
org.netbeans.modules.java.lsp.server.protocol.Server$ConsumeWithLookup$1.consume(Server.java:213)
at
org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at
org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at
org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
```
This change allows the waiting `InputStream.read()` to return with value -1,
that will indicate EOF to the `StreamDecoder` and releases the waiting
`DisconnectableInputStream` thread; that also allows `close()` to complete on
that stream.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists