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

Should explicitly report the fatal settings error #2089

Merged
merged 1 commit into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,16 @@ private List<URI> getURIs(String url) {

private void addWatcher(URI uri, Set<IPath> sources) {
if (uri != null && "file".equals(uri.getScheme())) {
File file = new File(uri);
if (file != null) {
IPath path = new Path(file.getAbsolutePath());
if (!isContainedIn(path, sources)) {
sources.add(path);
try {
File file = new File(uri);
if (file != null) {
IPath path = new Path(file.getAbsolutePath());
if (!isContainedIn(path, sources)) {
sources.add(path);
}
}
} catch (Exception e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -374,6 +375,26 @@ public int compare(FileSystemWatcher o1, FileSystemWatcher o2) {
assertEquals(newWatchers, watchers);
}

// https://github.com/redhat-developer/vscode-java/issues/2429
@Test
public void testSettingsWatchers() throws Exception {
ClientPreferences mockCapabilies = mock(ClientPreferences.class);
when(mockCapabilies.isWorkspaceChangeWatchedFilesDynamicRegistered()).thenReturn(Boolean.TRUE);
when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
try {
preferences.setFormatterUrl("file:c:invalid");
String settingsUrl = "../../formatter/settings.prefs";
preferences.setSettingsUrl(settingsUrl);
List<FileSystemWatcher> watchers = projectsManager.registerWatchers();
assertEquals("Unexpected watchers:\n" + toString(watchers), 10, watchers.size());
} catch (Exception e) {
fail(e.getMessage());
} finally {
preferences.setFormatterUrl(null);
preferences.setSettingsUrl(null);
}
}

private String toString(List<FileSystemWatcher> watchers) {
return watchers.stream().map(FileSystemWatcher::getGlobPattern).collect(Collectors.joining("\n"));
}
Expand Down