From 58b1db610c96befe7c0d3eca7c57a07eb7be7cc7 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Tue, 4 Feb 2020 10:49:27 +0100 Subject: [PATCH] detectAndUpgrade() shortcut on empty buffer Signed-off-by: Ludovic Orban --- .../eclipse/jetty/server/DetectorConnectionFactory.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java index 690563e5e2d..3f280a674d4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/DetectorConnectionFactory.java @@ -218,6 +218,13 @@ public class DetectorConnectionFactory extends AbstractConnectionFactory impleme */ private boolean detectAndUpgrade() { + if (BufferUtil.isEmpty(_buffer)) + { + if (LOG.isDebugEnabled()) + LOG.debug("Detector {} skipping detection on an empty buffer", getProtocol()); + return false; + } + if (LOG.isDebugEnabled()) LOG.debug("Detector {} performing detection with {} bytes", getProtocol(), _buffer.remaining()); boolean notRecognized = true;