diff --git a/src/main/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManager.java b/src/main/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManager.java index ec9dfc869..7ab16201d 100644 --- a/src/main/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManager.java +++ b/src/main/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManager.java @@ -545,7 +545,8 @@ public Optional serverPathToFileUri(String serverPath) { .filter(e -> e.getValue().isPresent()) .map(e -> tryResolveLocalFile(serverPath, e.getKey(), e.getValue().get())) .flatMap(Optional::stream) - .map(File::toURI) + .map(File::toPath) + .map(Path::toUri) .findFirst(); } diff --git a/src/test/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManagerTests.java b/src/test/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManagerTests.java index 2f99ad9b2..81f4f96fc 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManagerTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/connected/ProjectBindingManagerTests.java @@ -555,7 +555,9 @@ void should_return_optional_on_valid_path() { var uri = underTest.serverPathToFileUri(serverPath); assertThat(uri).isNotEmpty(); - assertThat(uri.get().toString()).contains("src/test/resources/sample-folder/Test.java"); + assertThat(uri.get().toString()) + .startsWith("file:///") + .contains("src/test/resources/sample-folder/Test.java"); } @Test