This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch TIKA-4793-fixes in repository https://gitbox.apache.org/repos/asf/tika.git
commit 89b8bd962575c0298b54b6946da4d8d673ffdef9 Author: tallison <[email protected]> AuthorDate: Thu Aug 13 15:08:21 2026 -0400 rm patch --- pr3009-followup.patch | 131 -------------------------------------------------- 1 file changed, 131 deletions(-) diff --git a/pr3009-followup.patch b/pr3009-followup.patch deleted file mode 100644 index bee05686e9..0000000000 --- a/pr3009-followup.patch +++ /dev/null @@ -1,131 +0,0 @@ -diff --git a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java -index 5b8186741..7c9739adf 100644 ---- a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java -+++ b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java -@@ -182,13 +182,18 @@ public class ConnectionHandler implements Runnable, Closeable { - handleCrash(PipesMessageType.UNSPECIFIED_CRASH, fetchEmitTuple.getId(), e); - } catch (Throwable t) { - if (t instanceof Error) { -- // OOM or other JVM-level error: don't trust the heap; exit immediately. -- LOG.error("handlerId={}: fatal JVM error; exiting", handlerId, t); -+ // OOM or other JVM-level error: don't trust the heap; exit -+ // immediately. Everything before the exit is best-effort and -+ // inside the try -- a secondary OOM in logging or writeCrash -+ // must not escape and leave this shared JVM alive post-Error. - try { -+ LOG.error("handlerId={}: fatal JVM error; exiting", handlerId, t); - protocolIO.writeCrash(PipesMessageType.OOM, t); - } catch (Throwable ignored) { -+ //swallow -+ } finally { -+ System.exit(PipesMessageType.OOM.getExitCode().orElse(18)); - } -- System.exit(PipesMessageType.OOM.getExitCode().orElse(18)); - } - // respond, or the client blocks until socket timeout and - // restarts a healthy server -diff --git a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ServerProtocolIO.java b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ServerProtocolIO.java -index eadb85cba..e94407d1c 100644 ---- a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ServerProtocolIO.java -+++ b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ServerProtocolIO.java -@@ -118,13 +118,14 @@ public class ServerProtocolIO { - LOG.warn("Payload exceeded maxIpcPayloadBytes {}; returning PAYLOAD_LIMIT_EXCEEDED", - maxIpcPayloadBytes); - // If content was already emitted server-side, preserve that status so the -- // client does not duplicate the emission on the passback path. -- if (pipesResult.status() == PipesResult.RESULT_STATUS.EMIT_SUCCESS_PASSBACK) { -+ // client does not duplicate the emission on the passback path. The fixed -+ // message replaces the original, which may itself be the overflow source -+ // (an accumulated parse-exception stack). -+ if (alreadyEmitted(pipesResult.status())) { - BoundedOutputStream fallbackBos = new BoundedOutputStream(maxIpcPayloadBytes); - try { - JsonPipesIpc.toStream( -- new PipesResult(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PASSBACK, -- "payload_limit_exceeded"), -+ new PipesResult(pipesResult.status(), "payload_limit_exceeded"), - fallbackBos); - PipesMessage.finished(fallbackBos.toByteArray()).write(output); - awaitAck(); -@@ -133,8 +134,8 @@ public class ServerProtocolIO { - if (!fallbackBos.overflowed()) { - throw fallbackE; - } -- // Even status-only EMIT_SUCCESS_PASSBACK overflows — fall through to -- // the guaranteed-fit static fallback. -+ // Even the status-only result overflows — fall through to the -+ // guaranteed-fit static fallback. - } - } - doWritePayloadLimitExceeded(); -@@ -144,6 +145,17 @@ public class ServerProtocolIO { - awaitAck(); - } - -+ /** -+ * True for statuses whose content the server already emitted. Replacing one of these -+ * with a failure status makes the client treat an emitted document as failed, so a -+ * retry emits it a second time. -+ */ -+ private static boolean alreadyEmitted(PipesResult.RESULT_STATUS status) { -+ return status == PipesResult.RESULT_STATUS.EMIT_SUCCESS || -+ status == PipesResult.RESULT_STATUS.EMIT_SUCCESS_PASSBACK || -+ status == PipesResult.RESULT_STATUS.EMIT_SUCCESS_PARSE_EXCEPTION; -+ } -+ - private void doWritePayloadLimitExceeded() throws IOException { - // FALLBACK_PAYLOAD_BYTES is pre-computed at class load and guaranteed to be smaller - // than maxIpcPayloadBytes (enforced by the constructor), so the client always accepts it. -diff --git a/tika-pipes/tika-pipes-core/src/test/java/org/apache/tika/pipes/core/server/ServerProtocolIOTest.java b/tika-pipes/tika-pipes-core/src/test/java/org/apache/tika/pipes/core/server/ServerProtocolIOTest.java -index d61802a31..016f630ee 100644 ---- a/tika-pipes/tika-pipes-core/src/test/java/org/apache/tika/pipes/core/server/ServerProtocolIOTest.java -+++ b/tika-pipes/tika-pipes-core/src/test/java/org/apache/tika/pipes/core/server/ServerProtocolIOTest.java -@@ -244,6 +244,48 @@ class ServerProtocolIOTest { - assertEquals(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PASSBACK, returned.status()); - } - -+ /** -+ * EMIT_SUCCESS_PARSE_EXCEPTION also means the content was already emitted server-side, -+ * so an overflow must not downgrade it to a failure status -- that would make the -+ * client record an emitted document as failed and a retry would emit it twice. -+ */ -+ @Test -+ void testEmitSuccessParseExceptionStatusPreservedOnOverflow() throws Exception { -+ Metadata m = new Metadata(); -+ m.add("content", "x".repeat(10_000)); -+ PipesResult result = -+ new PipesResult(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PARSE_EXCEPTION, -+ new EmitDataImpl("key", List.of(m))); -+ -+ int limit = 512; -+ assertTrue(JsonPipesIpc.toBytes(result).length > limit, -+ "test setup: serialized content must exceed limit"); -+ -+ PipesResult returned = exchange(result, limit); -+ -+ assertEquals(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PARSE_EXCEPTION, returned.status()); -+ } -+ -+ /** -+ * The overflow can be the message itself -- EmitHandler accumulates parse-exception -+ * stacks into it -- so the status-preserving retry must replace the message, not -+ * carry it over. -+ */ -+ @Test -+ void testOversizedMessageOnAlreadyEmittedStatusPreservesStatus() throws Exception { -+ PipesResult result = -+ new PipesResult(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PARSE_EXCEPTION, -+ "stack".repeat(5_000)); -+ -+ int limit = 512; -+ assertTrue(JsonPipesIpc.toBytes(result).length > limit, -+ "test setup: serialized message must exceed limit"); -+ -+ PipesResult returned = exchange(result, limit); -+ -+ assertEquals(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PARSE_EXCEPTION, returned.status()); -+ } -+ - // ---- writeCrash tests ---- - - /**
