Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Updated exception logging for HttpClientProtocol Made body of HttpClient public to insert new body HttpClientProtocol.executePolling request returns List of String to let subclasses do the parsing

Michael Rademakera17e6505e85f
diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
index 20178fea5..ba9d72ff2 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
@@ -156,7 +156,7 @@ public class HttpClientProtocol extends AbstractProtocol {
public MultivaluedMap<String, String> headers;
public MultivaluedMap<String, String> queryParameters;
protected List<Integer> failureCodes;
- protected String body;
+ public String body;
protected String contentType;
protected WebTarget client;
protected WebTarget requestTarget;
@@ -1255,30 +1255,20 @@ public class HttpClientProtocol extends AbstractProtocol {
protected void executePollingRequest(HttpClientRequest clientRequest, Consumer<Response> responseConsumer) {
Response originalResponse = null, lastResponse = null;
- List<Object> entities = null;
+ List<String> entities = new ArrayList<>();
try {
originalResponse = clientRequest.invoke(null);
if (clientRequest.pagingEnabled) {
lastResponse = originalResponse;
- entities = new ArrayList<>();
- entities.add(lastResponse.readEntity(Object.class));
+ entities.add(lastResponse.readEntity(String.class));
while ((lastResponse = executePagingRequest(clientRequest, lastResponse)) != null) {
- entities.add(lastResponse.readEntity(Object.class));
+ entities.add(lastResponse.readEntity(String.class));
}
originalResponse = PagingResponse.fromResponse(originalResponse).entity(entities).build();
}
} catch (Exception e) {
- String responseBody = lastResponse != null ? lastResponse.readEntity(String.class) : originalResponse != null ? originalResponse.readEntity(String.class) : null;
- if (TextUtil.isNullOrEmpty(responseBody)) {
- LOG.log(Level.SEVERE, "Exception thrown whilst doing polling request", e);
- } else {
- LOG.log(Level.SEVERE, String.format("Exception thrown whilst doing polling request: %s", responseBody), e);
- }
- //Try to recover as much as possible when an exception has occurred in a paging request
- if (entities != null) {
- originalResponse = PagingResponse.fromResponse(originalResponse).entity(entities).build();
- }
+ LOG.log(Level.SEVERE, "Exception thrown whilst doing polling request", e);
}
responseConsumer.accept(originalResponse);