Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCOMPILER-592] - IndexOutOfBoundsException when project.build.output… #244

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

thijsrijpert
Copy link
Contributor

@thijsrijpert thijsrijpert commented May 31, 2024

…Timestamp is empty

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCOMPILER-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCOMPILER-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@thijsrijpert
Copy link
Contributor Author

From JIRA issue:

Due to a combination of plugins, it is possible for the project.build.outputTimestamp property to have an empty string as a value. This causes an IndexOutOfBoundsException on line 1242 when it tries to access the first character in the string.

This can be fixed by doing an isEmpty check before doing the charAt check. I will create an PR for this.

While this bug is caused by another plugin, I think this should be fixed in the compiler because the error returned (IndexOutOfBoundsException), is vague and hard to debug.

The workaround for this issue is setting the project.build.outputTimestamp property with an arbitrary value.

@@ -1239,7 +1239,9 @@ public void execute() throws MojoExecutionException, CompilationFailureException
}
}

if (outputTimestamp != null && (outputTimestamp.length() > 1 || Character.isDigit(outputTimestamp.charAt(0)))) {
if (outputTimestamp != null
&& !outputTimestamp.isEmpty()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to understand how the value can be empty: <foo/>? This basically can happen in any plugin using this value, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it would be set by another plugin. The project I was working on has a lot of plugins, so I would not know which plugin exactly sets this value. When I encountered this issue, the value was not set in the projects pom, but it was a non-null empty string when this line was run, indicating it was set somewhere in the compilation process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I consider your fix as reasonable, I'd prefer to see the actual cause to be addressed as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I looked a bit further into this.

In the (internal) project I was working on was using the jgitver maven extension. This extension has a field named COMMIT_ISO_TIMESTAMP which contains the timestamp of the commit. If the repository does not have any commits, this timestamp is empty. The project I was working on was mapping this timestamp to the project.build.outputTimestamp to this maven commit timestamp in the parent pom, which I missed before.

This caused the above mentioned compiler error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you raised an upstream issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I created an upstream issue with jgitver. jgitver/jgitver-maven-plugin#184

Would you consider merging this pull request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give the maintainers some time to respond.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

On July 2th this MR has been approved by gnodet. Are we waiting for someone elses approval?

Regards,

Thijs Rijpert

@gnodet gnodet added this to the 4.0.0 milestone Jul 2, 2024
@olamy olamy added the bug Something isn't working label Aug 23, 2024
@olamy olamy merged commit 5b24341 into apache:master Aug 23, 2024
olamy pushed a commit that referenced this pull request Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants