aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/ActivityPubManager.java12
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java2
2 files changed, 14 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
index 41dd52eb..692d1107 100644
--- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
+++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
@@ -17,11 +17,14 @@ import com.juick.service.component.*;
import com.juick.util.MessageUtils;
import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Nonnull;
@@ -31,6 +34,7 @@ import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -313,4 +317,12 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
}
});
}
+
+ public static class ErrorHandler extends DefaultResponseErrorHandler {
+ @Override
+ public void handleError(ClientHttpResponse response) throws IOException {
+ logger.warn("HTTP ERROR {} {} : {}", response.getStatusCode().value(),
+ response.getStatusText(), IOUtils.toString(response.getBody(), StandardCharsets.UTF_8));
+ }
+ }
}
diff --git a/juick-server/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java b/juick-server/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
index b7762221..37afc1d8 100644
--- a/juick-server/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
+++ b/juick-server/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
@@ -1,5 +1,6 @@
package com.juick.server.configuration;
+import com.juick.server.ActivityPubManager;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.cache.CacheConfig;
import org.apache.http.impl.client.cache.CachingHttpClientBuilder;
@@ -18,6 +19,7 @@ public class ActivityPubClientConfig {
RestTemplate restTemplate = new RestTemplate(requestFactory);
// BufferingClientHttpRequestFactory allows us to read the response more than once - Necessary for debugging.
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient())));
+ restTemplate.setErrorHandler(new ActivityPubManager.ErrorHandler());
return restTemplate;
}
@Bean