diff --git a/pom.xml b/pom.xml
index 5ac439e..d1556e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.databunker
databunkerpro-java
- 1.0.0-SNAPSHOT
+ 1.1.0-SNAPSHOT
jar
DatabunkerPro Java Client
@@ -20,18 +20,11 @@
-
+
- org.apache.httpcomponents
- httpclient
- 4.5.14
-
-
-
-
- org.apache.httpcomponents
- httpcore
- 4.4.16
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.6.4
@@ -87,7 +80,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.1
+ 3.15.0
11
11
@@ -96,7 +89,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.1
+ 3.4.0
attach-sources
@@ -109,7 +102,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.3.2
+ 3.12.0
attach-javadocs
diff --git a/src/main/java/org/databunker/DatabunkerproApi.java b/src/main/java/org/databunker/DatabunkerproApi.java
index e1249f1..43e2444 100644
--- a/src/main/java/org/databunker/DatabunkerproApi.java
+++ b/src/main/java/org/databunker/DatabunkerproApi.java
@@ -1,14 +1,16 @@
package org.databunker;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.apache.http.client.methods.HttpGet;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.databunker.options.BasicOptions;
import org.databunker.options.UserOptions;
import org.databunker.options.SharedRecordOptions;
@@ -84,7 +86,7 @@ private Map makeRequest(String endpoint, Map dat
if (requestMetadata != null) {
bodyData.put("request_metadata", requestMetadata);
}
- StringEntity entity = new StringEntity(objectMapper.writeValueAsString(bodyData));
+ StringEntity entity = new StringEntity(objectMapper.writeValueAsString(bodyData), ContentType.APPLICATION_JSON);
request.setEntity(entity);
}
@@ -93,7 +95,7 @@ private Map makeRequest(String endpoint, Map dat
String responseString = EntityUtils.toString(entity);
Map result = objectMapper.readValue(responseString, Map.class);
- if (response.getStatusLine().getStatusCode() < 200 || response.getStatusLine().getStatusCode() >= 300) {
+ if (response.getCode() < 200 || response.getCode() >= 300) {
if (result.containsKey("status")) {
return result;
} else {
@@ -134,7 +136,7 @@ private byte[] rawRequest(String endpoint, Map data, Map getSystemMetrics(Map requestMetadata)
HttpEntity entity = response.getEntity();
String metricsText = EntityUtils.toString(entity);
return parsePrometheusMetrics(metricsText);
+ } catch (ParseException error) {
+ throw new IOException("Failed to parse the metrics response", error);
}
}
diff --git a/src/test/java/org/databunker/DatabunkerproApiPciTest.java b/src/test/java/org/databunker/DatabunkerproApiPciTest.java
index 5d2f896..ec95c2a 100644
--- a/src/test/java/org/databunker/DatabunkerproApiPciTest.java
+++ b/src/test/java/org/databunker/DatabunkerproApiPciTest.java
@@ -1,12 +1,12 @@
package org.databunker;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
diff --git a/src/test/java/org/databunker/DatabunkerproApiTest.java b/src/test/java/org/databunker/DatabunkerproApiTest.java
index c0d2459..ab97fb1 100644
--- a/src/test/java/org/databunker/DatabunkerproApiTest.java
+++ b/src/test/java/org/databunker/DatabunkerproApiTest.java
@@ -1,12 +1,12 @@
package org.databunker;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;