From 803f69f8484aa34c78ab160d1474db56bf0aff47 Mon Sep 17 00:00:00 2001 From: Felix Schumacher Date: Fri, 15 Jan 2021 15:34:11 +0100 Subject: [PATCH] Partly revert "Silence warning of tika about missing sqlite-jdbc dependency" This reverts commit aa6c7633d6ff8125d588071cb4739930a847e1fa. Instead of using a system property and extending the shell scripts to start JMeter, we now configure Tika inside the client code directly. The used config file stays at the same location and has still the same content. --- .gitignore | 2 +- bin/jmeter | 2 +- bin/jmeter.bat | 2 +- .../http/gui/action/ParseCurlCommandAction.java | 15 ++++++++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 61df09b98d..21abad60e4 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,7 @@ /bin/*.jmx /bin/*.jtl /bin/*.xml -# We need log4j2.xml even though we want to exclude xml created by batch tests +# We need log4j2.xml and tika-config.xml even though we want to exclude xml created by batch tests !/bin/log4j2.xml !/bin/tika-config.xml diff --git a/bin/jmeter b/bin/jmeter index fae82ffa28..5d5b949efa 100755 --- a/bin/jmeter +++ b/bin/jmeter @@ -187,7 +187,7 @@ esac # Always dump on OOM (does not cost anything unless triggered) DUMP="-XX:+HeapDumpOnOutOfMemoryError" -SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom -Dtika.config=${JMETER_HOME}/bin/tika-config.xml" +SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom" SERVER="-server" if [ -z "${JMETER_COMPLETE_ARGS}" ]; then diff --git a/bin/jmeter.bat b/bin/jmeter.bat index 2c96b54768..80fc534f57 100644 --- a/bin/jmeter.bat +++ b/bin/jmeter.bat @@ -162,7 +162,7 @@ if not defined GC_ALGO ( set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 ) -set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom -Dtika.config=%JMETER_BIN%tika-config.xml +set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom rem Always dump on OOM (does not cost anything unless triggered) set DUMP=-XX:+HeapDumpOnOutOfMemoryError 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 d610b52d8c..d601618e0b 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 @@ -29,6 +29,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; import java.text.MessageFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -104,8 +105,11 @@ import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.gui.ComponentUtil; import org.apache.jorphan.gui.JMeterUIDefaults; 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; /** * Opens a popup where user can enter a cURL command line and create a test plan @@ -130,7 +134,16 @@ public class ParseCurlCommandAction extends AbstractAction implements MenuCreato private JSyntaxTextArea cURLCommandTA; private JLabel statusText; private JCheckBox uploadCookiesCheckBox; - private final Tika tika = new Tika(); + private final Tika tika = createTika(); + + private Tika createTika() { + try { + return new Tika(new TikaConfig(Paths.get(JMeterUtils.getJMeterBinDir(), "tika-config.xml"))); + } catch (TikaException | IOException | SAXException e) { + return new Tika(); + } + } + public ParseCurlCommandAction() { super(); }