New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageIO fails reading random PNG file during tests #9228

Closed
miffels opened this Issue Sep 7, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@miffels

miffels commented Sep 7, 2015

Hi all,

After updating from Grails 3.0.2 to 3.0.5 I have had a breaking test that used to work before - it involves reading a PNG file from the local file system. I can read the file just fine from a regular Java as well as from the Grails console, so I figure this is somehow related to the Grails test context.

$ grails -version
| Grails Version: 3.0.2
| Groovy Version: 2.4.3
| JVM Version: 1.8.0_45
$ pngcheck default.png
OK: default.png (800x600, 32-bit RGB+alpha, non-interlaced, 99.7%).

Let's check in the console:

$ grails console
[...]
import javax.imageio.ImageIO

ImageIO.read(getClass().getResourceAsStream("/default.png"))

So this looks fine - until I try reading it from a test case:

$ grails test-app -unit
[...]
javax.imageio.IIOException: Error reading PNG image data
    at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1337)
    at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1606)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1352)
    at imageio.png.ImageIoSpec.test(ImageIoSpec.groovy:23)
Caused by: java.util.zip.ZipException: invalid literal/lengths set
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
    at java.io.FilterInputStream.read(FilterInputStream.java:83)
    at com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.java:1104)
    at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader.java:1215)
    at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1330)
    ... 4 more

You can find an SSCCE here.

Best,
Michael

@graemerocher

This comment has been minimized.

Show comment
Hide comment
@graemerocher

graemerocher Sep 7, 2015

Member

The test passes locally for me using the example provided.

Member

graemerocher commented Sep 7, 2015

The test passes locally for me using the example provided.

@miffels

This comment has been minimized.

Show comment
Hide comment
@miffels

miffels Sep 7, 2015

Oh, this is odd. Very odd. I tried to reproduce it on another machine and it passes for me as well. I wonder what might be influencing the test then? I am experiencing it in two separate projects, whereas it does not occur in the console or in plain Java. I think we can close this, but if you happen to have the slightest idea what I might want to try to fix this, I am more than open for suggestions ;)

miffels commented Sep 7, 2015

Oh, this is odd. Very odd. I tried to reproduce it on another machine and it passes for me as well. I wonder what might be influencing the test then? I am experiencing it in two separate projects, whereas it does not occur in the console or in plain Java. I think we can close this, but if you happen to have the slightest idea what I might want to try to fix this, I am more than open for suggestions ;)

@miffels

This comment has been minimized.

Show comment
Hide comment
@miffels

miffels Sep 8, 2015

Oh well, after updating Java, clearing the gradle cache and bumping the Grails version to 3.0.5 the error persisted.

It seems like having several meetings and not touching things for an hour or two resolved it, after having had this issue for a couple of weeks. I'll have to add this to my standard tool belt, directly after "restarting" , "clean build", "reinstalling" and "try the same, but shuffle the steps". 💢

miffels commented Sep 8, 2015

Oh well, after updating Java, clearing the gradle cache and bumping the Grails version to 3.0.5 the error persisted.

It seems like having several meetings and not touching things for an hour or two resolved it, after having had this issue for a couple of weeks. I'll have to add this to my standard tool belt, directly after "restarting" , "clean build", "reinstalling" and "try the same, but shuffle the steps". 💢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment