Skip to content

Commit

Permalink
Weird conditions on the disk, such as having an unformatted drive, sc…
Browse files Browse the repository at this point in the history
…rews up the eclipse autofinder on windows, causing the installer to throw an exception on bootup.

Fixed it by guarding various blocks in the detector with try/catch/ignore.

Reported by: http://groups.google.com/group/project-lombok/browse_thread/thread/2f4ded6c942ad0a5
  • Loading branch information
Reinier Zwitserloot committed Nov 1, 2009
1 parent d23591a commit 6733b1e
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/lombok/installer/EclipseFinder.java
Expand Up @@ -153,24 +153,34 @@ static List<String> findEclipseOnWindows() {
ignore.printStackTrace();
}

//Various try/catch/ignore statements are in this for loop. Weird conditions on the disk can cause exceptions,
//such as an unformatted drive causing a NullPointerException on listFiles. Best action is almost invariably to just
//continue onwards.
for (String letter : driveLetters) {
File f = new File(letter + ":\\");
for (File dir : f.listFiles()) {
if (!dir.isDirectory()) continue;
if (dir.getName().toLowerCase().contains("eclipse")) {
String eclipseLocation = findEclipseOnWindows1(dir);
if (eclipseLocation != null) eclipses.add(eclipseLocation);
}
if (dir.getName().toLowerCase().contains("program files")) {
for (File dir2 : dir.listFiles()) {
if (!dir2.isDirectory()) continue;
try {
File f = new File(letter + ":\\");
for (File dir : f.listFiles()) {
if (!dir.isDirectory()) continue;
try {
if (dir.getName().toLowerCase().contains("eclipse")) {
String eclipseLocation = findEclipseOnWindows1(dir);
if (eclipseLocation != null) eclipses.add(eclipseLocation);
}
}
} catch (Exception ignore) {}

try {
if (dir.getName().toLowerCase().contains("program files")) {
for (File dir2 : dir.listFiles()) {
if (!dir2.isDirectory()) continue;
if (dir.getName().toLowerCase().contains("eclipse")) {
String eclipseLocation = findEclipseOnWindows1(dir);
if (eclipseLocation != null) eclipses.add(eclipseLocation);
}
}
}
} catch (Exception ignore) {}
}
}
} catch (Exception ignore) {}
}

return eclipses;
Expand Down

0 comments on commit 6733b1e

Please sign in to comment.