You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by mi...@apache.org on 2026/08/27 07:55:48 UTC

(jmeter) branch master updated: Migrate to Apache Tika 4.0.0 (#6754)

This is an automated email from the ASF dual-hosted git repository.

milamberspace pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 9457d7215a Migrate to Apache Tika 4.0.0 (#6754)
9457d7215a is described below

commit 9457d7215a57826fa3ec3c2f2108fe0b54384a1a
Author: Milamber <mi...@apache.org>
AuthorDate: Thu Aug 27 10:55:42 2026 +0300

    Migrate to Apache Tika 4.0.0 (#6754)
    
    Bump tika-core to 4.0.0 and drop the no-op tika-parsers aggregator
    (packaging=pom, non-transitive: it shipped no jar and only pulled
    extra BOMs into dependency verification).
    
    Replace the removed TikaConfig with a plain Tika() for MIME detection
    in HTTPFileArg and ParseCurlCommandAction, and delete the now-unused
    tika-config.xml. Wrap the Parser.parse input in TikaInputStream in
    Document, as the Parser interface now requires it in 4.x.
    
    Add trusted keys for the BOMs imported by tika-core's parent POM
    (com.azure, io.grpc, org.eclipse.jetty, org.testcontainers) and update
    the expected release jar entry to tika-core-4.0.0.jar.
    
    Reflect the bump in the 6.0.0 "Non-functional changes" changelog entry
    (the dev cycle already moved 1.x -> 3.x; update it to 4.x).
    
    Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
---
 gradle/verification-metadata.xml                    |  4 ++++
 src/bom-thirdparty/build.gradle.kts                 |  3 +--
 .../main/java/org/apache/jmeter/util/Document.java  |  5 ++---
 src/dist/src/dist/expected_release_jars.csv         |  2 +-
 src/protocol/http/build.gradle.kts                  |  7 ++-----
 .../http/gui/action/ParseCurlCommandAction.java     | 14 +-------------
 .../jmeter/protocol/http/util/HTTPFileArg.java      | 14 +-------------
 .../jmeter/protocol/http/gui/action/tika-config.xml | 21 ---------------------
 xdocs/changes.xml                                   |  2 +-
 9 files changed, 13 insertions(+), 59 deletions(-)

diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 69fb2e633d..eedbce6676 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -129,8 +129,10 @@
          <trusted-key id="6BFAB2E3C6490B421B25C76C9C8C892F91F8E6D1" group="org.apache.rat"/>
          <trusted-key id="6CB87B18A453990EAC9453F87D713008CC07E9AD" group="xerces"/>
          <trusted-key id="6E13156C0EE653F0B984663AB95BBD3FA43C4492" group="org.apache"/>
+         <trusted-key id="6E7F910017655622A899639EE7D88DB8427DE651" group="org.testcontainers"/>
          <trusted-key id="6F538074CCEBF35F28AF9B066A0975F8B1127B83" group="org.jetbrains.kotlin"/>
          <trusted-key id="6FF955169D698CC09BA7403AC99BFE8CD562EAC1" group="com.github.autostyle"/>
+         <trusted-key id="716EE302674CDBB2E660E1B44DB5EA09F2E3C800" group="org.eclipse.jetty"/>
          <trusted-key id="7186BBF993566D8C2F4F7ED7D945E643368FEF62" group="io.github.eisop"/>
          <trusted-key id="7616EB882DAF57A11477AAF559A252FB1199D873" group="com.google.code.findbugs"/>
          <trusted-key id="764BE739DDAE10F4473FECF0AEF385ED6CA815AE" group="com.miglayout"/>
@@ -167,6 +169,7 @@
          <trusted-key id="AEB1E1AEC035C66FA39589D13EFC46EE83C40224" group="com.networknt"/>
          <trusted-key id="AF7512AF66FE4004D84DEC8A04C8C902FEFB1A01" group="io.mockk"/>
          <trusted-key id="B02137D875D833D9B23392ECAE5A7FB608A0221C" group="org.codehaus.plexus"/>
+         <trusted-key id="B02335AA54CCF21E52BBF9ABD9C565AA72BA2FDD" group="io.grpc"/>
          <trusted-key id="B0255B26003EF6F82491ACD7254E9C64C264C176" group="com.github.weisj"/>
          <trusted-key id="B18679A17A21DE79FF9DE8B0636D10E7975B6E6F" group="com.ethlo.time"/>
          <trusted-key id="B5569A15406AE682380F3EF8528DC75AA68F0923" group="jcharts"/>
@@ -175,6 +178,7 @@
             <trusting group="org.apache.commons"/>
          </trusted-key>
          <trusted-key id="BDB5FA4FE719D787FB3D3197F6D4A1D411E9D1AE" group="^com[.]google($|([.].*))" regex="true"/>
+         <trusted-key id="BF273975F5851E0DDE3ABB7D8D5DB0BAA89FE87B" group="com.azure"/>
          <trusted-key id="C3259D20DAEC4ACE6D57CC83340B090F727518D8" group="com.google.j2objc"/>
          <trusted-key id="C62C0CE2E5C346B2D9BF2D8BB2CA0DFE9ED21C6E" group="io.burt"/>
          <trusted-key id="C668130C58722C9DC1C0FC633F1EB974E7AB9B37" group="biz.aQute.bnd"/>
diff --git a/src/bom-thirdparty/build.gradle.kts b/src/bom-thirdparty/build.gradle.kts
index ffd0b4073f..ea87db3f27 100644
--- a/src/bom-thirdparty/build.gradle.kts
+++ b/src/bom-thirdparty/build.gradle.kts
@@ -117,8 +117,7 @@ dependencies {
         api("org.apache.logging.log4j:log4j-core:2.26.0")
         api("org.apache.logging.log4j:log4j-slf4j2-impl:2.26.0")
         api("org.apache.rat:apache-rat:0.17")
-        api("org.apache.tika:tika-core:3.2.3")
-        api("org.apache.tika:tika-parsers:3.2.3")
+        api("org.apache.tika:tika-core:4.0.0")
         api("org.apache.velocity:velocity:1.7")
         api("org.apache.xmlgraphics:xmlgraphics-commons:2.11")
         api("org.apiguardian:apiguardian-api:1.1.2")
diff --git a/src/core/src/main/java/org/apache/jmeter/util/Document.java b/src/core/src/main/java/org/apache/jmeter/util/Document.java
index 7b0ca1059e..ed9c520afc 100644
--- a/src/core/src/main/java/org/apache/jmeter/util/Document.java
+++ b/src/core/src/main/java/org/apache/jmeter/util/Document.java
@@ -17,10 +17,9 @@
 
 package org.apache.jmeter.util;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
+import org.apache.tika.io.TikaInputStream;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.parser.AutoDetectParser;
 import org.apache.tika.parser.ParseContext;
@@ -53,7 +52,7 @@ public class Document {
         ContentHandler handler = new BodyContentHandler(MAX_DOCUMENT_SIZE > 0 ? MAX_DOCUMENT_SIZE : -1); // -1 to disable the write limit
         Metadata metadata = new Metadata();
         ParseContext context = new ParseContext();
-        InputStream stream = new ByteArrayInputStream(document); // open the stream
+        TikaInputStream stream = TikaInputStream.get(document); // open the stream
         try {
             parser.parse(stream, handler, metadata, context);
             response = handler.toString();
diff --git a/src/dist/src/dist/expected_release_jars.csv b/src/dist/src/dist/expected_release_jars.csv
index 12ef9a5b9e..7a1135db88 100644
--- a/src/dist/src/dist/expected_release_jars.csv
+++ b/src/dist/src/dist/expected_release_jars.csv
@@ -152,7 +152,7 @@
 195922,stax2-api-4.2.2.jar
 10192,swing-extensions-laf-support-0.1.3.jar
 2539,swing-extensions-visual-padding-0.1.3.jar
-778543,tika-core-3.2.3.jar
+664580,tika-core-4.0.0.jar
 73265,txw2-4.0.6.jar
 173935,unbescape-1.1.6.RELEASE.jar
 1612256,woodstox-core-7.1.1.jar
diff --git a/src/protocol/http/build.gradle.kts b/src/protocol/http/build.gradle.kts
index af6b3482f5..2a6c3ffd46 100644
--- a/src/protocol/http/build.gradle.kts
+++ b/src/protocol/http/build.gradle.kts
@@ -70,12 +70,9 @@ dependencies {
     testImplementation(testFixtures(projects.src.core))
     testImplementation(testFixtures(projects.src.testkitWiremock))
     testImplementation("org.wiremock:wiremock")
-    // For some reason JMeter bundles just tika-core and tika-parsers without transitive
-    // dependencies. So we exclude those
+    // JMeter bundles just tika-core (without transitive dependencies) for MIME-type
+    // detection. Document parsing relies on a user-supplied tika-app.jar at runtime.
     implementation("org.apache.tika:tika-core") {
         isTransitive = false
     }
-    runtimeOnly("org.apache.tika:tika-parsers") {
-        isTransitive = false
-    }
 }
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseCurlCommandAction.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseCurlCommandAction.java
index 5e78a1a0c5..4862413405 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseCurlCommandAction.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseCurlCommandAction.java
@@ -105,11 +105,8 @@ import org.apache.jorphan.gui.ComponentUtil;
 import org.apache.jorphan.gui.JMeterUIDefaults;
 import org.apache.jorphan.util.StringUtilities;
 import org.apache.tika.Tika;
-import org.apache.tika.config.TikaConfig;
-import org.apache.tika.exception.TikaException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.xml.sax.SAXException;
 
 import com.google.auto.service.AutoService;
 
@@ -138,16 +135,7 @@ public class ParseCurlCommandAction extends AbstractAction implements MenuCreato
     private JSyntaxTextArea cURLCommandTA;
     private JLabel statusText;
     private JCheckBox uploadCookiesCheckBox;
-    private final Tika tika = createTika();
-
-    private Tika createTika() {
-        try {
-            return new Tika(new TikaConfig(this.getClass().getClassLoader()
-                    .getResourceAsStream("org/apache/jmeter/protocol/http/gui/action/tika-config.xml")));
-        } catch (TikaException | IOException | SAXException e) {
-            return new Tika();
-        }
-    }
+    private final Tika tika = new Tika();
 
     public ParseCurlCommandAction() {
         super();
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPFileArg.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPFileArg.java
index bf38e101cd..9b4921978f 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPFileArg.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPFileArg.java
@@ -28,9 +28,6 @@ import org.apache.jmeter.testelement.schema.PropertiesAccessor;
 import org.apache.jmeter.testelement.schema.PropertyDescriptor;
 import org.apache.jorphan.util.StringUtilities;
 import org.apache.tika.Tika;
-import org.apache.tika.config.TikaConfig;
-import org.apache.tika.exception.TikaException;
-import org.xml.sax.SAXException;
 
 /**
  * Class representing a file parameter for http upload.
@@ -46,7 +43,7 @@ public class HTTPFileArg extends AbstractTestElement implements Serializable {
     /** temporary storage area for the body header. */
     private String header;
 
-    private static final Tika tika = createTika();
+    private static final Tika tika = new Tika();
 
     /**
      * Constructor for an empty HTTPFileArg object
@@ -87,15 +84,6 @@ public class HTTPFileArg extends AbstractTestElement implements Serializable {
         setMimeType(detectMimeType(path, mimetype));
     }
 
-    private static Tika createTika() {
-        try {
-            return new Tika(new TikaConfig(HTTPFileArg.class.getClassLoader()
-                    .getResourceAsStream("org/apache/jmeter/protocol/http/gui/action/tika-config.xml")));
-        } catch (TikaException | IOException | SAXException e) {
-            return new Tika();
-        }
-    }
-
     private static String detectMimeType(String path, String mimetype) {
         if (StringUtilities.isNotBlank(mimetype)) {
             return mimetype;
diff --git a/src/protocol/http/src/main/resources/org/apache/jmeter/protocol/http/gui/action/tika-config.xml b/src/protocol/http/src/main/resources/org/apache/jmeter/protocol/http/gui/action/tika-config.xml
deleted file mode 100644
index e621d9c7a4..0000000000
--- a/src/protocol/http/src/main/resources/org/apache/jmeter/protocol/http/gui/action/tika-config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<properties>
-   <service-loader initializableProblemHandler="ignore"/>
-</properties>
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 988377c81b..0fadcca8ee 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -91,7 +91,7 @@ Summary
 
   <h3>Non-functional changes</h3>
   <ul>
-    <li>Update Apache Tika to 3.x from 1.x to use the latest parser engine.</li>
+    <li>Update Apache Tika to 4.x from 1.x to use the latest parser engine.</li>
     <li>Update Saxon-HE to 12.x from 11.x for XSLT and XQuery processing.</li>
     <li>Update Groovy to 5.x for the Groovy-based scripting environment.</li>
     <li>Update Bouncy Castle to 1.82 for cryptographic operations.</li>