[
https://issues.apache.org/jira/browse/TIKA-4878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18117030#comment-18117030
]
ASF GitHub Bot commented on TIKA-4878:
--------------------------------------
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.
> Re-open embedded content instead of caching it when the parser can re-read
> the source
> -------------------------------------------------------------------------------------
>
> Key: TIKA-4878
> URL: https://issues.apache.org/jira/browse/TIKA-4878
> Project: Tika
> Issue Type: Task
> Reporter: Tim Allison
> Priority: Minor
> Fix For: 4.1.0
>
>
> For embedded streams that can point to locations on an existing file, don't
> spool separate tmp files.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)