garydgregory commented on PR #1391:
URL: https://github.com/apache/commons-lang/pull/1391#issuecomment-2917738306
Hello @abhisripathi
I don't think we should return bad output for bad input; bad input should
throw an IAE. Unfortunately, the current implementation is inconsistent,
sometimes it throws an exception, sometimes it's GIGO.
For example (now in git master):
```java
// Note that we throw RuntimeException (but not which one) for the
following bad inputs:
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName(""));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("["));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("[]"));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("[;"));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("[];"));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName(" "));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("[$"));
assertThrows(RuntimeException.class, () ->
ClassUtils.getShortCanonicalName("[$a"));
```
We should probably re-implement the heart of this parsing using regular
expressions instead of custom code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]