You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/08/14 09:07:33 UTC
[james-project] 05/13: JAMES-3357 add logger for internal error in
jmapApiRoutes
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit bfeaf98250f8d478f36e18a19952fcb9be420129
Author: RĂ©mi Kowalski <rk...@linagora.com>
AuthorDate: Wed Jul 29 17:03:49 2020 +0200
JAMES-3357 add logger for internal error in jmapApiRoutes
---
.../main/java/org/apache/james/jmap/http/AuthenticationRoutes.java | 4 ++--
.../src/main/java/org/apache/james/jmap/http/DownloadRoutes.java | 4 ++--
.../src/main/java/org/apache/james/jmap/http/JMAPApiRoutes.java | 2 +-
.../src/main/java/org/apache/james/jmap/http/UploadRoutes.java | 2 +-
.../src/main/scala/org/apache/james/jmap/http/SessionRoutes.scala | 2 +-
.../src/main/scala/org/apache/james/jmap/routes/JMAPApiRoutes.scala | 2 +-
.../jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java | 3 ++-
7 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/AuthenticationRoutes.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/AuthenticationRoutes.java
index 35e0a69..1e77432 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/AuthenticationRoutes.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/AuthenticationRoutes.java
@@ -139,7 +139,7 @@ public class AuthenticationRoutes implements JMAPRoutes {
})))
.onErrorResume(BadRequestException.class, e -> handleBadRequest(response, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(e -> handleInternalError(response, e))
+ .onErrorResume(e -> handleInternalError(response, LOGGER, e))
.subscriberContext(jmapContext(request))
.subscriberContext(jmapAction("auth-post"))
.subscribeOn(Schedulers.elastic());
@@ -152,7 +152,7 @@ public class AuthenticationRoutes implements JMAPRoutes {
.onErrorResume(IllegalArgumentException.class, e -> handleBadRequest(resp, LOGGER, e))
.onErrorResume(BadRequestException.class, e -> handleBadRequest(resp, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(InternalErrorException.class, e -> handleInternalError(resp, e))
+ .onErrorResume(InternalErrorException.class, e -> handleInternalError(resp, LOGGER, e))
.onErrorResume(UnauthorizedException.class, e -> handleAuthenticationFailure(resp, LOGGER, e))
.subscriberContext(jmapContext(req))
.subscriberContext(jmapAction("returnEndPoints"))
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/DownloadRoutes.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/DownloadRoutes.java
index 160beae..443e2c3 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/DownloadRoutes.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/DownloadRoutes.java
@@ -144,7 +144,7 @@ public class DownloadRoutes implements JMAPRoutes {
.subscriberContext(jmapAuthContext(session)))
.onErrorResume(UnauthorizedException.class, e -> handleAuthenticationFailure(response, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(e -> handleInternalError(response, e))
+ .onErrorResume(e -> handleInternalError(response, LOGGER, e))
.subscriberContext(jmapContext(request))
.subscriberContext(jmapAction("download-post"))
.subscribeOn(Schedulers.elastic());
@@ -174,7 +174,7 @@ public class DownloadRoutes implements JMAPRoutes {
.subscriberContext(jmapAuthContext(session)))
.onErrorResume(UnauthorizedException.class, e -> handleAuthenticationFailure(response, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(e -> handleInternalError(response, e))
+ .onErrorResume(e -> handleInternalError(response, LOGGER, e))
.subscriberContext(jmapContext(request))
.subscriberContext(jmapAction("download-get"))
.subscribeOn(Schedulers.elastic());
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/JMAPApiRoutes.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/JMAPApiRoutes.java
index c33c0f3..b9bbca8 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/JMAPApiRoutes.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/JMAPApiRoutes.java
@@ -105,7 +105,7 @@ public class JMAPApiRoutes implements JMAPRoutes {
.onErrorResume(BadRequestException.class, e -> handleBadRequest(response, LOGGER, e))
.onErrorResume(UnauthorizedException.class, e -> handleAuthenticationFailure(response, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(e -> handleInternalError(response, e))
+ .onErrorResume(e -> handleInternalError(response, LOGGER, e))
.subscriberContext(jmapContext(request))
.subscribeOn(Schedulers.elastic());
}
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/UploadRoutes.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/UploadRoutes.java
index 9f7c235..0311550 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/UploadRoutes.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/UploadRoutes.java
@@ -106,7 +106,7 @@ public class UploadRoutes implements JMAPRoutes {
.onErrorResume(BadRequestException.class, e -> handleBadRequest(response, e))
.onErrorResume(UnauthorizedException.class, e -> handleAuthenticationFailure(response, LOGGER, e))
.doOnEach(logOnError(e -> LOGGER.error("Unexpected error", e)))
- .onErrorResume(e -> handleInternalError(response, e))
+ .onErrorResume(e -> handleInternalError(response, LOGGER, e))
.subscriberContext(jmapContext(request))
.subscriberContext(jmapAction("upload-get"))
.subscribeOn(Schedulers.elastic());
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/http/SessionRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/http/SessionRoutes.scala
index 557282f..8d62973 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/http/SessionRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/http/SessionRoutes.scala
@@ -79,6 +79,6 @@ class SessionRoutes @Inject() (@Named(InjectionKeys.RFC_8621) val authenticator:
def errorHandling(throwable: Throwable, response: HttpServerResponse): Mono[Void] =
throwable match {
case _: UnauthorizedException => handleAuthenticationFailure(response, LOGGER, throwable)
- case _ => handleInternalError(response, throwable)
+ case _ => handleInternalError(response, LOGGER, throwable)
}
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JMAPApiRoutes.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JMAPApiRoutes.scala
index d81adf6..972bccf 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JMAPApiRoutes.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/JMAPApiRoutes.scala
@@ -151,7 +151,7 @@ class JMAPApiRoutes (val authenticator: Authenticator,
s"The content type of the request was not application/json or the request did not parse as I-JSON: ${exception.getMessage}"))
case exception: UnsupportedCapabilitiesException => respondDetails(httpServerResponse,
unknownCapabilityProblem(s"The request used unsupported capabilities: ${exception.capabilities}"))
- case _ => SMono.fromPublisher(handleInternalError(httpServerResponse, throwable))
+ case _ => SMono.fromPublisher(handleInternalError(httpServerResponse, JMAPApiRoutes.LOGGER, throwable))
}
private def respondDetails(httpServerResponse: HttpServerResponse, details: ProblemDetails): SMono[Void] =
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
index f683ea1..2908216 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
@@ -42,7 +42,8 @@ public interface JMAPRoutes {
.header("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept"));
}
- default Mono<Void> handleInternalError(HttpServerResponse response, Throwable e) {
+ default Mono<Void> handleInternalError(HttpServerResponse response, Logger logger, Throwable e) {
+ logger.error("Internal server error", e);
return response.status(INTERNAL_SERVER_ERROR).send();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org