-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hi, wguttmn!
This error occurred at (JClassRegistry.java:467) when substring based on the logs below
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1911)
at org.exolab.castor.builder.JClassRegistry.ofTheSameType(JClassRegistry.java:467)
at org.exolab.castor.builder.JClassRegistry.printStatistics(JClassRegistry.java:424)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:753)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:690)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:587)
at org.codehaus.mojo.castor.GenerateMojo.processFile(GenerateMojo.java:530)
Here is the source code
private boolean ofTheSameType(final List<String> collisions) {
boolean allSame = true;
Iterator<String> iterator = collisions.iterator();
String typeString = null;
while (iterator.hasNext()) {
String xPath = iterator.next();
String newTypeString = xPath.substring(xPath.indexOf("[") + 1, xPath.indexOf("]"));// error occurred here
if (typeString != null) {
if (!typeString.equals(newTypeString)) {
allSame = false;
break;
}
} else {
typeString = newTypeString;
}
}
return allSame;
}
I do not know much about the castor.But, the xPath`s value may have many diffrent types, such as
1.normal
a[bcdefg]h
2.only have [
a[bcdefgh
3.only have ]
abcde]fgh
4.none
abcdefgh
5.strange
ab]cde[fgh
From these types, type 1 and 4 offen appear in xPath.But the method ofTheSameType does not handle type 4.
The above is my analysis, please refer to.
Metadata
Metadata
Assignees
Labels
No labels