vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Space in path of java.settings.url causes URISyntaxException

Open matter-it-does opened this issue 3 years ago • 4 comments

Illegal character in path at index xx: /Users/t/OneDrive - company/code/java_global.prefs
java.net.URISyntaxException: Illegal character in path at index xx: /Users/t/OneDrive - company/code/java_global.prefs
	at java.base/java.net.URI$Parser.fail(Unknown Source)
	at java.base/java.net.URI$Parser.checkChars(Unknown Source)
	at java.base/java.net.URI$Parser.parseHierarchical(Unknown Source)
	at java.base/java.net.URI$Parser.parse(Unknown Source)
	at java.base/java.net.URI.<init>(Unknown Source)
	at org.eclipse.jdt.ls.core.internal.managers.StandardProjectsManager.getURIs(StandardProjectsManager.java:533)
	at org.eclipse.jdt.ls.core.internal.managers.StandardProjectsManager.fileChanged(StandardProjectsManager.java:201)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceEventsHandler.didChangeWatchedFiles(WorkspaceEventsHandler.java:115)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.didChangeWatchedFiles(JDTLanguageServer.java:518)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$0(ParentProcessWatcher.java:130)
	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.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Environment
  • Operating System: macOS
  • JDK version:
  • Visual Studio Code version: Version: 1.70.2
  • Java extension version: v1.9.0
Steps To Reproduce

In settings, set java.settings.url to a path with space in it.

Current Result

The exception above

Expected Result

no exception

matter-it-does avatar Aug 19 '22 04:08 matter-it-does

@matter-it-does

The error is thrown from here due to /Users/t/OneDrive - company/code/java_global.prefs cannot be parsed to a URI.

Then it will be dealt as a file path. In your case, are the settings in the java_global.prefs file take effect?

jdneo avatar Aug 19 '22 05:08 jdneo

@matter-it-does Then it will be dealt as a file path. In your case, are the settings in the java_global.prefs file take effect?

@jdneo

Oh I just noticed, they take effect, but the exception is a bit confusing and cluttering

matter-it-does avatar Aug 22 '22 04:08 matter-it-does

Would @snjeza 's PR from https://github.com/redhat-developer/vscode-java/pull/2451 help with this ?

rgrunber avatar Aug 22 '22 21:08 rgrunber

Seems not. https://github.com/redhat-developer/vscode-java/pull/2451 is to check invalid url value. While in this case, user's url is a valid value.

The exception is thrown because the server will first try to parse a windows file path string to a URL. After failure, the server fallbacks to treat it as a file path. So it's still working finally.

jdneo avatar Aug 23 '22 02:08 jdneo