GitHub user Enygma2002 opened a pull request:
https://github.com/apache/maven-indexer/pull/11
Add minimal information to a newly created artifact info (using the
IndexUtils method), linking it to the context it belongs to.
While trying to write an IndexCreator, I`ve discovered that the
ArtifactInfo instance that I received in the IndexCreator.updateDocument method
was improperly constructed.
Digging further, I discovered that the updateDocument method is called by
IndexUtils.updateDocument that, in turn, constructs its ArtifactInfo instance
by calling IndexUtils.constructArtifactInfo(doc, context).
It turns out that the IndexUtils.constructArtifactInfo method uses the
no-arguments constructor for creating an ArtifactInfo instance and relies on
the IndexCreators to populate it. However, **it does not set the repositoryId
or contextId fields on this new instance**, leaving it in an inconsistent state
(with values for the artifact, but without the ability to properly identify the
artifact, i.e. where it comes from).
The simple solution is to add this information right after the no-argument
constructor call and before the indexCreators, so that, in their run, the index
creators also become aware of the source of the artifactInfo that they are
augmenting.
As a bonus, looking at the call Hierarchy of the ArtifactInfo.setRepository
method it seems that there are about 4 places where this is done by hand as a
result of the bad behavior of IndexUtils.constructArtifactInfo, so making this
change might also remove a bit of duplicate code.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Enygma2002/maven-indexer
fix-artifact-info-construction
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/maven-indexer/pull/11.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #11
----
commit 6d87d0be5860b830af3ce74127cfe282403b29f3
Author: Eduard Moraru <[email protected]>
Date: 2015-01-12T17:40:01Z
Add minimal information to a newly created artifact info (using the
IndexUtils method), linking it to the context it belongs to.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]