Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode ext causes "Header must provide a Content-Length property" continuously #968

Closed
ZinkLu opened this issue Feb 3, 2023 · 8 comments
Assignees
Labels
for: vscode something that is specific for VSCode type: bug

Comments

@ZinkLu
Copy link

ZinkLu commented Feb 3, 2023

Describe the bug
'to go defined' and 'code completion' fails. Developer Tools console continues to report errors "Header must provide a Content-Length property"

image

To Reproduce
MacOS 13.1 M1
install vscode 1.75.0
install vmware.vscode-spring-boot v1.44.0

Write some code that will cause the Java language server reports error(for example: call a function with invaid arguement), then the error is likely to be reproduced.

@BoykoAlex
Copy link
Contributor

These issues are usually related to the logging setup on the JVM... Can you check if JVM you are using to launch spring boot ls is different from the JVM launching Java LS?
spring-boot.ls.java.home property value and java.jdt.ls.java.home.

Read through the issue below:
redhat-developer/vscode-java#2577

Ensure there are no java agents contributing to the log output etc...

The issue is that something in the JVM attempts to write something to the output stream of the Spring Boot LS java process. The output stream of that process is used to send messages from the LS to the IDE client. Therefore IDE client throws an error that there is something unexpected found in the output stream.

@ZinkLu
Copy link
Author

ZinkLu commented Feb 3, 2023

I didn't change neither spring-boot.ls.java.home nor java.jdt.ls.java.home so both of them should stay default.

I can comfirm that this issue only happens when I upgrade vscode-spring-boot to v1.44.0.

I did tweak java.jdt.ls.vmargs on memory options.I'll fllow the vscode-java issue to do more tweaks.Thanks for replying, this issue should be closed if it work.

@ZinkLu
Copy link
Author

ZinkLu commented Feb 4, 2023

The errors were gone after adding -Xlog:jni+resolve=off in "java.jdt.ls.vmargs" and "spring-boot.ls.java.vmargs".

@ZinkLu ZinkLu closed this as completed Feb 4, 2023
@ZinkLu
Copy link
Author

ZinkLu commented Feb 4, 2023

This error occurred again, I do not know what will trigger this error, I temporarily disabled the spring-boot-tools.

@BoykoAlex
Copy link
Contributor

@ZinkLu do you recall what you were doing in VSCode at the moment of the error? Which editor you were working with?

Lets try to determine which LSP messages causes this error assuming it is some particular message... hopefully...

  1. Open VSCode settings.json and add "vscode-spring-boot.trace.server": "verbose" to it.
  2. Reload the Window or re-start VSCode
  3. Activate Output tab at the bottom and select vscode-spring-boot-debug-log in the drop-down in the top-right corner of the view

Screenshot 2023-02-06 at 11 17 26

Continue working with spring-boot extension. Once the "header content length" error occurs note the log and attach/paste the relevant part of it here please.

@ZinkLu
Copy link
Author

ZinkLu commented Feb 7, 2023

Hi @BoykoAlex, It's likely to reproduce the issue with following steps:

  1. Open a spring boot project;
  2. Typing some code which has syntax error(such as missing semicolons) and invalid function calling;
  3. Continue typing some function calling with coding auto-completion;
  4. Use 'Go To Definition' on the function (String.valueOf in my example);
  5. Issue reproduced;

Here is my example:

image

Trace log whe the issue happen;

[Trace - 11:53:51] Sending request 'textDocument/documentHighlight - (510)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 9,
        "character": 8
    }
}


[Trace - 11:53:51] Sending request 'textDocument/codeAction - (511)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 9,
            "character": 8
        },
        "end": {
            "line": 9,
            "character": 8
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 9,
                        "character": 8
                    },
                    "end": {
                        "line": 9,
                        "character": 39
                    }
                },
                "message": "Type null of the last argument to method format(Locale, String, Object...) doesn't exactly match the vararg parameter type. Cast to Object[] to confirm the non-varargs invocation, or pass individual arguments of type Object for a varargs invocation.",
                "code": "67109665",
                "severity": 2,
                "source": "Java"
            }
        ],
        "triggerKind": 2
    }
}


[Trace - 11:53:51] Sending notification '$/cancelRequest'.
Params: {
    "id": 509
}


[Trace - 11:55:03] Sending notification '$/cancelRequest'.
Params: {
    "id": 510
}


[Trace - 11:55:03] Sending request 'textDocument/documentHighlight - (512)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 24
    }
}


[Trace - 11:55:03] Sending notification '$/cancelRequest'.
Params: {
    "id": 501
}


[Trace - 11:55:03] Sending request 'textDocument/codeLens - (513)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    }
}


[Trace - 11:55:04] Sending request 'textDocument/codeAction - (514)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 10,
            "character": 24
        },
        "end": {
            "line": 10,
            "character": 24
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 10,
                        "character": 24
                    },
                    "end": {
                        "line": 10,
                        "character": 25
                    }
                },
                "message": "Syntax error, insert \";\" to complete Statement",
                "code": "1610612976",
                "severity": 1,
                "source": "Java"
            }
        ],
        "triggerKind": 2
    }
}


[Trace - 11:55:04] Sending notification '$/cancelRequest'.
Params: {
    "id": 511
}


