tballison commented on code in PR #3209:
URL: https://github.com/apache/tika/pull/3209#discussion_r4053102765
##########
tika-core/src/main/java/org/apache/tika/io/ReopenableSource.java:
##########
@@ -363,16 +368,36 @@ public void close() throws IOException {
}
}
+ /**
+ * A mark is kept in the open stream's buffer, so a reset within {@code
readlimit} costs
+ * nothing. Re-opening on every reset is what a reader that marks and
resets per record (POI
+ * reading a metafile's bitmaps) turned into inflating a zip entry
thousands of times.
+ */
@Override
public synchronized void mark(int readlimit) {
markPosition = position;
+ markInStream = false;
+ if (currentStream != null && retainedBuffer == null) {
+ // the buffer grows to honour a mark; past the cap a reset
re-opens instead
+ currentStream.mark(Math.min(readlimit, MAX_BUFFERED_MARK));
+ markInStream = true;
+ }
}
@Override
public synchronized void reset() throws IOException {
if (markPosition < 0) {
throw new IOException("Mark not set");
}
+ if (markInStream && currentStream != null) {
+ try {
+ currentStream.reset();
+ position = markPosition;
Review Comment:
Important finding. Fix incoming.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]