You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2024/03/20 18:29:56 UTC
(tika) branch TIKA-4207 updated: TIKA-4207 -- small improvements to AsyncResource and WMFParser
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch TIKA-4207
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/TIKA-4207 by this push:
new 7ca6d1759 TIKA-4207 -- small improvements to AsyncResource and WMFParser
7ca6d1759 is described below
commit 7ca6d17599e60f93a653eff727d2a014f36aa471
Author: tallison <ta...@apache.org>
AuthorDate: Wed Mar 20 14:29:40 2024 -0400
TIKA-4207 -- small improvements to AsyncResource and WMFParser
---
.../java/org/apache/tika/parser/microsoft/WMFParser.java | 3 ++-
.../org/apache/tika/server/core/resource/AsyncResource.java | 13 +++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/WMFParser.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/WMFParser.java
index 73b95b58c..3c55a14b0 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/WMFParser.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/WMFParser.java
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Set;
+import org.apache.commons.io.input.CloseShieldInputStream;
import org.apache.poi.hwmf.record.HwmfFont;
import org.apache.poi.hwmf.record.HwmfRecord;
import org.apache.poi.hwmf.record.HwmfRecordType;
@@ -63,7 +64,7 @@ public class WMFParser implements Parser {
try {
HwmfPicture picture = null;
try {
- picture = new HwmfPicture(stream);
+ picture = new HwmfPicture(CloseShieldInputStream.wrap(stream));
} catch (ArrayIndexOutOfBoundsException e) {
//POI can throw this on corrupt files
throw new TikaException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/AsyncResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/AsyncResource.java
index a23162065..a4d4ed489 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/AsyncResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/AsyncResource.java
@@ -45,6 +45,7 @@ import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.metadata.serialization.JsonFetchEmitTupleList;
import org.apache.tika.pipes.FetchEmitTuple;
import org.apache.tika.pipes.async.AsyncProcessor;
+import org.apache.tika.pipes.async.OfferLargerThanQueueSize;
import org.apache.tika.pipes.emitter.EmitData;
import org.apache.tika.pipes.emitter.EmitterManager;
import org.apache.tika.pipes.fetcher.FetchKey;
@@ -117,10 +118,14 @@ public class AsyncResource {
}
}
//Instant start = Instant.now();
- boolean offered = asyncProcessor.offer(request.getTuples(), maxQueuePauseMs);
- if (offered) {
- return ok(request.getTuples().size());
- } else {
+ try {
+ boolean offered = asyncProcessor.offer(request.getTuples(), maxQueuePauseMs);
+ if (offered) {
+ return ok(request.getTuples().size());
+ } else {
+ return throttle(request.getTuples().size());
+ }
+ } catch (OfferLargerThanQueueSize e) {
return throttle(request.getTuples().size());
}
}