eclipse-ee4j / eclipse-ee4j/eclipselink-workbench
StringIndexOutOfBoundsException on ManifestInterrogator.getBuildNumber() with SNAPSHOT builds
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 6
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
The ManifestInterrogator.getBuildNumber() function (in the package org.eclipse.persistence.tools.workbench.utility) try to extract the build number at the end of implementation version like that:
String specVersion = this.getVersionNumber();
String impVersion = this.getMainAttributeValue(Attributes.Name.IMPLEMENTATION_VERSION, this.defaults.defaultImplementationVersion());
return impVersion.substring(specVersion.length() + 1);
But, on snapshot builds, specVersion and impVersion values are identical ("2.7.3-SNAPSHOT" for example), so the following statement always fail:
return impVersion.substring(specVersion.length() + 1);
Simple fix
A simple fix can consist in removing the "-SNAPSHOT" suffix from the specification version number when it is present. Then, the "SNAPSHOT" word will be retained as the build number by the getBuildNumber() function.
Example:
public String getVersionNumber() {
final String version=this.getMainAttributeValue(Attributes.Name.SPECIFICATION_VERSION, this.defaults.defaultSpecificationVersion());
return
version.endsWith("-SNAPSHOT") ? version.substring(0, version.length() - 9) :
version;
}
With this source code, a "2.7.3-SNAPSHOT" version will produce the following results :
getVersionNumber(): 2.7.3getBuildNumber(): SNAPSHOT
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ManifestInterrogator.getBuildNumber() and getVersionNumber() in the org.eclipse.persistence.tools.workbench.utility package, then reproduce the failure with a 2.7.3-SNAPSHOT implementation version. Done means snapshot versions no longer raise StringIndexOutOfBoundsException and produce getVersionNumber() as 2.7.3 with getBuildNumber() as SNAPSHOT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100