TMI-107: JPEGSegmentImageInputStream now recovers from EOFException while parsing segments.

This commit is contained in:
Harald Kuhr
2015-03-07 21:41:38 +01:00
parent 34efe84e5a
commit 2b2dd2fb40
3 changed files with 44 additions and 6 deletions

View File

@@ -74,7 +74,9 @@ final class JPEGSegmentImageInputStream extends ImageInputStreamImpl {
if (streamPos >= segment.end()) {
// Go forward in cache
while (++currentSegment < segments.size()) {
int cachedSegment = currentSegment;
while (++cachedSegment < segments.size()) {
currentSegment = cachedSegment;
segment = segments.get(currentSegment);
if (streamPos >= segment.start && streamPos < segment.end()) {
@@ -157,7 +159,9 @@ final class JPEGSegmentImageInputStream extends ImageInputStreamImpl {
}
else if (streamPos < segment.start) {
// Go back in cache
while (--currentSegment >= 0) {
int cachedSegment = currentSegment;
while (--cachedSegment >= 0) {
currentSegment = cachedSegment;
segment = segments.get(currentSegment);
if (streamPos >= segment.start && streamPos < segment.end()) {