eclipse-ee4j / eclipse-ee4j/eclipselink-workbench

StringIndexOutOfBoundsException on ManifestInterrogator.getBuildNumber() with SNAPSHOT builds

Open
#8 4 comments 0 reactions 0 assignees View on GitHub

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.3
  • getBuildNumber() : SNAPSHOT

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.