Skip to content

Conversation

ryantse
Copy link
Contributor

@ryantse ryantse commented Jul 26, 2020

Changes the build system information to be conditionally set within the properties. In multi-threaded builds, without the optional put, a ConcurrentModificationException occurs as this information is written at the same time the object is being iterated over.

Context

Fixes #469.

Contributor Checklist

  • Added relevant integration or unit tests to verify the changes
  • Update the Readme or any other documentation (including relevant Javadoc)
  • Ensured that tests pass locally: mvn clean package
  • Ensured that the code meets the current checkstyle coding style definition: mvn clean verify -Pcheckstyle -Dmaven.test.skip=true -B

- Changes the build system information to be conditionally set
  within the properties. In multi-threaded builds, without the
  optional put, a ConcurrentModificationException occurs as this
  information is written at the same time the object is being
  iterated over.
@joschi
Copy link
Contributor

joschi commented Jul 27, 2020

@ryantse As far as I see maybePut is also not thread-safe, so even with the change, we would see ConcurrentModificationException in some cases.

If it was possible at all, it would be great if we could get the build server data only once and then share it with the invocations of the plugin in the Maven sub-modules.

Otherwise making BuildServerDataProvider thread-safe would be an option too.

- Removes the usages of the underlying HashMap functions on Properties objects that lack synchronization and are not thread safe.
@ryantse ryantse force-pushed the optional-build-information branch from dea8c65 to e0d9319 Compare July 27, 2020 17:09
@ryantse
Copy link
Contributor Author

ryantse commented Jul 27, 2020

@joschi: Thanks for the quick feedback. You're right that the original patch didn't fully correct the thread-safety issue. The only time this really is a problem is when injectAllReactorProjects is turned on along with additional properties being configured in sub-modules.

I have pushed another patch that more comprehensively addresses the issue. This patch removes all usage of the underlying HashMap functions in preference for equivalents in the Properties class. As Properties is properly synchronized, this mitigates all instances where multiple modules (and thus multiple threads) share the same object.

@ryantse
Copy link
Contributor Author

ryantse commented Jul 28, 2020

@TheSnoozer: Could you take a look at this pull request as well?

@ryantse
Copy link
Contributor Author

ryantse commented Aug 2, 2020

@TheSnoozer: Can this be merged or do you have any feedback on this patch? Thanks in advance!

@TheSnoozer
Copy link
Collaborator

Hi,
sorry for the delay here. Thanks for creating the Merge-Request with the needed changes. From what I can tell they look reasonable for me. Would this perhaps already mean we need to cut a 4.0.2 release (e.g. #507)? Perhaps could you confirm the changes fixed the issue locally? If so I'd just cut a release on the weekend.

@TheSnoozer TheSnoozer merged commit 6beb37d into git-commit-id:master Aug 3, 2020
@TheSnoozer TheSnoozer added this to the 4.0.2 milestone Aug 3, 2020
@TheSnoozer TheSnoozer mentioned this pull request Aug 3, 2020
4 tasks
@ryantse
Copy link
Contributor Author

ryantse commented Aug 4, 2020

@TheSnoozer: I was able to test the snapshot build of the plugin with our build system and it works well in my environment. It would be great if you could release a 4.0.2 with these changes.

@TheSnoozer
Copy link
Collaborator

Thanks for confirming! Will do a release on the weekend.

@TheSnoozer
Copy link
Collaborator

Now available as https://repo1.maven.org/maven2/pl/project13/maven/git-commit-id-plugin/4.0.2/. Thanks again for the investigation and pushing for the solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not thread safe when using injectAllReactorProjects.

3 participants