summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2022-05-23 15:59:53 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2022-05-23 15:59:53 +0200
commit6800f1493aa44fc5c2e79df49ff023f2e3434834 (patch)
tree7db9a5e8190d2c9f820f42821c008667b6401ec8 /container-core
parent892d4c41216a44ed704855239336316fe8f35293 (diff)
Classify failures due to client-initiated close as separate category
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/MetricDefinitions.java1
-rw-r--r--container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/SslHandshakeFailure.java41
2 files changed, 33 insertions, 9 deletions
diff --git a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/MetricDefinitions.java b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/MetricDefinitions.java
index b3a7ebc761a..686d23c4c99 100644
--- a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/MetricDefinitions.java
+++ b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/MetricDefinitions.java
@@ -64,6 +64,7 @@ class MetricDefinitions {
static final String SSL_HANDSHAKE_FAILURE_INCOMPATIBLE_PROTOCOLS = "jdisc.http.ssl.handshake.failure.incompatible_protocols";
static final String SSL_HANDSHAKE_FAILURE_INCOMPATIBLE_CIPHERS = "jdisc.http.ssl.handshake.failure.incompatible_ciphers";
static final String SSL_HANDSHAKE_FAILURE_UNKNOWN = "jdisc.http.ssl.handshake.failure.unknown";
+ static final String SSL_HANDSHAKE_FAILURE_CONNECTION_CLOSED = "jdisc.http.ssl.handshake.failure.connection_closed";
static final String JETTY_THREADPOOL_MAX_THREADS = "jdisc.http.jetty.threadpool.thread.max";
static final String JETTY_THREADPOOL_MIN_THREADS = "jdisc.http.jetty.threadpool.thread.min";
diff --git a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/SslHandshakeFailure.java b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/SslHandshakeFailure.java
index 331d8837bfa..20ce15d683f 100644
--- a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/SslHandshakeFailure.java
+++ b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/SslHandshakeFailure.java
@@ -1,7 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.server.jetty;
+import org.eclipse.jetty.io.EofException;
+
import javax.net.ssl.SSLHandshakeException;
+import java.io.IOException;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@@ -33,29 +36,49 @@ enum SslHandshakeFailure {
INVALID_CLIENT_CERT(
MetricDefinitions.SSL_HANDSHAKE_FAILURE_INVALID_CLIENT_CERT, // Includes mismatch of client certificate and private key
"INVALID_CLIENT_CERTIFICATE",
- "(PKIX path (building|validation) failed: .+)|(Invalid CertificateVerify signature)");
+ "(PKIX path (building|validation) failed: .+)|(Invalid CertificateVerify signature)"),
+ CONNECTION_CLOSED(
+ MetricDefinitions.SSL_HANDSHAKE_FAILURE_CONNECTION_CLOSED,
+ "CONNECTION_CLOSED",
+ e -> e.getCause() instanceof EofException
+ && e.getCause().getCause() instanceof IOException
+ && e.getCause().getCause().getMessage().equals("Broken pipe"));
private final String metricName;
private final String failureType;
- private final Predicate<String> messageMatcher;
+ private final Predicate<SSLHandshakeException> predicate;
SslHandshakeFailure(String metricName, String failureType, String messagePattern) {
+ this(metricName, failureType, new MessagePatternPredicate(messagePattern));
+ }
+
+ SslHandshakeFailure(String metricName, String failureType, Predicate<SSLHandshakeException> predicate) {
this.metricName = metricName;
this.failureType = failureType;
- this.messageMatcher = Pattern.compile(messagePattern).asMatchPredicate();
+ this.predicate = predicate;
}
String metricName() { return metricName; }
String failureType() { return failureType; }
static Optional<SslHandshakeFailure> fromSslHandshakeException(SSLHandshakeException exception) {
- String message = exception.getMessage();
- if (message == null || message.isBlank()) return Optional.empty();
- for (SslHandshakeFailure failure : values()) {
- if (failure.messageMatcher.test(message)) {
- return Optional.of(failure);
- }
+ for (SslHandshakeFailure type : values()) {
+ if (type.predicate.test(exception)) return Optional.of(type);
}
return Optional.empty();
}
+
+ private static class MessagePatternPredicate implements Predicate<SSLHandshakeException> {
+ final Pattern pattern;
+
+ MessagePatternPredicate(String pattern) { this.pattern = Pattern.compile(pattern); }
+
+ @Override
+ public boolean test(SSLHandshakeException e) {
+ String message = e.getMessage();
+ if (message == null || message.isBlank()) return false;
+ return pattern.matcher(message).matches();
+ }
+ }
+
}