Opened 8 years ago

Closed 8 years ago

#2398 closed defect (fixed)

Duplicate key exception thrown when using Maestro IMappingService.CreateMap

Reported by: johngalambos Owned by: jng
Priority: low Milestone:
Component: Maestro Version: 2.5.0
Severity: minor Keywords:
Cc: External ID:

Description

I'm coming across an issue when creating a RuntimeMap within Maestro.

When using the IMappingService.CreateMap(runTimeMapId, mapDefinition, metersPerUnit) method, I am getting the following exception:

System.ArgumentException was unhandled
  HResult=-2147024809
  Message=An item with the same key has already been added.
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContents.PutCompleted(IResource res) in c:\working\JenkinsCI\home\slave_win\jobs\Maestro 5.0.x\workspace\OSGeo.MapGuide.MaestroAPI.Http\Commands\HttpGetResourceContents.cs:line 51
       at OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContents.<>c__DisplayClass4.<Execute>b__1(Object obj) in c:\working\JenkinsCI\home\slave_win\jobs\Maestro 5.0.x\workspace\OSGeo.MapGuide.MaestroAPI.Http\Commands\HttpGetResourceContents.cs:line 77
       at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  InnerException:

Stepping through the code, it appears that this is happening because the same layer is referenced twice within the map definition (although with a different display name and within a different group).

In the OSGeo.MapGuide.MaestroAPI.Mapping.RunTimeMap class, there is a call to

   _getRes.Execute(GetLayerIds(mdf)).

That call yields all the layer.ResourceIds without checking if there are duplicate resourceIds. The duplicates result in the exception when running the

OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContent.Execute

method which fetches the resource contents of that layer twice and tries to add it to the _completed dictionary twice with the layer.ResourceId as the key.

I'm currently using the Maestro 5.0 branch but I've looked and this code doesn't appear to be updated within the 5.1 branch. I am also connecting to a MGE 2011 server.

Attachments (1)

2398.patch (925 bytes ) - added by johngalambos 8 years ago.
Patch for #2398

Download all attachments as: .zip

Change History (2)

by johngalambos, 8 years ago

Attachment: 2398.patch added

Patch for #2398

comment:1 by jng, 8 years ago

Resolution: fixed
Status: newclosed

Fixed r8012. Thanks for the patch.

Note: See TracTickets for help on using tickets.