aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/config')
-rw-r--r--src/main/java/com/juick/config/ActivityPubClientErrorHandler.java12
-rw-r--r--src/main/java/com/juick/config/ActivityPubConfig.java5
2 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/com/juick/config/ActivityPubClientErrorHandler.java b/src/main/java/com/juick/config/ActivityPubClientErrorHandler.java
index 69958bbd..23576ad5 100644
--- a/src/main/java/com/juick/config/ActivityPubClientErrorHandler.java
+++ b/src/main/java/com/juick/config/ActivityPubClientErrorHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -28,6 +28,7 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.client.DefaultResponseErrorHandler;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
@@ -36,16 +37,17 @@ import java.nio.charset.StandardCharsets;
@Component
public class ActivityPubClientErrorHandler extends DefaultResponseErrorHandler {
private static final Logger logger = LoggerFactory.getLogger("ActivityPub");
-
@Inject
private ApplicationEventPublisher applicationEventPublisher;
@Override
- public void handleError(URI contextUri, HttpMethod method, ClientHttpResponse response) throws IOException {
- logger.warn("HTTP ERROR {} {} : {}", response.getStatusCode().value(),
- response.getStatusText(), IOUtils.toString(response.getBody(), StandardCharsets.UTF_8));
+ public void handleError(@Nonnull URI contextUri, @Nonnull HttpMethod method, ClientHttpResponse response)
+ throws IOException {
if (response.getStatusCode().equals(HttpStatus.GONE)) {
logger.warn("Server report {} is gone, deleting", contextUri.toASCIIString());
applicationEventPublisher.publishEvent(new DeleteUserEvent(this, contextUri.toASCIIString()));
+ } else {
+ logger.warn("HTTP ERROR {} {} : {}", response.getStatusCode().value(),
+ response.getStatusText(), IOUtils.toString(response.getBody(), StandardCharsets.UTF_8));
}
}
}
diff --git a/src/main/java/com/juick/config/ActivityPubConfig.java b/src/main/java/com/juick/config/ActivityPubConfig.java
index 3570b97d..9a626d12 100644
--- a/src/main/java/com/juick/config/ActivityPubConfig.java
+++ b/src/main/java/com/juick/config/ActivityPubConfig.java
@@ -29,6 +29,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -66,8 +67,8 @@ public class ActivityPubConfig {
CloseableHttpClient httpClient;
@Bean
- HttpComponentsClientHttpRequestFactory clientHttpRequestFactory() {
- HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
+ ClientHttpRequestFactory clientHttpRequestFactory() {
+ var clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
clientHttpRequestFactory.setHttpClient(httpClient);
return clientHttpRequestFactory;
}