You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/05/05 15:45:24 UTC

[tomcat] branch 10.1.x updated (87409a1d7e -> 15a1d0e0c4)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from 87409a1d7e Increase wait time - I am seeing test failures on local VMs.
     new 0574bf3096 Clean-up, formatting. No functional change.
     new 15a1d0e0c4 Clean-up, formatting. No functional change.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../coyote/http2/ConnectionSettingsBase.java       |  10 +-
 .../coyote/http2/ConnectionSettingsLocal.java      |   2 +-
 java/org/apache/coyote/http2/HpackEncoder.java     |   8 +-
 java/org/apache/coyote/http2/Http2AsyncParser.java |   6 +-
 .../coyote/http2/Http2AsyncUpgradeHandler.java     |  26 +--
 java/org/apache/coyote/http2/Http2Protocol.java    |   4 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  12 +-
 java/org/apache/coyote/http2/Stream.java           |  16 +-
 java/org/apache/coyote/http2/StreamProcessor.java  |  15 +-
 .../tomcat/util/http/parser/Authorization.java     |  21 +--
 .../org/apache/tomcat/util/http/parser/Cookie.java |  48 +++--
 .../apache/tomcat/util/http/parser/EntityTag.java  |  10 +-
 java/org/apache/tomcat/util/http/parser/Host.java  |  12 +-
 .../apache/tomcat/util/http/parser/HttpParser.java | 210 +++++++++------------
 .../apache/tomcat/util/http/parser/MediaType.java  |   6 +-
 .../tomcat/util/http/parser/MediaTypeCache.java    |  13 +-
 .../apache/tomcat/util/http/parser/TokenList.java  |  22 +--
 .../apache/tomcat/util/http/parser/Upgrade.java    |   2 +-
 18 files changed, 196 insertions(+), 247 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Clean-up, formatting. No functional change.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0574bf30963e2ff582694e006ca598a9bb15512c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 5 16:44:52 2023 +0100

    Clean-up, formatting. No functional change.
    
    Preparation before back-porting RFC 918 priorities.
---
 .../coyote/http2/ConnectionSettingsBase.java       | 10 ++++-----
 .../coyote/http2/ConnectionSettingsLocal.java      |  2 +-
 java/org/apache/coyote/http2/HpackEncoder.java     |  8 +++----
 java/org/apache/coyote/http2/Http2AsyncParser.java |  6 ++---
 .../coyote/http2/Http2AsyncUpgradeHandler.java     | 26 +++++++++++-----------
 java/org/apache/coyote/http2/Http2Protocol.java    |  4 ++--
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 12 +++++-----
 java/org/apache/coyote/http2/Stream.java           | 16 ++++++-------
 java/org/apache/coyote/http2/StreamProcessor.java  | 15 +++++++------
 9 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/java/org/apache/coyote/http2/ConnectionSettingsBase.java b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
index a8e9879a46..8d894b1992 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsBase.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
@@ -45,8 +45,8 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
     static final int DEFAULT_MAX_FRAME_SIZE = MIN_MAX_FRAME_SIZE;
     static final long DEFAULT_MAX_HEADER_LIST_SIZE = 1 << 15;
 
