Skip to content

Commit 833fd93

Browse files
author
taylor.smock
committed
Fix #23866: java.io.UncheckedIOException: java.nio.file.FileSystemException: The device is not ready
This does two things: 1. Unwrap an unchecked exception in ImagesLoader so that we are throwing a checked exception 2. Explain some IO exceptions (specifically "the device is not ready") This is not the "best" solution, but it ''should'' mean that we are not ignoring issues related to JOSM. git-svn-id: https://josm.openstreetmap.de/svn/trunk@19216 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent 86382f4 commit 833fd93

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.net.HttpURLConnection;
1010
import java.net.SocketException;
1111
import java.net.UnknownHostException;
12+
import java.nio.file.FileSystemException;
1213
import java.util.regex.Matcher;
1314
import java.util.regex.Pattern;
1415

@@ -143,6 +144,19 @@ public static void explainNestedIOException(OsmTransferException e) {
143144
);
144145
}
145146

147+
/**
148+
* Explains a {@link IOException}
149+
*
150+
* @param e the exception
151+
*/
152+
private static void explainIOException(Exception e) {
153+
if (e instanceof FileSystemException && e.getMessage().contains("The device is not ready")) {
154+
showErrorDialog(ExceptionUtil.explainException(e), tr("File System Exception"), null);
155+
} else {
156+
explainGeneric(e);
157+
}
158+
}
159+
146160
/**
147161
* Explains a {@link IllegalDataException} which has caused an {@link OsmTransferException}.
148162
* This is most likely happening when JOSM tries to load data in an unsupported format.
@@ -492,6 +506,11 @@ public static void explainException(Exception e) {
492506
explainOsmTransferException((OsmTransferException) e);
493507
return;
494508
}
509+
FileSystemException fileSystemException = ExceptionUtil.getNestedException(e, FileSystemException.class);
510+
if (fileSystemException != null) {
511+
explainIOException(fileSystemException);
512+
return;
513+
}
495514
explainGeneric(e);
496515
}
497516
}

src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.File;
77
import java.io.IOException;
8+
import java.io.UncheckedIOException;
89
import java.util.ArrayList;
910
import java.util.Arrays;
1011
import java.util.Collection;
@@ -90,7 +91,14 @@ protected void realRun() throws IOException {
9091
progressMonitor.worked(1);
9192

9293
ImageEntry e = new ImageEntry(f);
93-
e.extractExif();
94+
try {
95+
e.extractExif();
96+
} catch (UncheckedIOException uncheckedIOException) {
97+
// We want to throw the actual IOException that is wrapped, not the unchecked IO exception.
98+
// See #23866
99+
Logging.trace(uncheckedIOException);
100+
throw uncheckedIOException.getCause();
101+
}
94102
File parentFile = f.getParentFile();
95103
entries.computeIfAbsent(parentFile != null ? parentFile.getName() : "", x -> new ArrayList<>()).add(e);
96104
}

0 commit comments

Comments
 (0)