From cf76b7d89c7bf1cd74565ddef39d7f5fef877de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Markovi=C4=8D?= Date: Tue, 3 Mar 2020 16:40:36 +0100 Subject: [PATCH] remove custom implementation and use org.apache.commons.lang.math.NumberUtils.isNumber --- .../elasticsearch/ElasticSearchMetric.java | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java b/src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java index f0e9a9d..71b9817 100644 --- a/src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java +++ b/src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java @@ -20,6 +20,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.commons.lang.math.NumberUtils.isNumber; + public class ElasticSearchMetric { private static final Logger logger = LoggerFactory.getLogger(ElasticSearchMetric.class); private SampleResult sampleResult; @@ -162,7 +164,7 @@ private void addCustomFields(BackendListenerContext context) { if (!parameterName.startsWith("es.") && context.containsParameter(parameterName) && !"".equals(parameter = context.getParameter(parameterName).trim())) { - if (isInteger(parameter)) { + if (isNumber(parameter)) { addFilteredJSON(parameterName, Long.parseLong(parameter)); } else { addFilteredJSON(parameterName, parameter); @@ -280,27 +282,4 @@ public Date getElapsedTime(boolean forBuildComparison) { } } - private static boolean isInteger(String str) { - if (str == null) { - return false; - } - int length = str.length(); - if (length == 0) { - return false; - } - int i = 0; - if (str.charAt(0) == '-') { - if (length == 1) { - return false; - } - i = 1; - } - for (; i < length; i++) { - char c = str.charAt(i); - if (c < '0' || c > '9') { - return false; - } - } - return true; - } }