1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 558541 - Remove dependency to org.apache.commons.io from CDT LSP

Switched to try-with-resources

Change-Id: Ia81b1e80c34ff62f9405d8a967f9877e5f8b0e86
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
Alexander Fedorov 2019-12-21 14:23:37 +03:00
parent b72a6c3d93
commit a2e53aa619
2 changed files with 5 additions and 11 deletions

View file

@ -2,12 +2,11 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.cdt.lsp.core Automatic-Module-Name: org.eclipse.cdt.lsp.core
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.cdt.lsp.core;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.lsp.core;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.1.0.qualifier
Bundle-Name: %Bundle-Name Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.google.gson;bundle-version="2.8.2", Require-Bundle: com.google.gson;bundle-version="2.8.2",
org.apache.commons.io,
org.eclipse.core.runtime, org.eclipse.core.runtime,
org.eclipse.core.commands, org.eclipse.core.commands,
org.eclipse.core.expressions, org.eclipse.core.expressions,

View file

@ -22,7 +22,6 @@ import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.IOUtils;
import org.eclipse.cdt.lsp.internal.core.LspCoreMessages; import org.eclipse.cdt.lsp.internal.core.LspCoreMessages;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -136,26 +135,22 @@ public class CPPStreamConnectionProvider extends ProcessStreamConnectionProvider
if (Platform.getOS().equals(Platform.OS_WIN32)) { if (Platform.getOS().equals(Platform.OS_WIN32)) {
command = new String[] { "cmd", "/c", "where " + selectedLanguageServer }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ command = new String[] { "cmd", "/c", "where " + selectedLanguageServer }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
BufferedReader reader = null;
try { try {
Process p = Runtime.getRuntime().exec(command); Process p = Runtime.getRuntime().exec(command);
reader = new BufferedReader(new InputStreamReader(p.getInputStream())); try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
res = reader.readLine(); res = reader.readLine();
}
} catch (IOException e) { } catch (IOException e) {
//FIXME: rework this branch , it may contain valuable information to understand the problem
e.printStackTrace(); e.printStackTrace();
} finally {
IOUtils.closeQuietly(reader);
} }
if (res == null) { if (res == null) {
return null; return null;
} }
File f = new File(res); File f = new File(res);
if (f.canExecute()) { if (f.canExecute()) {
return f; return f;
} }
return null; return null;
} }
} }