-    Map<Setting, Long> current = new ConcurrentHashMap<>();
-    Map<Setting, Long> pending = new ConcurrentHashMap<>();
+    Map<Setting,Long> current = new ConcurrentHashMap<>();
+    Map<Setting,Long> pending = new ConcurrentHashMap<>();
 
 
     ConnectionSettingsBase(String connectionId) {
@@ -203,9 +203,9 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
 
     private void validateMaxFrameSize(long maxFrameSize) throws T {
         if (maxFrameSize < MIN_MAX_FRAME_SIZE || maxFrameSize > MAX_MAX_FRAME_SIZE) {
-            String msg = sm.getString("connectionSettings.maxFrameSizeInvalid", connectionId,
-                    Long.toString(maxFrameSize), Integer.toString(MIN_MAX_FRAME_SIZE),
-                    Integer.toString(MAX_MAX_FRAME_SIZE));
+            String msg =
+                    sm.getString("connectionSettings.maxFrameSizeInvalid", connectionId, Long.toString(maxFrameSize),
+                            Integer.toString(MIN_MAX_FRAME_SIZE), Integer.toString(MAX_MAX_FRAME_SIZE));
             throwException(msg, Http2Error.PROTOCOL_ERROR);
         }
     }
diff --git a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
index 8fecf37136..372be80223 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
@@ -61,7 +61,7 @@ class ConnectionSettingsLocal extends ConnectionSettingsBase<IllegalArgumentExce
         // Stream is zero
         // Payload
         int pos = 9;
-        for (Map.Entry<Setting, Long> setting : pending.entrySet()) {
+        for (Map.Entry<Setting,Long> setting : pending.entrySet()) {
             ByteUtil.setTwoBytes(result, pos, setting.getKey().getId());
             pos += 2;
             ByteUtil.setFourBytes(result, pos, setting.getValue().longValue());
diff --git a/java/org/apache/coyote/http2/HpackEncoder.java b/java/org/apache/coyote/http2/HpackEncoder.java
index a6e92a97c9..79b2a8a771 100644
--- a/java/org/apache/coyote/http2/HpackEncoder.java
+++ b/java/org/apache/coyote/http2/HpackEncoder.java
@@ -76,14 +76,14 @@ class HpackEncoder {
     private int newMaxHeaderSize = -1; // if the max header size has been changed
     private int minNewMaxHeaderSize = -1; // records the smallest value of newMaxHeaderSize, as per section 4.1
 
-    private static final Map<String, TableEntry[]> ENCODING_STATIC_TABLE;
+    private static final Map<String,TableEntry[]> ENCODING_STATIC_TABLE;
 
     private final Deque<TableEntry> evictionQueue = new ArrayDeque<>();
-    private final Map<String, List<TableEntry>> dynamicTable = new HashMap<>(); // TODO: use a custom data structure to
-                                                                                // reduce allocations
+    private final Map<String,List<TableEntry>> dynamicTable = new HashMap<>(); // TODO: use a custom data structure to
+                                                                               // reduce allocations
 
     static {
-        Map<String, TableEntry[]> map = new HashMap<>();
+        Map<String,TableEntry[]> map = new HashMap<>();
         for (int i = 1; i < Hpack.STATIC_TABLE.length; ++i) {
             Hpack.HeaderField m = Hpack.STATIC_TABLE[i];
             TableEntry[] existing = map.get(m.name);
diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java
index ec59e19833..23e5cf9d99 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -52,8 +52,8 @@ class Http2AsyncParser extends Http2Parser {
         ByteBuffer preface = ByteBuffer.wrap(prefaceData);
         ByteBuffer header = ByteBuffer.allocate(9);
         ByteBuffer framePayload = ByteBuffer.allocate(input.getMaxFrameSize());
-        PrefaceCompletionHandler handler = new PrefaceCompletionHandler(webConnection, stream, prefaceData, preface,
-                header, framePayload);
+        PrefaceCompletionHandler handler =
+                new PrefaceCompletionHandler(webConnection, stream, prefaceData, preface, header, framePayload);
         socketWrapper.read(BlockingMode.NON_BLOCK, socketWrapper.getReadTimeout(), TimeUnit.MILLISECONDS, null, handler,
                 handler, preface, header, framePayload);
     }
@@ -164,7 +164,7 @@ class Http2AsyncParser extends Http2Parser {
         }
     }
 
-    private class FrameCompletionHandler implements CompletionCheck, CompletionHandler<Long, Void> {
+    private class FrameCompletionHandler implements CompletionCheck, CompletionHandler<Long,Void> {
 
         private final FrameType expected;
         protected final ByteBuffer[] buffers;
diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
index 5eee67451c..9372037f3d 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -55,7 +55,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
         super(protocol, adapter, coyoteRequest, socketWrapper);
     }
 
-    private final CompletionHandler<Long, Void> errorCompletion = new CompletionHandler<>() {
+    private final CompletionHandler<Long,Void> errorCompletion = new CompletionHandler<>() {
         @Override
         public void completed(Long result, Void attachment) {
         }
@@ -65,7 +65,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
             error.set(t);
         }
     };
-    private final CompletionHandler<Long, Void> applicationErrorCompletion = new CompletionHandler<>() {
+    private final CompletionHandler<Long,Void> applicationErrorCompletion = new CompletionHandler<>() {
         @Override
         public void completed(Long result, Void attachment) {
         }
@@ -320,8 +320,8 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                     sendfile.mappedBuffer = channel.map(MapMode.READ_ONLY, sendfile.pos, sendfile.end - sendfile.pos);
                 }
                 // Reserve as much as possible right away
-                int reservation = (sendfile.end - sendfile.pos > Integer.MAX_VALUE) ? Integer.MAX_VALUE
-                        : (int) (sendfile.end - sendfile.pos);
+                int reservation = (sendfile.end - sendfile.pos > Integer.MAX_VALUE) ? Integer.MAX_VALUE :
+                        (int) (sendfile.end - sendfile.pos);
                 sendfile.streamReservation = sendfile.stream.reserveWindowSize(reservation, true);
                 sendfile.connectionReservation = reserveWindowSize(sendfile.stream, sendfile.streamReservation, true);
             } catch (IOException e) {
@@ -337,8 +337,8 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
             // connectionReservation will always be smaller than or the same as
             // streamReservation
             int frameSize = Integer.min(getMaxFrameSize(), sendfile.connectionReservation);
-            boolean finished = (frameSize == sendfile.left) &&
-                    sendfile.stream.getCoyoteResponse().getTrailerFields() == null;
+            boolean finished =
+                    (frameSize == sendfile.left) && sendfile.stream.getCoyoteResponse().getTrailerFields() == null;
 
             // Need to check this now since sending end of stream will change this.
             boolean writable = sendfile.stream.canWrite();
@@ -371,7 +371,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
         }
     }
 
-    protected class SendfileCompletionHandler implements CompletionHandler<Long, SendfileData> {
+    protected class SendfileCompletionHandler implements CompletionHandler<Long,SendfileData> {
         @Override
         public void completed(Long nBytes, SendfileData sendfile) {
             CompletionState completionState = null;
@@ -397,12 +397,12 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 try {
                     if (sendfile.connectionReservation == 0) {
                         if (sendfile.streamReservation == 0) {
-                            int reservation = (sendfile.end - sendfile.pos > Integer.MAX_VALUE) ? Integer.MAX_VALUE
-                                    : (int) (sendfile.end - sendfile.pos);
+                            int reservation = (sendfile.end - sendfile.pos > Integer.MAX_VALUE) ? Integer.MAX_VALUE :
+                                    (int) (sendfile.end - sendfile.pos);
                             sendfile.streamReservation = sendfile.stream.reserveWindowSize(reservation, true);
                         }
-                        sendfile.connectionReservation = reserveWindowSize(sendfile.stream, sendfile.streamReservation,
-                                true);
+                        sendfile.connectionReservation =
+                                reserveWindowSize(sendfile.stream, sendfile.streamReservation, true);
                     }
                 } catch (IOException e) {
                     failed(e, sendfile);
@@ -418,8 +418,8 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 // connectionReservation will always be smaller than or the same as
                 // streamReservation
                 int frameSize = Integer.min(getMaxFrameSize(), sendfile.connectionReservation);
-                boolean finished = (frameSize == sendfile.left) &&
-                        sendfile.stream.getCoyoteResponse().getTrailerFields() == null;
+                boolean finished =
+                        (frameSize == sendfile.left) && sendfile.stream.getCoyoteResponse().getTrailerFields() == null;
 
                 // Need to check this now since sending end of stream will change this.
                 boolean writable = sendfile.stream.canWrite();
diff --git a/java/org/apache/coyote/http2/Http2Protocol.java b/java/org/apache/coyote/http2/Http2Protocol.java
index 08b4be2673..484d5d200a 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -128,8 +128,8 @@ public class Http2Protocol implements UpgradeProtocol {
     @Override
     public InternalHttpUpgradeHandler getInternalUpgradeHandler(SocketWrapperBase<?> socketWrapper, Adapter adapter,
             Request coyoteRequest) {
-        return socketWrapper.hasAsyncIO() ? new Http2AsyncUpgradeHandler(this, adapter, coyoteRequest, socketWrapper)
-                : new Http2UpgradeHandler(this, adapter, coyoteRequest, socketWrapper);
+        return socketWrapper.hasAsyncIO() ? new Http2AsyncUpgradeHandler(this, adapter, coyoteRequest, socketWrapper) :
+                new Http2UpgradeHandler(this, adapter, coyoteRequest, socketWrapper);
     }
 
 
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 3ee2f5bc28..4fdd27f20e 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -117,7 +117,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
     private HpackDecoder hpackDecoder;
     private HpackEncoder hpackEncoder;
 
-    private final ConcurrentNavigableMap<Integer, AbstractNonZeroStream> streams = new ConcurrentSkipListMap<>();
+    private final ConcurrentNavigableMap<Integer,AbstractNonZeroStream> streams = new ConcurrentSkipListMap<>();
     protected final AtomicInteger activeRemoteStreamCount = new AtomicInteger(0);
     // Start at -1 so the 'add 2' logic in closeIdleStreams() works
     private volatile int maxActiveRemoteStreamId = -1;
@@ -1631,8 +1631,8 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
 
     @Override
     public void receivedEndOfStream(int streamId) throws ConnectionException {
-        AbstractNonZeroStream abstractNonZeroStream = getAbstractNonZeroStream(streamId,
-                connectionState.get().isNewStreamAllowed());
+        AbstractNonZeroStream abstractNonZeroStream =
+                getAbstractNonZeroStream(streamId, connectionState.get().isNewStreamAllowed());
         if (abstractNonZeroStream instanceof Stream) {
             Stream stream = (Stream) abstractNonZeroStream;
             stream.receivedEndOfStream();
@@ -1682,7 +1682,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
 
 
     private void closeIdleStreams(int newMaxActiveRemoteStreamId) {
-        final ConcurrentNavigableMap<Integer, AbstractNonZeroStream> subMap = streams.subMap(
+        final ConcurrentNavigableMap<Integer,AbstractNonZeroStream> subMap = streams.subMap(
                 Integer.valueOf(maxActiveRemoteStreamId), false, Integer.valueOf(newMaxActiveRemoteStreamId), false);
         for (AbstractNonZeroStream stream : subMap.values()) {
             if (stream instanceof Stream) {
@@ -1742,8 +1742,8 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
 
     @Override
     public void headersEnd(int streamId) throws Http2Exception {
-        AbstractNonZeroStream abstractNonZeroStream = getAbstractNonZeroStream(streamId,
-                connectionState.get().isNewStreamAllowed());
+        AbstractNonZeroStream abstractNonZeroStream =
+                getAbstractNonZeroStream(streamId, connectionState.get().isNewStreamAllowed());
         if (abstractNonZeroStream instanceof Stream) {
             setMaxProcessedStream(streamId);
             Stream stream = (Stream) abstractNonZeroStream;
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 71463b01b5..f4bdde1990 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -117,8 +117,8 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
         } else {
             // HTTP/2 Push or HTTP/1.1 upgrade
             this.coyoteRequest = coyoteRequest;
-            this.inputBuffer = new SavedRequestStreamInputBuffer(
-                    (SavedRequestInputFilter) coyoteRequest.getInputBuffer());
+            this.inputBuffer =
+                    new SavedRequestStreamInputBuffer((SavedRequestInputFilter) coyoteRequest.getInputBuffer());
             // Headers have been read by this point
             state.receivedStartOfHeaders();
             if (HTTP_UPGRADE_STREAM.equals(identifier)) {
@@ -534,7 +534,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
 
 
     final void writeTrailers() throws IOException {
-        Supplier<Map<String, String>> supplier = coyoteResponse.getTrailerFields();
+        Supplier<Map<String,String>> supplier = coyoteResponse.getTrailerFields();
         if (supplier == null) {
             // No supplier was set, end of stream will already have been sent
             return;
@@ -545,7 +545,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
         MimeHeaders mimeHeaders = coyoteResponse.getMimeHeaders();
         mimeHeaders.recycle();
 
-        Map<String, String> headerMap = supplier.get();
+        Map<String,String> headerMap = supplier.get();
         if (headerMap == null) {
             headerMap = Collections.emptyMap();
         }
@@ -553,7 +553,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
         // Copy the contents of the Map to the MimeHeaders
         // TODO: Is there benefit in refactoring this? Is MimeHeaders too
         // heavyweight? Can we reduce the copy/conversions?
-        for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) {
+        for (Map.Entry<String,String> headerEntry : headerMap.entrySet()) {
             MessageBytes mb = mimeHeaders.addValue(headerEntry.getKey());
             mb.setString(headerEntry.getValue());
         }
@@ -732,9 +732,9 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
                     inputBuffer.swallowUnread();
                 }
             } catch (IOException ioe) {
-                ConnectionException ce = new ConnectionException(
-                        sm.getString("stream.reset.fail", getConnectionId(), getIdAsString()),
-                        Http2Error.PROTOCOL_ERROR, ioe);
+                ConnectionException ce =
+                        new ConnectionException(sm.getString("stream.reset.fail", getConnectionId(), getIdAsString()),
+                                Http2Error.PROTOCOL_ERROR, ioe);
                 handler.closeConnection(ce);
             }
         } else {
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java
index 303aff7692..d08c875cbd 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -94,9 +94,9 @@ class StreamProcessor extends AbstractProcessor {
                             // fully read. This typically occurs when Tomcat rejects an upload
                             // of some form (e.g. PUT or POST). Need to tell the client not to
                             // send any more data on this stream (reset).
-                            StreamException se = new StreamException(sm.getString("streamProcessor.cancel",
-                                    stream.getConnectionId(), stream.getIdAsString()), Http2Error.NO_ERROR,
-                                    stream.getIdAsInt());
+                            StreamException se =
+                                    new StreamException(sm.getString("streamProcessor.cancel", stream.getConnectionId(),
+                                            stream.getIdAsString()), Http2Error.NO_ERROR, stream.getIdAsInt());
                             stream.close(se);
                         } else if (!getErrorState().isConnectionIoAllowed()) {
                             ConnectionException ce = new ConnectionException(
@@ -153,15 +153,16 @@ class StreamProcessor extends AbstractProcessor {
 
 
     private void prepareSendfile() {
-        String fileName = (String) stream.getCoyoteRequest()
-                .getAttribute(org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
+        String fileName =
+                (String) stream.getCoyoteRequest().getAttribute(org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
         if (fileName != null) {
             sendfileData = new SendfileData();
             sendfileData.path = new File(fileName).toPath();
             sendfileData.pos = ((Long) stream.getCoyoteRequest()
                     .getAttribute(org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
-            sendfileData.end = ((Long) stream.getCoyoteRequest()
-                    .getAttribute(org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue();
+            sendfileData.end =
+                    ((Long) stream.getCoyoteRequest().getAttribute(org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR))
+                            .longValue();
             sendfileData.left = sendfileData.end - sendfileData.pos;
             sendfileData.stream = stream;
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Clean-up, formatting. No functional change.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 15a1d0e0c4fbfb3afe5d3c86f8f1dd8655c38499
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 5 16:45:14 2023 +0100

    Clean-up, formatting. No functional change.
    
    Preparation before back-porting RFC 918 priorities.
---
 .../tomcat/util/http/parser/Authorization.java     |  21 +--
 .../org/apache/tomcat/util/http/parser/Cookie.java |  48 +++--
 .../apache/tomcat/util/http/parser/EntityTag.java  |  10 +-
 java/org/apache/tomcat/util/http/parser/Host.java  |  12 +-
 .../apache/tomcat/util/http/parser/HttpParser.java | 210 +++++++++------------
 .../apache/tomcat/util/http/parser/MediaType.java  |   6 +-
 .../tomcat/util/http/parser/MediaTypeCache.java    |  13 +-
 .../apache/tomcat/util/http/parser/TokenList.java  |  22 +--
 .../apache/tomcat/util/http/parser/Upgrade.java    |   2 +-
 9 files changed, 146 insertions(+), 198 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/parser/Authorization.java b/java/org/apache/tomcat/util/http/parser/Authorization.java
index 8afba9bd1c..bb7b1a16e9 100644
--- a/java/org/apache/tomcat/util/http/parser/Authorization.java
+++ b/java/org/apache/tomcat/util/http/parser/Authorization.java
@@ -32,8 +32,8 @@ public class Authorization {
     static {
         // Digest field types.
         // Note: These are more relaxed than RFC2617. This adheres to the
-        //       recommendation of RFC2616 that servers are tolerant of buggy
-        //       clients when they can be so without ambiguity.
+        // recommendation of RFC2616 that servers are tolerant of buggy
+        // clients when they can be so without ambiguity.
         fieldTypes.put("username", FieldType.QUOTED_STRING);
         fieldTypes.put("realm", FieldType.QUOTED_STRING);
         fieldTypes.put("nonce", FieldType.QUOTED_STRING);
@@ -58,21 +58,18 @@ public class Authorization {
 
 
     /**
-     * Parses an HTTP Authorization header for DIGEST authentication as per RFC
-     * 2617 section 3.2.2.
+     * Parses an HTTP Authorization header for DIGEST authentication as per RFC 2617 section 3.2.2.
      *
      * @param input The header value to parse
      *
-     * @return  A map of directives and values as {@link String}s or
-     *          <code>null</code> if a parsing error occurs. Although the
-     *          values returned are {@link String}s they will have been
-     *          validated to ensure that they conform to RFC 2617.
+     * @return A map of directives and values as {@link String}s or <code>null</code> if a parsing error occurs.
+     *             Although the values returned are {@link String}s they will have been validated to ensure that they
+     *             conform to RFC 2617.
      *
-     * @throws IllegalArgumentException If the header does not conform to RFC
-     *                                  2617
-     * @throws java.io.IOException If an error occurs while reading the input
+     * @throws IllegalArgumentException If the header does not conform to RFC 2617
+     * @throws java.io.IOException      If an error occurs while reading the input
      */
-    public static Map<String,String> parseAuthorizationDigest (StringReader input)
+    public static Map<String,String> parseAuthorizationDigest(StringReader input)
             throws IllegalArgumentException, IOException {
 
         Map<String,String> result = new HashMap<>();
diff --git a/java/org/apache/tomcat/util/http/parser/Cookie.java b/java/org/apache/tomcat/util/http/parser/Cookie.java
index 7a0310ceaf..63b30d76c7 100644
--- a/java/org/apache/tomcat/util/http/parser/Cookie.java
+++ b/java/org/apache/tomcat/util/http/parser/Cookie.java
@@ -27,27 +27,28 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * <p>Cookie header parser based on RFC6265</p>
- * <p>The parsing of cookies using RFC6265 is more relaxed that the
- * specification in the following ways:</p>
+ * <p>
+ * Cookie header parser based on RFC6265
+ * </p>
+ * <p>
+ * The parsing of cookies using RFC6265 is more relaxed that the specification in the following ways:
+ * </p>
  * <ul>
- *   <li>Values 0x80 to 0xFF are permitted in cookie-octet to support the use of
- *       UTF-8 in cookie values as used by HTML 5.</li>
- *   <li>For cookies without a value, the '=' is not required after the name as
- *       some browsers do not sent it.</li>
+ * <li>Values 0x80 to 0xFF are permitted in cookie-octet to support the use of UTF-8 in cookie values as used by HTML
+ * 5.</li>
+ * <li>For cookies without a value, the '=' is not required after the name as some browsers do not sent it.</li>
  * </ul>
- *
- * <p>Implementation note:<br>
- * This class has been carefully tuned. Before committing any changes, ensure
- * that the TesterCookiePerformance unit test continues to give results within
- * 1% for the old and new parsers.</p>
+ * <p>
+ * Implementation note:<br>
+ * This class has been carefully tuned. Before committing any changes, ensure that the TesterCookiePerformance unit test
+ * continues to give results within 1% for the old and new parsers.
+ * </p>
  */
 public class Cookie {
 
     private static final Log log = LogFactory.getLog(Cookie.class);
     private static final UserDataHelper invalidCookieLog = new UserDataHelper(log);
-    private static final StringManager sm =
-            StringManager.getManager("org.apache.tomcat.util.http.parser");
+    private static final StringManager sm = StringManager.getManager("org.apache.tomcat.util.http.parser");
 
     private static final boolean isCookieOctet[] = new boolean[256];
     private static final boolean isText[] = new boolean[256];
@@ -64,10 +65,10 @@ public class Cookie {
 
     static {
         // %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E (RFC6265)
-        // %x80 to %xFF                                 (UTF-8)
+        // %x80 to %xFF (UTF-8)
         for (int i = 0; i < 256; i++) {
-            if (i < 0x21 || i == QUOTE_BYTE || i == COMMA_BYTE ||
-                    i == SEMICOLON_BYTE || i == SLASH_BYTE || i == DEL_BYTE) {
+            if (i < 0x21 || i == QUOTE_BYTE || i == COMMA_BYTE || i == SEMICOLON_BYTE || i == SLASH_BYTE ||
+                    i == DEL_BYTE) {
                 isCookieOctet[i] = false;
             } else {
                 isCookieOctet[i] = true;
@@ -88,8 +89,7 @@ public class Cookie {
     }
 
 
-    public static void parseCookie(byte[] bytes, int offset, int len,
-            ServerCookies serverCookies) {
+    public static void parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies) {
 
         // ByteBuffer is used throughout this parser as it allows the byte[]
         // and position information to be easily passed between parsing methods
@@ -146,7 +146,7 @@ public class Cookie {
 
 
     private static void skipLWS(ByteBuffer bb) {
-        while(bb.hasRemaining()) {
+        while (bb.hasRemaining()) {
             byte b = bb.get();
             if (b != TAB_BYTE && b != SPACE_BYTE) {
                 bb.rewind();
@@ -157,7 +157,7 @@ public class Cookie {
 
 
     private static void skipUntilSemiColon(ByteBuffer bb) {
-        while(bb.hasRemaining()) {
+        while (bb.hasRemaining()) {
             if (bb.get() == SEMICOLON_BYTE) {
                 break;
             }
@@ -180,8 +180,7 @@ public class Cookie {
 
 
     /**
-     * Similar to readCookieValue() but treats a comma as part of an invalid
-     * value.
+     * Similar to readCookieValue() but treats a comma as part of an invalid value.
      */
     private static ByteBuffer readCookieValueRfc6265(ByteBuffer bb) {
         boolean quoted = false;
@@ -250,8 +249,7 @@ public class Cookie {
 
 
     /**
-     * Custom implementation that skips many of the safety checks in
-     * {@link java.nio.ByteBuffer}.
+     * Custom implementation that skips many of the safety checks in {@link java.nio.ByteBuffer}.
      */
     private static class ByteBuffer {
 
diff --git a/java/org/apache/tomcat/util/http/parser/EntityTag.java b/java/org/apache/tomcat/util/http/parser/EntityTag.java
index f863ccca9f..132b480ca3 100644
--- a/java/org/apache/tomcat/util/http/parser/EntityTag.java
+++ b/java/org/apache/tomcat/util/http/parser/EntityTag.java
@@ -22,16 +22,14 @@ import java.io.StringReader;
 public class EntityTag {
 
     /**
-     * Parse the given input as (per RFC 7232) 1#entity-tag.
-     * Compare an ETag header with a resource ETag as described in RFC 7232
-     * section 2.3.2.
+     * Parse the given input as (per RFC 7232) 1#entity-tag. Compare an ETag header with a resource ETag as described in
+     * RFC 7232 section 2.3.2.
      *
      * @param input        The input to parse
      * @param compareWeak  Use weak comparison e.g. match "etag" with W/"etag"
      * @param resourceETag Resource's ETag
      *
-     * @return {@code true} if ETag matches, {@code false} if ETag doesn't match
-     *         or {@code null} if the input is invalid
+     * @return {@code true} if ETag matches, {@code false} if ETag doesn't match or {@code null} if the input is invalid
      *
      * @throws IOException If an I/O occurs during the parsing
      */
@@ -65,7 +63,7 @@ public class EntityTag {
             }
 
             // Note: RFC 2616 allowed quoted string
-            //       RFC 7232 does not allow " in the entity-tag
+            // RFC 7232 does not allow " in the entity-tag
             String value = HttpParser.readQuotedString(input, true);
             if (value == null) {
                 // Not a quoted string so the header is invalid
diff --git a/java/org/apache/tomcat/util/http/parser/Host.java b/java/org/apache/tomcat/util/http/parser/Host.java
index b867adc205..f9cb602bfe 100644
--- a/java/org/apache/tomcat/util/http/parser/Host.java
+++ b/java/org/apache/tomcat/util/http/parser/Host.java
@@ -35,11 +35,9 @@ public class Host {
      *
      * @param mb The host header value
      *
-     * @return The position of ':' that separates the host from the port or -1
-     *         if it is not present
+     * @return The position of ':' that separates the host from the port or -1 if it is not present
      *
-     * @throws IllegalArgumentException If the host header value is not
-     *         specification compliant
+     * @throws IllegalArgumentException If the host header value is not specification compliant
      */
     public static int parse(MessageBytes mb) {
         return parse(new MessageBytesReader(mb));
@@ -51,11 +49,9 @@ public class Host {
      *
      * @param string The host header value
      *
-     * @return The position of ':' that separates the host from the port or -1
-     *         if it is not present
+     * @return The position of ':' that separates the host from the port or -1 if it is not present
      *
-     * @throws IllegalArgumentException If the host header value is not
-     *         specification compliant
+     * @throws IllegalArgumentException If the host header value is not specification compliant
      */
     public static int parse(String string) {
         return parse(new StringReader(string));
diff --git a/java/org/apache/tomcat/util/http/parser/HttpParser.java b/java/org/apache/tomcat/util/http/parser/HttpParser.java
index 6975e3b53f..dbc3f7edb7 100644
--- a/java/org/apache/tomcat/util/http/parser/HttpParser.java
+++ b/java/org/apache/tomcat/util/http/parser/HttpParser.java
@@ -22,17 +22,12 @@ import java.io.Reader;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * HTTP header value parser implementation. Parsing HTTP headers as per RFC2616
- * is not always as simple as it first appears. For headers that only use tokens
- * the simple approach will normally be sufficient. However, for the other
- * headers, while simple code meets 99.9% of cases, there are often some edge
- * cases that make things far more complicated.
- *
- * The purpose of this parser is to let the parser worry about the edge cases.
- * It provides tolerant (where safe to do so) parsing of HTTP header values
- * assuming that wrapped header lines have already been unwrapped. (The Tomcat
- * header processing code does the unwrapping.)
- *
+ * HTTP header value parser implementation. Parsing HTTP headers as per RFC2616 is not always as simple as it first
+ * appears. For headers that only use tokens the simple approach will normally be sufficient. However, for the other
+ * headers, while simple code meets 99.9% of cases, there are often some edge cases that make things far more
+ * complicated. The purpose of this parser is to let the parser worry about the edge cases. It provides tolerant (where
+ * safe to do so) parsing of HTTP header values assuming that wrapped header lines have already been unwrapped. (The
+ * Tomcat header processing code does the unwrapping.)
  */
 public class HttpParser {
 
@@ -64,10 +59,9 @@ public class HttpParser {
             }
 
             // Separator
-            if (    i == '(' || i == ')' || i == '<' || i == '>'  || i == '@'  ||
-                    i == ',' || i == ';' || i == ':' || i == '\\' || i == '\"' ||
-                    i == '/' || i == '[' || i == ']' || i == '?'  || i == '='  ||
-                    i == '{' || i == '}' || i == ' ' || i == '\t') {
+            if (i == '(' || i == ')' || i == '<' || i == '>' || i == '@' || i == ',' || i == ';' || i == ':' ||
+                    i == '\\' || i == '\"' || i == '/' || i == '[' || i == ']' || i == '?' || i == '=' || i == '{' ||
+                    i == '}' || i == ' ' || i == '\t') {
                 IS_SEPARATOR[i] = true;
             }
 
@@ -77,7 +71,7 @@ public class HttpParser {
             }
 
             // Hex: 0-9, a-f, A-F
-            if ((i >= '0' && i <='9') || (i >= 'a' && i <= 'f') || (i >= 'A' && i <= 'F')) {
+            if ((i >= '0' && i <= '9') || (i >= 'a' && i <= 'f') || (i >= 'A' && i <= 'F')) {
                 IS_HEX[i] = true;
             }
 
@@ -103,12 +97,12 @@ public class HttpParser {
                 IS_UNRESERVED[i] = true;
             }
 
-            if (i == '!' || i == '$' || i == '&' || i == '\'' || i == '(' || i == ')' || i == '*' ||
-                    i == '+' || i == ',' || i == ';' || i == '=') {
+            if (i == '!' || i == '$' || i == '&' || i == '\'' || i == '(' || i == ')' || i == '*' || i == '+' ||
+                    i == ',' || i == ';' || i == '=') {
                 IS_SUBDELIM[i] = true;
             }
 
-            // userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )
+            // userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
             if (IS_UNRESERVED[i] || i == '%' || IS_SUBDELIM[i] || i == ':') {
                 IS_USERINFO[i] = true;
             }
@@ -116,8 +110,8 @@ public class HttpParser {
             // The characters that are normally not permitted for which the
             // restrictions may be relaxed when used in the path and/or query
             // string
-            if (i == '\"' || i == '<' || i == '>' || i == '[' || i == '\\' || i == ']' ||
-                    i == '^' || i == '`'  || i == '{' || i == '|' || i == '}') {
+            if (i == '\"' || i == '<' || i == '>' || i == '[' || i == '\\' || i == ']' || i == '^' || i == '`' ||
+                    i == '{' || i == '|' || i == '}') {
                 IS_RELAXABLE[i] = true;
             }
         }
@@ -136,16 +130,14 @@ public class HttpParser {
             // Not valid for request target.
             // Combination of multiple rules from RFC7230 and RFC 3986. Must be
             // ASCII, no controls plus a few additional characters excluded
-            if (IS_CONTROL[i] ||
-                    i == ' ' || i == '\"' || i == '#' || i == '<' || i == '>' || i == '\\' ||
-                    i == '^' || i == '`'  || i == '{' || i == '|' || i == '}') {
+            if (IS_CONTROL[i] || i == ' ' || i == '\"' || i == '#' || i == '<' || i == '>' || i == '\\' || i == '^' ||
+                    i == '`' || i == '{' || i == '|' || i == '}') {
                 IS_NOT_REQUEST_TARGET[i] = true;
             }
 
             /*
-             * absolute-path  = 1*( "/" segment )
-             * segment        = *pchar
-             * pchar          = unreserved / pct-encoded / sub-delims / ":" / "@"
+             * absolute-path = 1*( "/" segment ) segment = *pchar pchar = unreserved / pct-encoded / sub-delims / ":" /
+             * "@"
              *
              * Note pchar allows everything userinfo allows plus "@"
              */
@@ -154,7 +146,7 @@ public class HttpParser {
             }
 
             /*
-             * query          = *( pchar / "/" / "?" )
+             * query = *( pchar / "/" / "?" )
              *
              * Note query allows everything absolute-path allows plus "?"
              */
@@ -219,7 +211,7 @@ public class HttpParser {
         }
 
         StringBuilder result = new StringBuilder();
-        for (int i = start ; i < end; i++) {
+        for (int i = start; i < end; i++) {
             char c = input.charAt(i);
             if (input.charAt(i) == '\\') {
                 i++;
@@ -248,17 +240,14 @@ public class HttpParser {
 
 
     /**
-     * Is the provided String a token as per RFC 7230?
-     * <br>
-     * Note: token = 1 * tchar (RFC 7230)
-     * <br>
-     * Since a token requires at least 1 tchar, {@code null} and the empty
-     * string ({@code ""}) are not considered to be valid tokens.
+     * Is the provided String a token as per RFC 7230? <br>
+     * Note: token = 1 * tchar (RFC 7230) <br>
+     * Since a token requires at least 1 tchar, {@code null} and the empty string ({@code ""}) are not considered to be
+     * valid tokens.
      *
      * @param s The string to test
      *
-     * @return {@code true} if the string is a valid token, otherwise
-     *         {@code false}
+     * @return {@code true} if the string is a valid token, otherwise {@code false}
      */
     public static boolean isToken(String s) {
         if (s == null) {
@@ -336,17 +325,14 @@ public class HttpParser {
 
 
     /**
-     * Is the provided String a scheme as per RFC 3986?
-     * <br>
-     * Note: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-     * <br>
-     * Since a scheme requires at least 1 ALPHA, {@code null} and the empty
-     * string ({@code ""}) are not considered to be valid tokens.
+     * Is the provided String a scheme as per RFC 3986? <br>
+     * Note: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) <br>
+     * Since a scheme requires at least 1 ALPHA, {@code null} and the empty string ({@code ""}) are not considered to be
+     * valid tokens.
      *
      * @param s The string to test
      *
-     * @return {@code true} if the string is a valid scheme, otherwise
-     *         {@code false}
+     * @return {@code true} if the string is a valid scheme, otherwise {@code false}
      */
     public static boolean isScheme(String s) {
         if (s == null) {
@@ -453,9 +439,8 @@ public class HttpParser {
     }
 
     /**
-     * @return  the token if one was found, the empty string if no data was
-     *          available to read or <code>null</code> if data other than a
-     *          token was found
+     * @return the token if one was found, the empty string if no data was available to read or <code>null</code> if
+     *             data other than a token was found
      */
     static String readToken(Reader input) throws IOException {
         StringBuilder result = new StringBuilder();
@@ -481,8 +466,8 @@ public class HttpParser {
     }
 
     /**
-     * @return  the digits if any were found, the empty string if no data was
-     *          found or if data other than digits was found
+     * @return the digits if any were found, the empty string if no data was found or if data other than digits was
+     *             found
      */
     static String readDigits(Reader input) throws IOException {
         StringBuilder result = new StringBuilder();
@@ -504,8 +489,7 @@ public class HttpParser {
     }
 
     /**
-     * @return  the number if digits were found, -1 if no data was found
-     *          or if data other than digits was found
+     * @return the number if digits were found, -1 if no data was found or if data other than digits was found
      */
     static long readLong(Reader input) throws IOException {
         String digits = readDigits(input);
@@ -518,9 +502,8 @@ public class HttpParser {
     }
 
     /**
-     * @return the quoted string if one was found, null if data other than a
-     *         quoted string was found or null if the end of data was reached
-     *         before the quoted string was terminated
+     * @return the quoted string if one was found, null if data other than a quoted string was found or null if the end
+     *             of data was reached before the quoted string was terminated
      */
     static String readQuotedString(Reader input, boolean returnQuoted) throws IOException {
 
@@ -558,8 +541,7 @@ public class HttpParser {
         return result.toString();
     }
 
-    static String readTokenOrQuotedString(Reader input, boolean returnQuoted)
-            throws IOException {
+    static String readTokenOrQuotedString(Reader input, boolean returnQuoted) throws IOException {
 
         // Peek at next character to enable correct method to be called
         int c = skipLws(input);
@@ -572,16 +554,13 @@ public class HttpParser {
     }
 
     /**
-     * Token can be read unambiguously with or without surrounding quotes so
-     * this parsing method for token permits optional surrounding double quotes.
-     * This is not defined in any RFC. It is a special case to handle data from
-     * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8
-     * &amp; 9, Apple Safari for OSX and iOS) that add quotes to values that
-     * should be tokens.
+     * Token can be read unambiguously with or without surrounding quotes so this parsing method for token permits
+     * optional surrounding double quotes. This is not defined in any RFC. It is a special case to handle data from
+     * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8 &amp; 9, Apple Safari for OSX and iOS)
+     * that add quotes to values that should be tokens.
      *
-     * @return the token if one was found, null if data other than a token or
-     *         quoted token was found or null if the end of data was reached
-     *         before a quoted token was terminated
+     * @return the token if one was found, null if data other than a token or quoted token was found or null if the end
+     *             of data was reached before a quoted token was terminated
      */
     static String readQuotedToken(Reader input) throws IOException {
 
@@ -626,18 +605,15 @@ public class HttpParser {
     }
 
     /**
-     * LHEX can be read unambiguously with or without surrounding quotes so this
-     * parsing method for LHEX permits optional surrounding double quotes. Some
-     * buggy clients (libwww-perl for DIGEST auth) are known to send quoted LHEX
-     * when the specification requires just LHEX.
-     *
+     * LHEX can be read unambiguously with or without surrounding quotes so this parsing method for LHEX permits
+     * optional surrounding double quotes. Some buggy clients (libwww-perl for DIGEST auth) are known to send quoted
+     * LHEX when the specification requires just LHEX.
      * <p>
-     * LHEX are, literally, lower-case hexadecimal digits. This implementation
-     * allows for upper-case digits as well, converting the returned value to
-     * lower-case.
+     * LHEX are, literally, lower-case hexadecimal digits. This implementation allows for upper-case digits as well,
+     * converting the returned value to lower-case.
      *
-     * @return  the sequence of LHEX (minus any surrounding quotes) if any was
-     *          found, or <code>null</code> if data other LHEX was found
+     * @return the sequence of LHEX (minus any surrounding quotes) if any was found, or <code>null</code> if data other
+     *             LHEX was found
      */
     static String readLhex(Reader input) throws IOException {
 
@@ -762,9 +738,8 @@ public class HttpParser {
 
 
     /**
-     * @return If inIPv6 is false, the position of ':' that separates the host
-     *         from the port or -1 if it is not present. If inIPv6 is true, the
-     *         number of characters read
+     * @return If inIPv6 is false, the position of ':' that separates the host from the port or -1 if it is not present.
+     *             If inIPv6 is true, the number of characters read
      */
     static int readHostIPv4(Reader reader, boolean inIPv6) throws IOException {
         int octet = -1;
@@ -783,8 +758,7 @@ public class HttpParser {
                     octetCount++;
                     octet = -1;
                 } else if (inIPv6 || octet == -1) {
-                    throw new IllegalArgumentException(
-                            sm.getString("http.invalidOctet", Integer.toString(octet)));
+                    throw new IllegalArgumentException(sm.getString("http.invalidOctet", Integer.toString(octet)));
                 } else {
                     // Might not be an IPv4 address. Could be a host / FQDN with
                     // a fully numeric component.
@@ -831,8 +805,8 @@ public class HttpParser {
                 reader.reset();
                 return readHostDomainName(reader);
             } else {
-                throw new IllegalArgumentException(sm.getString(
-                        "http.illegalCharacterIpv4", Character.toString((char) c)));
+                throw new IllegalArgumentException(
+                        sm.getString("http.illegalCharacterIpv4", Character.toString((char) c)));
             }
             pos++;
         } while (true);
@@ -854,8 +828,7 @@ public class HttpParser {
 
 
     /**
-     * @return The position of ':' that separates the host from the port or -1
-     *         if it is not present
+     * @return The position of ':' that separates the host from the port or -1 if it is not present
      */
     static int readHostIPv6(Reader reader) throws IOException {
         // Must start with '['
@@ -887,16 +860,15 @@ public class HttpParser {
                     throw new IllegalArgumentException(sm.getString("http.invalidHextet"));
                 }
             } else if (c == ':') {
-                if (precedingColonsCount >=2 ) {
+                if (precedingColonsCount >= 2) {
                     // ::: is not allowed
                     throw new IllegalArgumentException(sm.getString("http.tooManyColons"));
                 } else {
-                    if(precedingColonsCount == 1) {
+                    if (precedingColonsCount == 1) {
                         // End of ::
-                        if (parsedDoubleColon ) {
+                        if (parsedDoubleColon) {
                             // Only allowed one :: sequence
-                            throw new IllegalArgumentException(
-                                    sm.getString("http.tooManyDoubleColons"));
+                            throw new IllegalArgumentException(sm.getString("http.tooManyDoubleColons"));
                         }
                         parsedDoubleColon = true;
                         // :: represents at least one h16 block
@@ -925,35 +897,31 @@ public class HttpParser {
                     throw new IllegalArgumentException(sm.getString("http.invalidIpv4Location"));
                 }
             } else {
-                throw new IllegalArgumentException(sm.getString(
-                        "http.illegalCharacterIpv6", Character.toString((char) c)));
+                throw new IllegalArgumentException(
+                        sm.getString("http.illegalCharacterIpv6", Character.toString((char) c)));
             }
             pos++;
         } while (true);
 
         if (h16Count > 8) {
-            throw new IllegalArgumentException(
-                    sm.getString("http.tooManyHextets", Integer.toString(h16Count)));
+            throw new IllegalArgumentException(sm.getString("http.tooManyHextets", Integer.toString(h16Count)));
         } else if (h16Count != 8 && !parsedDoubleColon) {
-            throw new IllegalArgumentException(
-                    sm.getString("http.tooFewHextets", Integer.toString(h16Count)));
+            throw new IllegalArgumentException(sm.getString("http.tooFewHextets", Integer.toString(h16Count)));
         }
 
         c = reader.read();
         if (c == ':') {
             return validatePort(reader, pos);
         } else {
-            if(c == -1) {
+            if (c == -1) {
                 return -1;
             }
-            throw new IllegalArgumentException(
-                    sm.getString("http.illegalAfterIpv6", Character.toString((char) c)));
+            throw new IllegalArgumentException(sm.getString("http.illegalAfterIpv6", Character.toString((char) c)));
         }
     }
 
     /**
-     * @return The position of ':' that separates the host from the port or -1
-     *         if it is not present
+     * @return The position of ':' that separates the host from the port or -1 if it is not present
      */
     static int readHostDomainName(Reader reader) throws IOException {
         DomainParseState state = DomainParseState.NEW;
@@ -986,9 +954,9 @@ public class HttpParser {
     }
 
 
-     /**
-     * Skips all characters until EOF or the specified target is found. Normally
-     * used to skip invalid input until the next separator.
+    /**
+     * Skips all characters until EOF or the specified target is found. Normally used to skip invalid input until the
+     * next separator.
      */
     static SkipResult skipUntil(Reader input, int c, char target) throws IOException {
         while (c != -1 && c != target) {
@@ -1016,13 +984,13 @@ public class HttpParser {
 
 
     private enum DomainParseState {
-        NEW(     true, false, false, false, "http.invalidCharacterDomain.atStart"),
-        ALPHA(   true,  true,  true,  true, "http.invalidCharacterDomain.afterLetter"),
-        NUMERIC( true,  true,  true,  true, "http.invalidCharacterDomain.afterNumber"),
-        PERIOD(  true, false, false,  true, "http.invalidCharacterDomain.afterPeriod"),
-        HYPHEN(  true,  true, false, false, "http.invalidCharacterDomain.afterHyphen"),
-        COLON(  false, false, false, false, "http.invalidCharacterDomain.afterColon"),
-        END(    false, false, false, false, "http.invalidCharacterDomain.atEnd");
+        NEW(true, false, false, false, "http.invalidCharacterDomain.atStart"),
+        ALPHA(true, true, true, true, "http.invalidCharacterDomain.afterLetter"),
+        NUMERIC(true, true, true, true, "http.invalidCharacterDomain.afterNumber"),
+        PERIOD(true, false, false, true, "http.invalidCharacterDomain.afterPeriod"),
+        HYPHEN(true, true, false, false, "http.invalidCharacterDomain.afterHyphen"),
+        COLON(false, false, false, false, "http.invalidCharacterDomain.afterColon"),
+        END(false, false, false, false, "http.invalidCharacterDomain.atEnd");
 
         private final boolean mayContinue;
         private final boolean allowsHyphen;
@@ -1030,8 +998,8 @@ public class HttpParser {
         private final boolean allowsEnd;
         private final String errorMsg;
 
-        DomainParseState(boolean mayContinue, boolean allowsHyphen, boolean allowsPeriod,
-                boolean allowsEnd, String errorMsg) {
+        DomainParseState(boolean mayContinue, boolean allowsHyphen, boolean allowsPeriod, boolean allowsEnd,
+                String errorMsg) {
             this.mayContinue = mayContinue;
             this.allowsHyphen = allowsHyphen;
             this.allowsPeriod = allowsPeriod;
@@ -1048,8 +1016,7 @@ public class HttpParser {
                 if (allowsEnd) {
                     return END;
                 } else {
-                    throw new IllegalArgumentException(
-                            sm.getString("http.invalidSegmentEndState", this.name()));
+                    throw new IllegalArgumentException(sm.getString("http.invalidSegmentEndState", this.name()));
                 }
             } else if (HttpParser.isAlpha(c)) {
                 return ALPHA;
@@ -1059,26 +1026,23 @@ public class HttpParser {
                 if (allowsPeriod) {
                     return PERIOD;
                 } else {
-                    throw new IllegalArgumentException(sm.getString(errorMsg,
-                            Character.toString((char) c)));
+                    throw new IllegalArgumentException(sm.getString(errorMsg, Character.toString((char) c)));
                 }
             } else if (c == ':') {
                 if (allowsEnd) {
                     return COLON;
                 } else {
-                    throw new IllegalArgumentException(sm.getString(errorMsg,
-                            Character.toString((char) c)));
+                    throw new IllegalArgumentException(sm.getString(errorMsg, Character.toString((char) c)));
                 }
             } else if (c == '-') {
                 if (allowsHyphen) {
                     return HYPHEN;
                 } else {
-                    throw new IllegalArgumentException(sm.getString(errorMsg,
-                            Character.toString((char) c)));
+                    throw new IllegalArgumentException(sm.getString(errorMsg, Character.toString((char) c)));
                 }
             } else {
-                throw new IllegalArgumentException(sm.getString(
-                        "http.illegalCharacterDomain", Character.toString((char) c)));
+                throw new IllegalArgumentException(
+                        sm.getString("http.illegalCharacterDomain", Character.toString((char) c)));
             }
         }
     }
diff --git a/java/org/apache/tomcat/util/http/parser/MediaType.java b/java/org/apache/tomcat/util/http/parser/MediaType.java
index 52203cf3de..f89f12444b 100644
--- a/java/org/apache/tomcat/util/http/parser/MediaType.java
+++ b/java/org/apache/tomcat/util/http/parser/MediaType.java
@@ -72,7 +72,7 @@ public class MediaType {
                     result.append(type);
                     result.append('/');
                     result.append(subtype);
-                    for (Map.Entry<String, String> entry : parameters.entrySet()) {
+                    for (Map.Entry<String,String> entry : parameters.entrySet()) {
                         String value = entry.getValue();
                         if (value == null || value.length() == 0) {
                             continue;
@@ -98,7 +98,7 @@ public class MediaType {
                     result.append(type);
                     result.append('/');
                     result.append(subtype);
-                    for (Map.Entry<String, String> entry : parameters.entrySet()) {
+                    for (Map.Entry<String,String> entry : parameters.entrySet()) {
                         if (entry.getKey().equalsIgnoreCase("charset")) {
                             continue;
                         }
@@ -119,7 +119,9 @@ public class MediaType {
      * Parses a MediaType value, either from an HTTP header or from an application.
      *
      * @param input a reader over the header text
+     *
      * @return a MediaType parsed from the input, or null if not valid
+     *
      * @throws IOException if there was a problem reading the input
      */
     public static MediaType parseMediaType(StringReader input) throws IOException {
diff --git a/java/org/apache/tomcat/util/http/parser/MediaTypeCache.java b/java/org/apache/tomcat/util/http/parser/MediaTypeCache.java
index 191aef307c..5495d55bec 100644
--- a/java/org/apache/tomcat/util/http/parser/MediaTypeCache.java
+++ b/java/org/apache/tomcat/util/http/parser/MediaTypeCache.java
@@ -33,14 +33,13 @@ public class MediaTypeCache {
     }
 
     /**
-     * Looks in the cache and returns the cached value if one is present. If no
-     * match exists in the cache, a new parser is created, the input parsed and
-     * the results placed in the cache and returned to the user.
+     * Looks in the cache and returns the cached value if one is present. If no match exists in the cache, a new parser
+     * is created, the input parsed and the results placed in the cache and returned to the user.
      *
      * @param input The content-type header value to parse
-     * @return      The results are provided as a two element String array. The
-     *                  first element is the media type less the charset and
-     *                  the second element is the charset
+     *
+     * @return The results are provided as a two element String array. The first element is the media type less the
+     *             charset and the second element is the charset
      */
     public String[] parse(String input) {
         String[] result = cache.get(input);
@@ -56,7 +55,7 @@ public class MediaTypeCache {
             // Ignore - return null
         }
         if (m != null) {
-            result = new String[] {m.toStringNoCharset(), m.getCharset()};
+            result = new String[] { m.toStringNoCharset(), m.getCharset() };
             cache.put(input, result);
         }
 
diff --git a/java/org/apache/tomcat/util/http/parser/TokenList.java b/java/org/apache/tomcat/util/http/parser/TokenList.java
index d805c61841..b2c15fb909 100644
--- a/java/org/apache/tomcat/util/http/parser/TokenList.java
+++ b/java/org/apache/tomcat/util/http/parser/TokenList.java
@@ -31,16 +31,13 @@ public class TokenList {
 
 
     /**
-     * Parses an enumeration of header values of the form 1#token, forcing all
-     * parsed values to lower case.
+     * Parses an enumeration of header values of the form 1#token, forcing all parsed values to lower case.
      *
      * @param inputs     The headers to parse
-     * @param collection The Collection (usually a list or a set) to which the
-     *                       parsed tokens should be added
+     * @param collection The Collection (usually a list or a set) to which the parsed tokens should be added
      *
-     * @return {@code true} if the header values were parsed cleanly and at
-     *         least one token was found, otherwise {@code false} (e.g. if a
-     *         non-token value was encountered)
+     * @return {@code true} if the header values were parsed cleanly and at least one token was found, otherwise
+     *             {@code false} (e.g. if a non-token value was encountered)
      *
      * @throws IOException If an I/O error occurs reading the header
      */
@@ -59,16 +56,13 @@ public class TokenList {
 
 
     /**
-     * Parses a header of the form 1#token, forcing all parsed values to lower
-     * case.
+     * Parses a header of the form 1#token, forcing all parsed values to lower case.
      *
      * @param input      The header to parse
-     * @param collection The Collection (usually a list or a set) to which the
-     *                       parsed tokens should be added
+     * @param collection The Collection (usually a list or a set) to which the parsed tokens should be added
      *
-     * @return {@code true} if the header values were parsed cleanly and at
-     *         least one token was found, otherwise {@code false} (e.g. if a
-     *         non-token value was encountered)
+     * @return {@code true} if the header values were parsed cleanly and at least one token was found, otherwise
+     *             {@code false} (e.g. if a non-token value was encountered)
      *
      * @throws IOException If an I/O error occurs reading the header
      */
diff --git a/java/org/apache/tomcat/util/http/parser/Upgrade.java b/java/org/apache/tomcat/util/http/parser/Upgrade.java
index 5e566a1e52..60c754ab22 100644
--- a/java/org/apache/tomcat/util/http/parser/Upgrade.java
+++ b/java/org/apache/tomcat/util/http/parser/Upgrade.java
@@ -55,7 +55,7 @@ public class Upgrade {
     }
 
 
-    public static List<Upgrade> parse (Enumeration<String> headerValues) {
+    public static List<Upgrade> parse(Enumeration<String> headerValues) {
         try {
             List<Upgrade> result = new ArrayList<>();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org