[Trace - 11:55:19] Sending notification '$/cancelRequest'.
Params: {
    "id": 513
}


[Trace - 11:55:19] Sending request 'textDocument/codeLens - (515)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    }
}


[Trace - 11:55:19] Sending notification '$/cancelRequest'.
Params: {
    "id": 512
}


[Trace - 11:55:19] Sending request 'textDocument/documentHighlight - (516)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 9,
        "character": 38
    }
}


[Trace - 11:55:19] Sending request 'textDocument/codeAction - (517)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 9,
            "character": 38
        },
        "end": {
            "line": 9,
            "character": 38
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 9,
                        "character": 8
                    },
                    "end": {
                        "line": 9,
                        "character": 39
                    }
                },
                "message": "Type null of the last argument to method format(Locale, String, Object...) doesn't exactly match the vararg parameter type. Cast to Object[] to confirm the non-varargs invocation, or pass individual arguments of type Object for a varargs invocation.",
                "code": "67109665",
                "severity": 2,
                "source": "Java"
            },
            {
                "range": {
                    "start": {
                        "line": 9,
                        "character": 38
                    },
                    "end": {
                        "line": 9,
                        "character": 39
                    }
                },
                "message": "Syntax error, insert \";\" to complete BlockStatements",
                "code": "1610612976",
                "severity": 1,
                "source": "Java"
            }
        ],
        "triggerKind": 2
    }
}


[Trace - 11:55:19] Sending notification '$/cancelRequest'.
Params: {
    "id": 514
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 516
}


[Trace - 11:55:20] Sending request 'textDocument/documentHighlight - (518)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 12
    }
}


[Trace - 11:55:20] Sending request 'textDocument/codeAction - (519)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 10,
            "character": 12
        },
        "end": {
            "line": 10,
            "character": 12
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 517
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 518
}


[Trace - 11:55:20] Sending request 'textDocument/documentHighlight - (520)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 16
    }
}


[Trace - 11:55:20] Sending request 'textDocument/codeAction - (521)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 10,
            "character": 16
        },
        "end": {
            "line": 10,
            "character": 16
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 519
}


[Trace - 11:55:20] Sending request 'textDocument/hover - (522)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 16
    }
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 497
}


[Trace - 11:55:20] Sending request 'textDocument/definition - (523)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 16
    }
}


[Trace - 11:55:20] Sending notification '$/cancelRequest'.
Params: {
    "id": 522
}


[Trace - 11:55:21] Sending request 'textDocument/hover - (524)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 17
    }
}


[Trace - 11:55:21] Sending notification '$/cancelRequest'.
Params: {
    "id": 524
}


[Trace - 11:55:21] Sending request 'textDocument/definition - (525)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 18
    }
}


[Trace - 11:55:21] Sending notification '$/cancelRequest'.
Params: {
    "id": 523
}


[Trace - 11:55:21] Sending request 'textDocument/definition - (526)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 13
    }
}


[Trace - 11:55:21] Sending request 'textDocument/codeAction - (527)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "range": {
        "start": {
            "line": 10,
            "character": 18
        },
        "end": {
            "line": 10,
            "character": 18
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:55:21] Sending notification '$/cancelRequest'.
Params: {
    "id": 521
}


[Trace - 11:55:26] Sending notification '$/cancelRequest'.
Params: {
    "id": 515
}


[Trace - 11:55:26] Sending request 'textDocument/codeLens - (528)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    }
}


[Trace - 11:55:26] Sending request 'textDocument/hover - (529)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 17
    }
}


[Trace - 11:55:26] Sending notification '$/cancelRequest'.
Params: {
    "id": 526
}


[Trace - 11:55:26] Sending request 'textDocument/definition - (530)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 18
    }
}


[Trace - 11:55:27] Sending notification '$/cancelRequest'.
Params: {
    "id": 529
}


[Trace - 11:55:28] Sending request 'textDocument/definition - (531)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 18
    }
}


[Trace - 11:55:28] Sending request 'textDocument/hover - (532)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    },
    "position": {
        "line": 10,
        "character": 17
    }
}


[Trace - 11:55:28] Sending notification '$/cancelRequest'.
Params: {
    "id": 532
}


[Trace - 11:59:55] Sending notification '$/cancelRequest'.
Params: {
    "id": 528
}


[Trace - 11:59:55] Sending request 'textDocument/codeLens - (533)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/zinklu/tmp/demo/src/main/java/com/example/demo/controller/Hello.java"
    }
}

@BoykoAlex
Copy link
Contributor

The issue is that OpenRewrite dependency has a System.out.println(...) statement executed while parsing a Java Source. Since standard in and out streams of the Language Server process are used for JSON RPC comm to the IDE client (VSCode) the sys out corrupts the comm data hence the error about header content length.

Here is the fix for rewrite project: openrewrite/rewrite#2804

Once it is merged then spring-boot extension is built I'll post the download link to VSIX file to try and close the issue.

@BoykoAlex
Copy link
Contributor

Please try spring-boot extension VSIX (snapshot) at the bottom of the page: https://dist.springsource.com/snapshot/STS4/nightly-distributions.html Should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode type: bug
Projects
None yet
Development

No branches or pull requests

3 participants