Andrew Baumann created DROOLS-2806:
--------------------------------------
Summary: ReleaseId created by KieServicesImpl can not be used to update a
snapshot every time.
Key: DROOLS-2806
URL:
https://issues.jboss.org/browse/DROOLS-2806
Project: Drools
Issue Type: Feature Request
Affects Versions: 7.9.0.Final
Reporter: Andrew Baumann
Assignee: Mario Fusco
KieServicesImpl generates a ReleaseId with method
"KieServices.Factory.get().newReleaseId(groupId, artifactId, version);" This
implementation has the base class of AFReleaseIdImpl. The property "String
snapshotVersion" of this releaseId is never set through the KieServices factory
method. This mainly impacts embedded scenarios. ReleaseIds created through the
AFReleaseIdImpl.adapt(...) method do have the snapshotVersion string set. The
snapshotVersion property will be used in the KieMavenRepositoryImpl to force load the
snapshot artifact every time.
KieMavenRepositoryImpl:load(...) "String oldSnapshotVersion =
((ReleaseIdImpl)kieModule.getReleaseId()).getSnapshotVersion();"
This casting and accessing the snapshotVersion string might not be ideal. The check of the
version ending in "-SNAPSHOT" could be checked in kieMavenRepositoryImpl to not
rely on the cast. Another fix could be having the responsibility of setting the
snapshotVersion string belong to the AFReleaseIdImpl class. Every time the version of the
implementation releaseId class changes, "isSnapshot" is evaluated and
snapshotVersion is set accordingly.
A workaround to the KieServicesImpl factory not setting the snapshotVersion string is to
set it manually. Example Client Code:
public void loadNewKieContainerVersion(String groupId, String artifactId, String version)
{
ReleaseId releaseId = KieServices.Factory.get().newReleaseId(groupId, artifactId,
version);
Boolean isSnapshot = releaseId.isSnapshot();
if (isSnapshot && (ReleaseIdImpl) releaseId != null
&& ((ReleaseIdImpl) releaseId).getSnapshotVersion() == null) {
((ReleaseIdImpl) releaseId).setSnapshotVersion(releaseId.getVersion());
}
loadNewKieContainerVersion(releaseId);
}
The fix could also get rid to manually set the snapshot version in DROOLS-2591.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)