Skip to content

Commit 0fdd6cf

Browse files
committed
TIKA-4809: Fix needsPipesParsingHelper missing /meta after its pipes migration
1 parent f2a8c08 commit 0fdd6cf

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private static ServerDetails initServer(TikaServerConfig tikaServerConfig) throw
185185
PipesParsingHelper pipesParsingHelper = null;
186186
if (needsPipesParsingHelper(tikaServerConfig)) {
187187
pipesParsingHelper = initPipesParsingHelper(tikaServerConfig);
188-
LOG.info("Pipes-based parsing enabled for /tika, /rmeta, /unpack, and /pipes endpoints");
188+
LOG.info("Pipes-based parsing enabled for /tika, /rmeta, /unpack, /meta, and /pipes endpoints");
189189
}
190190

191191
TikaResource tikaResource = new TikaResource(tikaLoader, serverStatus, pipesParsingHelper,
@@ -456,21 +456,22 @@ private static Collection<?> loadWriterServices() {
456456

457457
/**
458458
* Determines if the shared PipesParser (wrapped in PipesParsingHelper) is needed
459-
* based on configured endpoints. It's needed when /tika, /rmeta, /unpack, or /pipes
460-
* are enabled (either explicitly or by default) -- all four now share one parser.
461-
* (Note: unlike the others, /pipes also requires allowPipes to actually start; if
462-
* it's listed without allowPipes, loadCoreProviders will refuse to start regardless
463-
* of whether this method already triggered building the shared parser.)
459+
* based on configured endpoints. It's needed when /tika, /rmeta, /unpack, /meta, or
460+
* /pipes are enabled (either explicitly or by default) -- all five now share one
461+
* parser. (Note: unlike the others, /pipes also requires allowPipes to actually
462+
* start; if it's listed without allowPipes, loadCoreProviders will refuse to start
463+
* regardless of whether this method already triggered building the shared parser.)
464464
*/
465-
private static boolean needsPipesParsingHelper(TikaServerConfig tikaServerConfig) {
465+
static boolean needsPipesParsingHelper(TikaServerConfig tikaServerConfig) {
466466
List<String> endpoints = tikaServerConfig.getEndpoints();
467467
// If no endpoints specified, all default endpoints are loaded (including
468468
// tika, rmeta, and unpack; pipes too when allowPipes is set)
469469
if (endpoints == null || endpoints.isEmpty()) {
470470
return true;
471471
}
472472
return endpoints.contains("tika") || endpoints.contains("rmeta")
473-
|| endpoints.contains("unpack") || endpoints.contains("pipes");
473+
|| endpoints.contains("unpack") || endpoints.contains("pipes")
474+
|| endpoints.contains("meta");
474475
}
475476

476477
/**

tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerProcessTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package org.apache.tika.server.core;
1818

1919
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
2021
import static org.junit.jupiter.api.Assertions.assertThrows;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2123

2224
import java.util.ArrayList;
2325
import java.util.List;
@@ -51,4 +53,13 @@ public void ordinaryEndpointIsAllowedWithoutAllowPipes() {
5153
assertDoesNotThrow(
5254
() -> TikaServerProcess.loadCoreProviders(config(false, "meta"), null, null));
5355
}
56+
57+
@Test
58+
public void metaAloneNeedsPipesParsingHelper() {
59+
// /meta is now pipes-backed too; a config listing only "meta" (no tika/rmeta/
60+
// unpack/pipes) must still build the shared PipesParser, or every /meta request
61+
// hits IllegalStateException("Pipes-based parsing is not enabled").
62+
assertTrue(TikaServerProcess.needsPipesParsingHelper(config(false, "meta")));
63+
assertFalse(TikaServerProcess.needsPipesParsingHelper(config(false, "status")));
64+
}
5465
}

0 commit comments

Comments
 (0)