A DESCRIPTION OF THE PROBLEM :
Throw StringIndexOutOfBoundsException when testing sun.tools.jar.Manifest.isManifestName with empty input.
This method is unavailable in jdk1.8.0_301, but it still works in jdk1.8.0_292.
You can just replace API "charAt" with "startsWith", and this exception will not appear again.
This kind of reform has happened before, please refer to https://github.com/openjdk/jdk/commit/e341e35276315a5140ddec11a7e659d57328e9a0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The test case:
@Test
public void test_isManifestNam(){
String string0 = "";
sun.tools.jar.Manifest.isManifestName(string0);
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the input is empty, it should return false rather than StringIndexOutOfBoundsException.
ACTUAL -
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at sun.tools.jar.Manifest.isManifestName(Manifest.java:247)
---------- BEGIN SOURCE ----------
public static boolean isManifestName(String name) {
// remove leading /
if (name.charAt(0) == '/') {
name = name.substring(1, name.length());
}
// case insensitive
name = name.toUpperCase();
if (name.equals("META-INF/MANIFEST.MF")) {
return true;
}
return false;
}
---------- END SOURCE ----------
FREQUENCY : occasionally
Throw StringIndexOutOfBoundsException when testing sun.tools.jar.Manifest.isManifestName with empty input.
This method is unavailable in jdk1.8.0_301, but it still works in jdk1.8.0_292.
You can just replace API "charAt" with "startsWith", and this exception will not appear again.
This kind of reform has happened before, please refer to https://github.com/openjdk/jdk/commit/e341e35276315a5140ddec11a7e659d57328e9a0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The test case:
@Test
public void test_isManifestNam(){
String string0 = "";
sun.tools.jar.Manifest.isManifestName(string0);
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the input is empty, it should return false rather than StringIndexOutOfBoundsException.
ACTUAL -
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at sun.tools.jar.Manifest.isManifestName(Manifest.java:247)
---------- BEGIN SOURCE ----------
public static boolean isManifestName(String name) {
// remove leading /
if (name.charAt(0) == '/') {
name = name.substring(1, name.length());
}
// case insensitive
name = name.toUpperCase();
if (name.equals("META-INF/MANIFEST.MF")) {
return true;
}
return false;
}
---------- END SOURCE ----------
FREQUENCY : occasionally