java.lang.ArrayIndexOutOfBoundsException caused due to broken versions

Symptoms:

Deployment fails with java.lang.ArrayIndexOutOfBoundsException error caused due to broken version sequences

Example error code

Caused by: com.botronsoft.jira.rollout.impl.merge.MergeException: Unable to apply change 'type: addition, object: JiraConfigurationRoot#root/JiraProject#EBTRESOSDES/JiraProjectVersion#tresos designer 2008.a, target object: JiraConfigurationRoot#root/JiraProject#EBTRESOSDES, feature: versions'
	at com.botronsoft.jira.rollout.impl.merge.AbstractMergeAdapter.notifyChanged(AbstractMergeAdapter.java:88)
	at com.botronsoft.jira.rollout.impl.merge.di.CacheRefreshInterceptor.invoke(CacheRefreshInterceptor.java:30)
	at com.botronsoft.jira.rollout.impl.merge.MainMergeAdapter.notifyChanged(MainMergeAdapter.java:54)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:356)
	at org.eclipse.emf.compare.merge.AbstractMerger.addAt(AbstractMerger.java:1222)
	at com.botronsoft.jira.rollout.model.diff.AtomicityAwareReferenceMerger.addInTarget(AtomicityAwareReferenceMerger.java:95)
	at org.eclipse.emf.compare.merge.ReferenceChangeMerger.accept(ReferenceChangeMerger.java:129)
	at org.eclipse.emf.compare.merge.AbstractMerger.copyDiff(AbstractMerger.java:796)
	at org.eclipse.emf.compare.merge.AbstractMerger.copyLeftToRight(AbstractMerger.java:819)
	at org.eclipse.emf.compare.merge.BatchMerger.copyAllLeftToRight(BatchMerger.java:150)
	at com.botronsoft.jira.rollout.impl.deploy.ConfigurationImportServiceImpl.importConfiguration(ConfigurationImportServiceImpl.java:214)
	at com.botronsoft.jira.rollout.impl.snapshot.SnapshotImportServiceImpl.importSnapshot(SnapshotImportServiceImpl.java:287)
	... 3 more

Caused by: java.lang.ArrayIndexOutOfBoundsException: 33 

Cause:

The problem is that the client's source environment has broken version sequences in the database. This can happen if they are deleting project versions from the database. In CMJ we are expecting that the sequences of project version to be following numbers but if something is deleted not from the Jira UI there are differences in the sequence numbering.

Resolution:

The simplest workaround is to check the sequences in the projectversion Database table and rearrange two versions and then create a new snapshot and try to deploy it.

Here in this example error - we need to rearrange the two versions for the project with this key: EBTRESOSDES and afterward return them to their original state.