SDT - Handle IllegalArgumentException #2981
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is for an issue raised on the mailing list - http://lists.openmicroscopy.org.uk/pipermail/ome-users/2017-October/006718.html
Associated sample file: QA-18098
The problem is caused by reading the block length of the data block and attempting to skip that number of bytes. The expected result from skip bytes should be that it attempts to skip the number of bytes provided and if the end of the file is reached returns the actual number skipped (eg https://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html#skipBytes(int)). However NIOFileHandle in common throws an exception.
For compressed data the number of available bytes in the file may be less. We have other sample files of this nature (QA-11079) which similarly attempt to skip a number of bytes which do not exist, by chance these do not throw the same error though. I believe the real fix should be in NIOHandle (likely https://github.com/ome/ome-common-java/blob/43ca478d2977455c79656b12f1ad60aa39f1f86e/src/main/java/loci/common/NIOFileHandle.java#L456) however it could be worthwhile to include a fix at the format level for a patch release.
To test: