Skip to content
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

Handling Corrupt Tile Cache #1043

Closed
JackPGreen opened this issue Mar 10, 2018 · 3 comments
Closed

Handling Corrupt Tile Cache #1043

JackPGreen opened this issue Mar 10, 2018 · 3 comments
Labels

Comments

@JackPGreen
Copy link

I ran out of disk space while in the middle of caching a tile, which caused the cached tile to become corrupted (which is fine).

When I then tried to retrieve the tile from the cache, I get the following error (below).

The problem is that that this error isn't thrown - it's caught and printed to the console internally in Mapsforge.

In addition, with a regular tile cache setup, because the tilecache contains a value for this job (even though it's corrupt), it's never replaced.

I think the default behaviour should not be to print exceptions to the console, and if this error occurs then it should be rethrown and the corrupt tile removed from the cache.

java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off+len > b.length || off+len < 0!
at javax.imageio.stream.FileCacheImageInputStream.read(FileCacheImageInputStream.java:177)
at com.sun.imageio.plugins.common.SubImageInputStream.read(SubImageInputStream.java:61)
at com.sun.imageio.plugins.common.InputStreamAdapter.read(InputStreamAdapter.java:47)
at java.io.SequenceInputStream.read(SequenceInputStream.java:208)
at java.io.SequenceInputStream.read(SequenceInputStream.java:211)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at java.io.DataInputStream.readFully(DataInputStream.java:195)
at com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.java:1092)
at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader.java:1196)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1301)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1577)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
at javax.imageio.ImageIO.read(ImageIO.java:1352)
at org.mapsforge.map.awt.graphics.AwtBitmap.(AwtBitmap.java:36)
at org.mapsforge.map.awt.graphics.AwtTileBitmap.(AwtTileBitmap.java:33)
at org.mapsforge.map.awt.graphics.AwtGraphicFactory.createTileBitmap(AwtGraphicFactory.java:203)
at org.mapsforge.map.layer.cache.FileSystemTileCache.get(FileSystemTileCache.java:254)

@devemux86
Copy link
Collaborator

A re-throw can crash the app, should be handled internally there like mentioned by clearing any bad one and request again the tile.
Though looking at FileSystemTileCache in case of errors the job is removed and return null to trigger a reload of the tile.

@JackPGreen
Copy link
Author

For reference this was with 0.9.1

@devemux86 devemux86 added the bug label Apr 14, 2018
@devemux86 devemux86 added question and removed bug labels Aug 1, 2019
@devemux86
Copy link
Collaborator

Can discuss in forum and if there is interest from community to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants