Skip to content

Commit ef73dd4

Browse files
authored
fix: Do not log an error if the user aborts an upload (#22908)
1 parent 99b8fdf commit ef73dd4

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

flow-server/src/main/java/com/vaadin/flow/server/DefaultErrorHandler.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.EOFException;
1919
import java.net.SocketException;
2020
import java.net.SocketTimeoutException;
21+
import java.util.Collections;
2122
import java.util.HashSet;
2223
import java.util.Set;
2324

@@ -54,6 +55,13 @@
5455
*/
5556
public class DefaultErrorHandler implements ErrorHandler {
5657

58+
public static final Set<String> SOCKET_EXCEPTIONS = Collections
59+
.unmodifiableSet(Set.of(SocketException.class.getName(),
60+
SocketTimeoutException.class.getName(),
61+
EOFException.class.getName(),
62+
"org.eclipse.jetty.io.EofException",
63+
"org.apache.catalina.connector.ClientAbortException"));
64+
5765
private final Set<String> ignoredExceptions;
5866
private final Set<String> routeConfigurationExceptions;
5967

@@ -70,11 +78,7 @@ protected DefaultErrorHandler(Set<String> ignoredExceptions,
7078
}
7179

7280
public DefaultErrorHandler() {
73-
this.ignoredExceptions = Set.of(SocketException.class.getName(),
74-
SocketTimeoutException.class.getName(),
75-
EOFException.class.getName(),
76-
"org.eclipse.jetty.io.EofException",
77-
"org.apache.catalina.connector.ClientAbortException");
81+
this.ignoredExceptions = SOCKET_EXCEPTIONS;
7882
this.routeConfigurationExceptions = Set.of(
7983
AmbiguousRouteConfigurationException.class.getName(),
8084
InvalidRouteConfigurationException.class.getName(),

flow-server/src/main/java/com/vaadin/flow/server/communication/TransferUtil.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.vaadin.flow.internal.UrlUtil;
3838
import com.vaadin.flow.internal.streams.UploadCompleteEvent;
3939
import com.vaadin.flow.internal.streams.UploadStartEvent;
40+
import com.vaadin.flow.server.DefaultErrorHandler;
4041
import com.vaadin.flow.server.VaadinRequest;
4142
import com.vaadin.flow.server.VaadinResponse;
4243
import com.vaadin.flow.server.VaadinSession;
@@ -204,8 +205,15 @@ public static void handleUpload(UploadHandler handler,
204205
.warn("File upload failed.", e);
205206
handler.responseHandled(new UploadResult(false, response, e));
206207
} catch (Exception e) {
207-
LoggerFactory.getLogger(UploadHandler.class)
208-
.error("Exception during upload", e);
208+
if (DefaultErrorHandler.SOCKET_EXCEPTIONS
209+
.contains(e.getClass().getName())) {
210+
// Client aborted the upload, no need to log an error
211+
LoggerFactory.getLogger(UploadHandler.class)
212+
.debug("Client aborted the upload", e);
213+
} else {
214+
LoggerFactory.getLogger(UploadHandler.class)
215+
.error("Exception during upload", e);
216+
}
209217
handler.responseHandled(new UploadResult(false, response, e));
210218
}
211219
}

0 commit comments

Comments
 (0)