Skip to content

Fix splitCommaSeparated behavior and add unit tests#962

Open
YCharanGowda wants to merge 4 commits intoapache:mainfrom
YCharanGowda:fix-stringutils-split
Open

Fix splitCommaSeparated behavior and add unit tests#962
YCharanGowda wants to merge 4 commits intoapache:mainfrom
YCharanGowda:fix-stringutils-split

Conversation

@YCharanGowda
Copy link

  • Fixed splitCommaSeparated to correctly handle inputs like ",,,"
  • Added unit tests for edge cases and normal cases
  • Ensured consistent behavior for empty elements

This change improves robustness of StringUtils without affecting existing logic.

Copy link
Contributor

@markt-asf markt-asf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't explained what problem this PR is trying to solve.

What is the correct behaviour for an input of ",,," and on what are you basing that assertion?

Where is the behaviour currently inconsistent? And how does it impact Tomcat?

Assert.fail("ParameterMap is not locked.");
} catch (UnsupportedOperationException expectedException) {
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is here for readability

} catch (UnsupportedOperationException expectedException) {
}
}
@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a space.

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tomcat.util.buf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely not. It is TOTALLY unacceptable to remove a license header.

Comment on lines -25 to 10
* None of these tests should throw a NPE.
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this explanatory comment removed?

Assert.assertEquals("", StringUtils.join((String[]) null));
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Assert.assertEquals("", StringUtils.join(null, ','));
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Assert.assertEquals("", sb.toString());
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Assert.assertEquals("", sb.toString());
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

}
}

// ✅ Added tests by Y Charan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line. We do not advertise authorship in the Tomcat code base.

Comment on lines +70 to +71
// 🔥

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this nonsense.

public void testEmptyParameterMap() {
Map<String,String[]> map = new ParameterMap<>();
Assert.assertTrue(map.isEmpty());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What has this got to do with the stated purpose of the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants