From 8753511e73d4b72330752886cb9d5e9d0f5943ae Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Tue, 10 Mar 2026 18:52:24 +0530 Subject: [PATCH 1/7] Improve sentence in README for clarity --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 49602c130203..d84023d8b43c 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,5 @@ instructions for reporting a bug ### Contributing -Please see [CONTRIBUTING](CONTRIBUTING.md) for more info. +For information on how to contribute to Apache Tomcat, please see +[CONTRIBUTING.md](CONTRIBUTING.md). From b52d80268c1c176f80516b04895911757f6f4140 Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Sat, 14 Mar 2026 22:07:20 +0530 Subject: [PATCH 2/7] Add additional unit tests for compute and computeIfAbsent in ParameterMap --- .../catalina/util/TestParameterMap.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/util/TestParameterMap.java b/test/org/apache/catalina/util/TestParameterMap.java index 87ead7f60243..92d801a32b88 100644 --- a/test/org/apache/catalina/util/TestParameterMap.java +++ b/test/org/apache/catalina/util/TestParameterMap.java @@ -300,11 +300,37 @@ public void testEntrySetImmutabilityAfterLocked() { Assert.fail("ParameterMap is not locked."); } catch (UnsupportedOperationException expectedException) { } - try { entrySet.clear(); Assert.fail("ParameterMap is not locked."); } catch (UnsupportedOperationException expectedException) { } } + @Test + public void testComputeIfAbsentAfterLocked() { + ((ParameterMap) paramMap).setLocked(true); + + try { + paramMap.computeIfAbsent("param5", k -> new String[]{"value5"}); + Assert.fail("ParameterMap is not locked."); + } catch (IllegalStateException expectedException) { + } + } + + @Test + public void testComputeAfterLocked() { + ((ParameterMap) paramMap).setLocked(true); + + try { + paramMap.compute("param1", (k, v) -> new String[]{"changed"}); + Assert.fail("ParameterMap is not locked."); + } catch (IllegalStateException expectedException) { + } + } + + @Test + public void testEmptyParameterMap() { + Map map = new ParameterMap<>(); + Assert.assertTrue(map.isEmpty()); + } } \ No newline at end of file From 045db5fa92324ea8ce7c98ae8540e3fb6cf1759b Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Fri, 20 Mar 2026 16:26:18 +0530 Subject: [PATCH 3/7] Fix splitCommaSeparated behavior and add unit tests --- .../tomcat/util/buf/TestStringUtils.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/test/org/apache/tomcat/util/buf/TestStringUtils.java b/test/org/apache/tomcat/util/buf/TestStringUtils.java index b7ac950a2655..28b5fd6a2c41 100644 --- a/test/org/apache/tomcat/util/buf/TestStringUtils.java +++ b/test/org/apache/tomcat/util/buf/TestStringUtils.java @@ -1,19 +1,3 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.apache.tomcat.util.buf; import java.util.Collection; @@ -22,7 +6,7 @@ import org.junit.Test; /* - * None of these tests should throw a NPE. + * */ public class TestStringUtils { @@ -31,7 +15,6 @@ public void testNullArray() { Assert.assertEquals("", StringUtils.join((String[]) null)); } - @Test public void testNullArrayCharStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -39,19 +22,16 @@ public void testNullArrayCharStringBuilder() { Assert.assertEquals("", sb.toString()); } - @Test public void testNullCollection() { Assert.assertEquals("", StringUtils.join((Collection) null)); } - @Test public void testNullCollectionChar() { Assert.assertEquals("", StringUtils.join(null, ',')); } - @Test public void testNullIterableCharStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -59,7 +39,6 @@ public void testNullIterableCharStringBuilder() { Assert.assertEquals("", sb.toString()); } - @Test public void testNullArrayCharFunctionStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -67,11 +46,34 @@ public void testNullArrayCharFunctionStringBuilder() { Assert.assertEquals("", sb.toString()); } - @Test public void testNullIterableCharFunctionStringBuilder() { StringBuilder sb = new StringBuilder(); StringUtils.join((Iterable) null, ',', null, sb); Assert.assertEquals("", sb.toString()); } -} + + // ✅ Added tests by Y Charan + + @Test + public void testSplitCommaSeparatedOnlyCommas() { + String[] result = StringUtils.splitCommaSeparated(",,,"); + Assert.assertArrayEquals(new String[]{}, result); + } + + @Test + public void testSplitCommaSeparatedMultipleCommas() { + String[] result = StringUtils.splitCommaSeparated("a,,b"); + Assert.assertArrayEquals(new String[]{"a", "", "b"}, result); + } + + // 🔥 + + @Test + public void testJoinCollectionWithSeparator() { + Collection input = java.util.Arrays.asList("a", "b", "c"); + String result = StringUtils.join(input, ','); + + Assert.assertEquals("a,b,c", result); + } +} \ No newline at end of file From 1a49b9550bec6ab69cf1cd5d3e5958e1285cae68 Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Sat, 21 Mar 2026 16:51:25 +0530 Subject: [PATCH 4/7] Reverting the changes --- README.md | 3 +- .../catalina/util/TestParameterMap.java | 28 +---------- .../tomcat/util/buf/TestStringUtils.java | 48 +++++++++---------- 3 files changed, 25 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index d2257210320a..28f1161a4f94 100644 --- a/README.md +++ b/README.md @@ -74,5 +74,4 @@ instructions for reporting a bug ### Contributing -For information on how to contribute to Apache Tomcat, please see -[CONTRIBUTING.md](CONTRIBUTING.md). +Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information. diff --git a/test/org/apache/catalina/util/TestParameterMap.java b/test/org/apache/catalina/util/TestParameterMap.java index 92d801a32b88..87ead7f60243 100644 --- a/test/org/apache/catalina/util/TestParameterMap.java +++ b/test/org/apache/catalina/util/TestParameterMap.java @@ -300,37 +300,11 @@ public void testEntrySetImmutabilityAfterLocked() { Assert.fail("ParameterMap is not locked."); } catch (UnsupportedOperationException expectedException) { } + try { entrySet.clear(); Assert.fail("ParameterMap is not locked."); } catch (UnsupportedOperationException expectedException) { } } - @Test - public void testComputeIfAbsentAfterLocked() { - ((ParameterMap) paramMap).setLocked(true); - - try { - paramMap.computeIfAbsent("param5", k -> new String[]{"value5"}); - Assert.fail("ParameterMap is not locked."); - } catch (IllegalStateException expectedException) { - } - } - - @Test - public void testComputeAfterLocked() { - ((ParameterMap) paramMap).setLocked(true); - - try { - paramMap.compute("param1", (k, v) -> new String[]{"changed"}); - Assert.fail("ParameterMap is not locked."); - } catch (IllegalStateException expectedException) { - } - } - - @Test - public void testEmptyParameterMap() { - Map map = new ParameterMap<>(); - Assert.assertTrue(map.isEmpty()); - } } \ No newline at end of file diff --git a/test/org/apache/tomcat/util/buf/TestStringUtils.java b/test/org/apache/tomcat/util/buf/TestStringUtils.java index 28b5fd6a2c41..41129fc1aa16 100644 --- a/test/org/apache/tomcat/util/buf/TestStringUtils.java +++ b/test/org/apache/tomcat/util/buf/TestStringUtils.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.tomcat.util.buf; import java.util.Collection; @@ -6,7 +22,7 @@ import org.junit.Test; /* - * + * None of these tests should throw a NPE. */ public class TestStringUtils { @@ -15,6 +31,7 @@ public void testNullArray() { Assert.assertEquals("", StringUtils.join((String[]) null)); } + @Test public void testNullArrayCharStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -22,16 +39,19 @@ public void testNullArrayCharStringBuilder() { Assert.assertEquals("", sb.toString()); } + @Test public void testNullCollection() { Assert.assertEquals("", StringUtils.join((Collection) null)); } + @Test public void testNullCollectionChar() { Assert.assertEquals("", StringUtils.join(null, ',')); } + @Test public void testNullIterableCharStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -39,6 +59,7 @@ public void testNullIterableCharStringBuilder() { Assert.assertEquals("", sb.toString()); } + @Test public void testNullArrayCharFunctionStringBuilder() { StringBuilder sb = new StringBuilder(); @@ -46,34 +67,11 @@ public void testNullArrayCharFunctionStringBuilder() { Assert.assertEquals("", sb.toString()); } + @Test public void testNullIterableCharFunctionStringBuilder() { StringBuilder sb = new StringBuilder(); StringUtils.join((Iterable) null, ',', null, sb); Assert.assertEquals("", sb.toString()); } - - // ✅ Added tests by Y Charan - - @Test - public void testSplitCommaSeparatedOnlyCommas() { - String[] result = StringUtils.splitCommaSeparated(",,,"); - Assert.assertArrayEquals(new String[]{}, result); - } - - @Test - public void testSplitCommaSeparatedMultipleCommas() { - String[] result = StringUtils.splitCommaSeparated("a,,b"); - Assert.assertArrayEquals(new String[]{"a", "", "b"}, result); - } - - // 🔥 - - @Test - public void testJoinCollectionWithSeparator() { - Collection input = java.util.Arrays.asList("a", "b", "c"); - String result = StringUtils.join(input, ','); - - Assert.assertEquals("a,b,c", result); - } } \ No newline at end of file From b5d7313692805c709eb5f377b906b4c8f2948ef5 Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Sat, 21 Mar 2026 17:20:38 +0530 Subject: [PATCH 5/7] Reverted Readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28f1161a4f94..61d68bb45ff5 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,4 @@ instructions for reporting a bug ### Contributing -Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information. +Please see [CONTRIBUTING](CONTRIBUTING.md) for more information. From 82309867495fd6533f51674712a0cd8c74ccb92d Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Sat, 21 Mar 2026 17:27:11 +0530 Subject: [PATCH 6/7] Revert unintended changes to StringUtils --- FETCH_HEAD | 0 fix-stringutils-split | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 FETCH_HEAD create mode 100644 fix-stringutils-split diff --git a/FETCH_HEAD b/FETCH_HEAD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/fix-stringutils-split b/fix-stringutils-split new file mode 100644 index 000000000000..e69de29bb2d1 From 7aabdd00de7ac8cd4ca1ec0de81dd8e9a97df2da Mon Sep 17 00:00:00 2001 From: YCHARAN Date: Sat, 21 Mar 2026 17:33:04 +0530 Subject: [PATCH 7/7] Revert unintended change to StringUtils --- test/org/apache/tomcat/util/buf/TestStringUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/org/apache/tomcat/util/buf/TestStringUtils.java b/test/org/apache/tomcat/util/buf/TestStringUtils.java index 41129fc1aa16..a4d22f022218 100644 --- a/test/org/apache/tomcat/util/buf/TestStringUtils.java +++ b/test/org/apache/tomcat/util/buf/TestStringUtils.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.tomcat.util.buf; import java.util.Collection;