1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Fixed the bug related to the incorrect exception handling that could cause a null pointer exception

This commit is contained in:
Mikhail Sennikovsky 2005-05-31 11:25:06 +00:00
parent 24648ae9ed
commit 53358d181d
2 changed files with 19 additions and 27 deletions

View file

@ -120,30 +120,25 @@ public class CygwinPathResolver implements IBuildPathResolver {
IPath toSave = GnuUIPlugin.getDefault().getStateLocation(); IPath toSave = GnuUIPlugin.getDefault().getStateLocation();
toSave = toSave.addTrailingSeparator().append(OUTFILE); toSave = toSave.addTrailingSeparator().append(OUTFILE);
String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT }; String[] args = {ARG0, ARG1, toSave.toOSString(), REGISTRY_ROOTS[i]+REGISTRY_KEY+QUOT };
File f = new File(toSave.toOSString());
f.delete();
int result = -1;
try { try {
result = ProcessFactory.getFactory().exec(args).waitFor(); File f = new File(toSave.toOSString());
} f.delete();
catch (IOException e) {} if (ProcessFactory.getFactory().exec(args).waitFor() == 0 && f.exists() && f.canRead()) {
catch (InterruptedException e) {} BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
if (result == 0 && f.exists() && f.canRead()) { ArrayList ls = new ArrayList(1);
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
} catch (FileNotFoundException e) {}
ArrayList ls = new ArrayList(1);
try {
String s; String s;
while ((s = r.readLine() ) != null ) ls.add(s); while ((s = r.readLine() ) != null ) ls.add(s);
r.close(); r.close();
f.delete(); f.delete();
} catch (IOException e) {} String[] aus = (String[])ls.toArray(new String[0]);
String[] aus = (String[])ls.toArray(new String[0]); if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); }
if (etcCygwin == null) { etcCygwin = getDir(aus, ETCPATTERN); } if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); }
if (binCygwin == null) { binCygwin = getDir(aus, BINPATTERN); } if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);}
if (rootCygwin == null) { rootCygwin = getDir(aus, ROOTPATTERN);} }
} catch (FileNotFoundException e) {
} catch (IOException e) {
} catch (InterruptedException e) {
} catch (SecurityException e) {
} }
} }
} }

View file

@ -40,14 +40,11 @@ public class IsGnuCygwinToolChainSupported implements
String etcCygwin = CygwinPathResolver.getEtcPath(); String etcCygwin = CygwinPathResolver.getEtcPath();
if (etcCygwin != null) { if (etcCygwin != null) {
File file = new File(etcCygwin + "/setup/installed.db"); //$NON-NLS-1$ 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; }
// all required package names should be found
boolean[] found = new boolean[CHECKED_NAMES.length];
try { try {
BufferedReader data = new BufferedReader(new FileReader(file));
// all required package names should be found
boolean[] found = new boolean[CHECKED_NAMES.length];
String s; String s;
while ((s = data.readLine()) != null ) { while ((s = data.readLine()) != null ) {
for (int j = 0; j < CHECKED_NAMES.length; j++) { for (int j = 0; j < CHECKED_NAMES.length; j++) {
@ -59,8 +56,8 @@ public class IsGnuCygwinToolChainSupported implements
toolchainIsSupported &= found[j]; toolchainIsSupported &= found[j];
} }
data.close(); data.close();
} catch (FileNotFoundException e) {
} catch (IOException e) { } catch (IOException e) {
//TODO: log
} }
} }
return toolchainIsSupported; return toolchainIsSupported;