From 77ca89805dedfc433fa2058375f01a28e1b0bfd0 Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser <23085769+hiddenalpha@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:54:15 +0200 Subject: [PATCH] Fixes: https://github.com/swisspost/gateleen/issues/569 --- .../gateleen/core/http/LocalHttpClientRequest.java | 6 +++++- .../java/org/swisspush/gateleen/routing/Forwarder.java | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClientRequest.java b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClientRequest.java index 4bc9060c..fb152839 100644 --- a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClientRequest.java +++ b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClientRequest.java @@ -825,7 +825,11 @@ public boolean reset(long code, Throwable cause) { @Override public HttpConnection connection() { - throw new UnsupportedOperationException(); + // Cited from API specification: + // @return the {@link HttpConnection} associated with this request + // As "no connection" is associated with this request, we return "no connection". + log.debug("There's no connection associated with this request."); + return null; } @Override diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java index 17114f6d..c2e0dded 100755 --- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java +++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java @@ -371,12 +371,13 @@ public WriteStream drainHandler(@Nullable Handler handler) { }; req.exceptionHandler(t -> { - RequestLoggerFactory - .getLogger(Forwarder.class, req) - .warn("Exception during forwarding - closing (forwarding) client connection", t); + log.info("Exception during forwarding - closing (forwarding) client connection", t); HttpConnection connection = cReq.connection(); if (connection != null) { connection.close(); + } else { + log.warn("There's no connection we could close in {}, gateleen wishes your request a happy timeout ({})", + cReq.getClass(), req.uri()); } });