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 2026/08/10 16:32:33 UTC
(tika) 02/04: TIKA-4809: Remove the maxEmbeddedResources/maxEmbeddedCount headers
This is an automated email from the ASF dual-hosted git repository.
tballison pushed a commit to branch TIKA-4809-stage-4
in repository https://gitbox.apache.org/repos/asf/tika.git
commit b0a24fee570f04a8db62e81155eefee2d3125a10
Author: tallison <ta...@apache.org>
AuthorDate: Sun Aug 9 20:35:55 2026 -0400
TIKA-4809: Remove the maxEmbeddedResources/maxEmbeddedCount headers
---
.../core/resource/RecursiveMetadataResource.java | 40 +++++-----------------
.../server/core/resource/ServerHandlerConfig.java | 35 -------------------
.../standard/RecursiveMetadataResourceTest.java | 3 --
3 files changed, 8 insertions(+), 70 deletions(-)
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
index 762b8ab0ab..554f513c96 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
@@ -37,7 +37,6 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.tika.config.EmbeddedLimits;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
@@ -64,7 +63,7 @@ public class RecursiveMetadataResource {
*/
public List<Metadata> parseMetadata(TikaInputStream tis, Metadata metadata,
MultivaluedMap<String, String> httpHeaders,
- ServerHandlerConfig handlerConfig)
+ String handlerTypeName)
throws Exception {
final ParseContext context = tikaResource.createParseContext();
@@ -72,32 +71,12 @@ public class RecursiveMetadataResource {
fillMetadata(null, metadata, httpHeaders);
TikaResource.logRequest(LOG, "/rmeta", metadata);
- // Set up handler factory in context using shared utility
- setupContentHandlerFactory(context, handlerConfig.type().toString());
-
- // Set up embedded limits if specified
- if (handlerConfig.maxEmbeddedCount() >= 0) {
- EmbeddedLimits limits = new EmbeddedLimits();
- limits.setMaxCount(handlerConfig.maxEmbeddedCount());
- context.set(EmbeddedLimits.class, limits);
- }
+ setupContentHandlerFactory(context, handlerTypeName);
// Filtering is done in child process, no need to filter again
return tikaResource.parseWithPipes(tis, metadata, context, ParseMode.RMETA);
}
- static ServerHandlerConfig buildHandlerConfig(MultivaluedMap<String, String> httpHeaders, String handlerTypeName, ParseMode parseMode) {
- int maxEmbeddedCount = -1;
- // Support both old header name and new for backwards compatibility
- if (httpHeaders.containsKey("maxEmbeddedResources")) {
- maxEmbeddedCount = Integer.parseInt(httpHeaders.getFirst("maxEmbeddedResources"));
- } else if (httpHeaders.containsKey("maxEmbeddedCount")) {
- maxEmbeddedCount = Integer.parseInt(httpHeaders.getFirst("maxEmbeddedCount"));
- }
- return new ServerHandlerConfig(BasicContentHandlerFactory.parseHandlerType(handlerTypeName, DEFAULT_HANDLER_TYPE),
- parseMode, maxEmbeddedCount);
- }
-
/**
* Returns an InputStream that can be deserialized as a list of
* {@link Metadata} objects.
@@ -132,7 +111,7 @@ public class RecursiveMetadataResource {
try (TikaInputStream tis = TikaInputStream.get(att.getObject(InputStream.class))) {
tis.getPath(); // Spool to temp file for pipes-based parsing
List<Metadata> metadataList = parseMetadata(tis, Metadata.newInstance(context), att.getHeaders(),
- buildHandlerConfig(att.getHeaders(), handlerTypeName, ParseMode.RMETA));
+ handlerTypeName);
return Response.ok(new MetadataList(metadataList)).build();
}
}
@@ -157,17 +136,14 @@ public class RecursiveMetadataResource {
TikaResource.logRequest(LOG, "/rmeta/config", metadata);
return Response
- .ok(parseMetadataWithContext(tis, metadata, httpHeaders.getRequestHeaders(),
- buildHandlerConfig(httpHeaders.getRequestHeaders(), null, ParseMode.RMETA),
- context))
+ .ok(parseMetadataWithContext(tis, metadata, null, context))
.build();
}
}
- private MetadataList parseMetadataWithContext(TikaInputStream tis, Metadata metadata, MultivaluedMap<String, String> httpHeaders,
- ServerHandlerConfig handlerConfig, ParseContext context) throws Exception {
- // Set up handler factory in context if not already set using shared utility
- setupContentHandlerFactoryIfNeeded(context, handlerConfig.type().toString());
+ private MetadataList parseMetadataWithContext(TikaInputStream tis, Metadata metadata,
+ String handlerTypeName, ParseContext context) throws Exception {
+ setupContentHandlerFactoryIfNeeded(context, handlerTypeName);
// Filtering is done in child process, no need to filter again
List<Metadata> metadataList = tikaResource.parseWithPipes(tis, metadata, context, ParseMode.RMETA);
@@ -207,7 +183,7 @@ public class RecursiveMetadataResource {
try (TikaInputStream tis = TikaInputStream.get(is)) {
tis.getPath(); // Spool to temp file for pipes-based parsing
List<Metadata> metadataList = parseMetadata(tis, metadata, httpHeaders.getRequestHeaders(),
- buildHandlerConfig(httpHeaders.getRequestHeaders(), handlerTypeName, ParseMode.RMETA));
+ handlerTypeName);
return Response.ok(new MetadataList(metadataList)).build();
}
}
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/ServerHandlerConfig.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/ServerHandlerConfig.java
deleted file mode 100644
index 5187563d95..0000000000
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/ServerHandlerConfig.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.server.core.resource;
-
-import org.apache.tika.pipes.api.ParseMode;
-import org.apache.tika.sax.BasicContentHandlerFactory;
-
-/**
- * Server-internal configuration for request handlers.
- * This holds configuration parsed from HTTP headers for a single request
- * for the BasicContentHandlerFactory kinds of elements.
- * <p>
- * Note: Embedded resource limits are now configured via EmbeddedLimits in ParseContext,
- * not through this config.
- */
-public record ServerHandlerConfig(
- BasicContentHandlerFactory.HANDLER_TYPE type,
- ParseMode parseMode,
- int maxEmbeddedCount
-) {
-}
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
index 025c4593c1..de3605813e 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
@@ -469,9 +469,6 @@ public class RecursiveMetadataResourceTest extends CXFTestBase {
assertContains("plundered our seas", content);
}
- // TIKA-3227 - TODO: re-enable once maxEmbeddedResources is configurable via JSON
- // Use maxEmbeddedResources=0 in config to skip embedded documents
-
@Test
public void testXFA() throws Exception {
Response response = WebClient