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

schultz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 0801c8c3f7 Use Reader instead of explicit StringReader
0801c8c3f7 is described below

commit 0801c8c3f797f3db7af630cb59b678908832e45d
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed Jun 18 11:35:10 2025 -0400

    Use Reader instead of explicit StringReader
    
    Avoid double-assignment
---
 java/org/apache/tomcat/util/http/parser/MediaType.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/parser/MediaType.java 
b/java/org/apache/tomcat/util/http/parser/MediaType.java
index ff2a5f76d8..fc37f30761 100644
--- a/java/org/apache/tomcat/util/http/parser/MediaType.java
+++ b/java/org/apache/tomcat/util/http/parser/MediaType.java
@@ -17,7 +17,7 @@
 package org.apache.tomcat.util.http.parser;
 
 import java.io.IOException;
-import java.io.StringReader;
+import java.io.Reader;
 import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -124,7 +124,7 @@ public class MediaType {
      *
      * @throws IOException if there was a problem reading the input
      */
-    public static MediaType parseMediaType(StringReader input) throws 
IOException {
+    public static MediaType parseMediaType(Reader input) throws IOException {
 
         // Type (required)
         String type = HttpParser.readToken(input);
@@ -151,9 +151,11 @@ public class MediaType {
         while (lookForSemiColon == SkipResult.FOUND) {
             String attribute = HttpParser.readToken(input);
 
-            String value = "";
+            String value;
             if (HttpParser.skipConstant(input, "=") == SkipResult.FOUND) {
                 value = HttpParser.readTokenOrQuotedString(input, true);
+            } else {
+                value = "";
             }
 
             if (attribute != null) {


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

Reply via email to