Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-2677

Migration of process instances fails when there are no process instances

    XMLWordPrintable

Details

    Description

      When the process definition includes a 'migrate-instances' entry like:

      <migrate-instances versions="*"/>
      

      The migration of process instances fails when there are no process instances in the jBPM database:

      EXCEPTION ###########################################
      16:15:36,793 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.DeployCmd@1a550
      f9
      java.lang.IndexOutOfBoundsException: fromIndex = -1
      at java.util.SubList.<init>(AbstractList.java:600)
      at java.util.RandomAccessSubList.<init>(AbstractList.java:758)
      at java.util.AbstractList.subList(AbstractList.java:468)
      at org.jbpm.pvm.internal.migration.InstanceMigrator.getProcessesToMigrate(InstanceMigrator.java:104)
      at org.jbpm.pvm.internal.migration.InstanceMigrator.getProcessInstancesToMigrate(InstanceMigrator.java:84)
      [..]

      This issue is caused by the following code in the InstanceMigrator class:

      private static List<ProcessDefinition> getProcessesToMigrate(String processDefinitionName, MigrationDescriptor migrationDescriptor) {
          RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);
          List<ProcessDefinition> processDefinitions = repositorySession
              .createProcessDefinitionQuery()
              .processDefinitionName(processDefinitionName)
              .orderAsc(ProcessDefinitionQuery.PROPERTY_VERSION)
              .list();
          int startIndex = calculateStartIndex(processDefinitions.size() - 1, migrationDescriptor);
          int endIndex = calculateEndIndex(processDefinitions.size() - 1, migrationDescriptor);
          if (startIndex > endIndex) startIndex = endIndex;
          return processDefinitions.subList(startIndex, endIndex);
        }
      

      No check is done to see if the list of processes (processDefinitions) is not empty.

      This issue causes our unit tests to fail since our unit tests start with an empty jBPM database.

      Attachments

        Activity

          People

            rebody HuiSheng Xu (Inactive)
            edgar-1 Edgar Vonk (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: