Changeset 19216 in josm for trunk/src/org


Ignore:
Timestamp:
2024-09-09T19:25:48+02:00 (2 months ago)
Author:
taylor.smock
Message:

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.

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java

    r18802 r19216  
    1010import java.net.SocketException;
    1111import java.net.UnknownHostException;
     12import java.nio.file.FileSystemException;
    1213import java.util.regex.Matcher;
    1314import java.util.regex.Pattern;
     
    142143                ht("/ErrorMessages#NestedIOException")
    143144        );
     145    }
     146
     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        }
    144158    }
    145159
     
    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    }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java

    r18248 r19216  
    66import java.io.File;
    77import java.io.IOException;
     8import java.io.UncheckedIOException;
    89import java.util.ArrayList;
    910import java.util.Arrays;
     
    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);
Note: See TracChangeset for help on using the changeset viewer.