Multiple entries with same key: 10000=TEST-1 and 10000=TEST-1

Hi,

I’m having trouble updating JIRA Issue Links, using a plugin written in Java. It has to ‘rename’ the GlobalIDs of a series of RILs, so:

  • First, it executes the remoteIssueLinkService.validateDelete(...) and remoteIssueLinkService.validateCreate(...) for all links we plan to remove/add with a different globalId,
  • If none fails, it executes all of them,

The next time I want to update issue links, it fails with an exception I have no control upon:


[INFO] [talledLocalContainer] 2017-06-28 12:02:47,781 http-nio-2990-exec-2 ERROR admin 722x16000x1 zzz5g9 127.0.0.1 /rest/reqs/1/rename [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Multiple entries with same key: 10000=TEST-1 and 10000=TEST-1
[INFO] [talledLocalContainer] java.lang.IllegalArgumentException: Multiple entries with same key: 10000=TEST-1 and 10000=TEST-1
[INFO] [talledLocalContainer] 	at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150)
[INFO] [talledLocalContainer] 	at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104)
[INFO] [talledLocalContainer] 	at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70)
[INFO] [talledLocalContainer] 	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254)
[INFO] [talledLocalContainer] 	at com.google.common.collect.Maps.uniqueIndex(Maps.java:1166)
[INFO] [talledLocalContainer] 	at com.google.common.collect.Maps.uniqueIndex(Maps.java:1140)
[INFO] [talledLocalContainer] 	at com.atlassian.jira.bc.issue.link.DefaultRemoteIssueLinkService.findRemoteIssueLinksByGlobalId(DefaultRemoteIssueLinkService.java:174)
[INFO] [talledLocalContainer] 	... 3 filtered
[INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(Method.java:497)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:30)
[INFO] [talledLocalContainer] 	at com.sun.proxy.$Proxy510.findRemoteIssueLinksByGlobalId(Unknown Source)
[INFO] [talledLocalContainer] 	... 3 filtered
[INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(Method.java:497)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
[INFO] [talledLocalContainer] 	at com.sun.proxy.$Proxy4611.findRemoteIssueLinksByGlobalId(Unknown Source)
[INFO] [talledLocalContainer] 	at com.example.TestResource.renameGlobalIds(TestResource.java:334)

I don’t see what’s wrong, because the primary keys are perfectly ok in the table remotelink:

  id   | issueid |                                                 globalid                                                 | (Other columns) 
-------+---------+----------------------------------------------------------------------------------------------------------+-----------------
 10006 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-011&issue=TEST-1&relationship=resolves | ...
 10007 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-012&issue=TEST-1&relationship=resolves | ...
 10008 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-013&issue=TEST-1&relationship=resolves | ...
 10009 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-014&issue=TEST-1&relationship=resolves | ...
 10010 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-015&issue=TEST-1&relationship=resolves | ...
 10011 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-016&issue=TEST-1&relationship=resolves | ...
 10012 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-017&issue=TEST-1&relationship=resolves | ...
 10013 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-018&issue=TEST-1&relationship=resolves | ...
 10014 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-019&issue=TEST-1&relationship=resolves | ...
 10015 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-020&issue=TEST-1&relationship=resolves | ...
 10016 |   10000 | applink=777f0fe1-eb88-3927-a8af-984ec2cb8192&spaceKey=ds&key=PREQ-021&issue=TEST-1&relationship=resolves | ...

Is it a known issue? It seems to be located at the Hibernate level, so I’m not sure where to start resolving it.

I have simply raised a bug to Atlassian about DefaultRemoteIssueLinkService#findRemoteIssueLinksByGlobalId(), and in the meantime I’m using another method (less efficient but, with a loop, returns enough info).