Skip to content

Commit

Permalink
Only print solution log for IIOException caused by "Invalid chunk len…
Browse files Browse the repository at this point in the history
…gth"

Signed-off-by: utzcoz <utzcoz@outlook.com>
  • Loading branch information
utzcoz committed Nov 17, 2021
1 parent 741e881 commit 2d3729e
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -90,14 +90,17 @@ static RobolectricBufferedImage getImageFromStream(String fileName, InputStream
reader.dispose();
}
} catch (IOException e) {
if (FORMAT_NAME_PNG.equalsIgnoreCase(format) && e instanceof IIOException) {
Throwable cause = e.getCause();
if (FORMAT_NAME_PNG.equalsIgnoreCase(format)
&& cause instanceof IIOException
&& cause.getMessage() != null
&& cause.getMessage().contains("Invalid chunk length")) {
String pngFileName = "(" + (fileName == null ? "not given PNG file name" : fileName) + ")";
System.err.println(
"Looks like your PNG file"
"The PNG file"
+ pngFileName
+ " has format problem that OpenJDK can't process correctly. You can check"
+ " https://github.com/robolectric/robolectric/issues/6812 for potential"
+ " solution.");
+ " cannot be decoded. This may be due to an OpenJDK issue with certain PNG files."
+ " See https://github.com/robolectric/robolectric/issues/6812 for more details.");
}
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 2d3729e

Please sign in to comment.