mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Fixed the bug related to the incorrect exception handling that could cause a null pointer exception
This commit is contained in:
parent
24648ae9ed
commit
53358d181d
2 changed files with 19 additions and 27 deletions
|
@ -120,31 +120,26 @@ public class CygwinPathResolver implements IBuildPathResolver {
|
|||
IPath toSave = GnuUIPlugin.getDefault().getStateLocation();
|
||||
toSave = toSave.addTrailingSeparator().append(OUTFILE);
|
||||
String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT };
|
||||
try {
|
||||
File f = new File(toSave.toOSString());
|
||||
f.delete();
|
||||
int result = -1;
|
||||
try {
|
||||
result = ProcessFactory.getFactory().exec(args).waitFor();
|
||||
}
|
||||
catch (IOException e) {}
|
||||
catch (InterruptedException e) {}
|
||||
if (result == 0 && f.exists() && f.canRead()) {
|
||||
BufferedReader r = null;
|
||||
try {
|
||||
r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
|
||||
} catch (FileNotFoundException e) {}
|
||||
if (ProcessFactory.getFactory().exec(args).waitFor() == 0 && f.exists() && f.canRead()) {
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
|
||||
ArrayList ls = new ArrayList(1);
|
||||
try {
|
||||
String s;
|
||||
while ((s = r.readLine() ) != null ) ls.add(s);
|
||||
r.close();
|
||||
f.delete();
|
||||
} catch (IOException e) {}
|
||||
String[] aus = (String[])ls.toArray(new String[0]);
|
||||
if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); }
|
||||
if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); }
|
||||
if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException e) {
|
||||
} catch (SecurityException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,14 +40,11 @@ public class IsGnuCygwinToolChainSupported implements
|
|||
String etcCygwin = CygwinPathResolver.getEtcPath();
|
||||
if (etcCygwin != null) {
|
||||
File file = new File(etcCygwin + "/setup/installed.db"); //$NON-NLS-1$
|
||||
BufferedReader data;
|
||||
try {
|
||||
data = new BufferedReader(new FileReader(file));
|
||||
} catch (FileNotFoundException e) { return false; }
|
||||
BufferedReader data = new BufferedReader(new FileReader(file));
|
||||
|
||||
// all required package names should be found
|
||||
boolean[] found = new boolean[CHECKED_NAMES.length];
|
||||
try {
|
||||
String s;
|
||||
while ((s = data.readLine()) != null ) {
|
||||
for (int j = 0; j < CHECKED_NAMES.length; j++) {
|
||||
|
@ -59,8 +56,8 @@ public class IsGnuCygwinToolChainSupported implements
|
|||
toolchainIsSupported &= found[j];
|
||||
}
|
||||
data.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (IOException e) {
|
||||
//TODO: log
|
||||
}
|
||||
}
|
||||
return toolchainIsSupported;
|
||||
|
|
Loading…
Add table
Reference in a new issue