You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2025/06/18 15:37:31 UTC
(tomcat) branch 11.0.x updated: Use Reader instead of explicit StringReader
This is an automated email from the ASF dual-hosted git repository.
schultz pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 6225882e85 Use Reader instead of explicit StringReader
6225882e85 is described below
commit 6225882e852dec53ba3c3e8ddad5c01cbeef924e
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org