Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-2806

ReleaseId created by KieServicesImpl can not be used to update a snapshot every time.

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 7.9.0.Final
    • None
    • None
    • NEW
    • NEW

      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.

            mfusco@redhat.com Mario Fusco
            rhn-gps-abaumann Andrew Baumann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: