File tree Expand file tree Collapse file tree
main/java/org/apache/commons/lang3
test/java/org/apache/commons/lang3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -496,9 +496,10 @@ private static String getCanonicalName(final String name) {
496496 className = className .substring (dim );
497497 if (className .startsWith ("L" )) {
498498 className = className .substring (1 , className .endsWith (";" ) ? className .length () - 1 : className .length ());
499- } else if (! className .isEmpty ( )) {
500- className = reverseAbbreviationMap .get (className . substring ( 0 , 1 ) );
499+ } else if (className .length () == 1 && reverseAbbreviationMap . containsKey ( className )) {
500+ className = reverseAbbreviationMap .get (className );
501501 }
502+
502503 final StringBuilder canonicalClassNameBuffer = new StringBuilder (className .length () + dim * 2 );
503504 canonicalClassNameBuffer .append (className );
504505 for (int i = 0 ; i < dim ; i ++) {
Original file line number Diff line number Diff line change @@ -3208,36 +3208,6 @@ public static boolean isAllUpperCase(final CharSequence cs) {
32083208 return true ;
32093209 }
32103210
3211- /**
3212- * Counts the number of uppercase characters in the given {@code CharSequence}.
3213- *
3214- * <p>{@code null} or an empty CharSequence returns {@code 0}.</p>
3215- *
3216- * <pre>
3217- * StringUtils.countUpperCaseLetters(null) = 0
3218- * StringUtils.countUpperCaseLetters("") = 0
3219- * StringUtils.countUpperCaseLetters("abc") = 0
3220- * StringUtils.countUpperCaseLetters("ABC") = 3
3221- * StringUtils.countUpperCaseLetters("AbC1") = 2
3222- * </pre>
3223- *
3224- * @param cs the CharSequence to check, may be null
3225- * @return the number of uppercase characters in the CharSequence, or {@code 0} if null/empty
3226- */
3227-
3228- public static int countUpperCaseLetters (final CharSequence cs ) {
3229- if (cs == null || cs .length () == 0 ) {
3230- return 0 ;
3231- }
3232-
3233- int count =0 ;
3234- for (int i =0 ; i <cs .length (); i ++) {
3235- if (Character .isUpperCase (cs .charAt (i ))) {
3236- count ++;
3237- }
3238- }
3239- return count ;
3240- }
32413211 /**
32423212 * Tests if the CharSequence contains only Unicode letters.
32433213 *
Original file line number Diff line number Diff line change @@ -237,6 +237,15 @@ public void test_getAllSuperclasses_Class() {
237237 assertNull (ClassUtils .getAllSuperclasses (null ));
238238 }
239239
240+ @ Test
241+ public void test_getShortCanonicalName_MalformedInput () {
242+ assertEquals ("String[]" , ClassUtils .getShortCanonicalName ("[String" ));
243+ }
244+ @ Test
245+ public void test_getShortCanonicalName_MissingSemicolon () {
246+ assertEquals ("String[]" , ClassUtils .getShortCanonicalName ("[LString" ));
247+ }
248+
240249 @ Test
241250 public void test_getCanonicalName_Class () {
242251 assertEquals ("org.apache.commons.lang3.ClassUtils" , ClassUtils .getCanonicalName (ClassUtils .class ));
Original file line number Diff line number Diff line change @@ -937,20 +937,6 @@ public void testIsAllUpperCase() {
937937 assertFalse (StringUtils .isAllUpperCase ("A1C" ));
938938 assertFalse (StringUtils .isAllUpperCase ("A/C" ));
939939 }
940-
941- /**
942- * Test for {@link StringUtils#countUpperCaseLetters(CharSequence)}.
943- */
944- @ Test
945- public void testCountUpperCaseLetters () {
946- assertEquals (5 , StringUtils .countUpperCaseLetters ("HELLO" ));
947- assertEquals (2 , StringUtils .countUpperCaseLetters ("HelloWorld" ));
948- assertEquals (0 , StringUtils .countUpperCaseLetters ("helloworld" ));
949- assertEquals (0 , StringUtils .countUpperCaseLetters ("1234" ));
950- assertEquals (0 , StringUtils .countUpperCaseLetters ("" ));
951- assertEquals (0 , StringUtils .countUpperCaseLetters (null ));
952- }
953-
954940 /**
955941 * Test for {@link StringUtils#isMixedCase(CharSequence)}.
956942 */
You can’t perform that action at this time.
0 commit comments