It's all about the answers!

Ask a question

MultiStaleDataException when saving the work item


Kinny Kun (5183) | asked Apr 20 '09, 1:51 p.m.
Hi,

Im getting MultiStaleDataException when saving the work item. The exception occurs after I tried to set attribute and save the work item couple times. Following is the code how I set the attribute and save the work item. Any idea what may cause the exception? What did I do wrong in the code? Please help. Thanks.

Any help is appreciated. Thank you very much.

IWorkItemClient wiClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager wcManager = wiClient.getWorkItemWorkingCopyManager();
IWorkItemHandle handle = (IWorkItemHandle)workitem.getItemHandle();
ItemProfile<IWorkItem> profile = IWorkItem.FULL_PROFILE;
wcManager.connect(handle, profile, monitor);
WorkItemWorkingCopy workingCopy = wcManager.getWorkingCopy(handle);
IWorkItem wi = workingCopy.getWorkItem();
wi.setValue(attr, attrValue); (**note: attr is IAttribute and attrValue is Object)
IDetailedStatus s = workingCopy.save(monitor);

Exception: com.ibm.team.workitem.common.model.MultiStaleDataException: Stale Data
Message: Exception saving work item
Details: Exception saving work item
com.ibm.team.workitem.common.model.MultiStaleDataException: Stale Data
at com.ibm.team.workitem.common.internal.util.Utils.checkSaveResult(Utils.java:272)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.saveWorkItems(WorkItemWorkingCopyRegistry.java:1642)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.saveAffected(WorkItemWorkingCopyRegistry.java:1538)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.save(WorkItemWorkingCopyRegistry.java:1439)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.save(WorkItemWorkingCopyRegistry.java:1410)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyManager.save(WorkItemWorkingCopyManager.java:115)
at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyImpl.save(WorkItemWorkingCopyImpl.java:221)

2 answers



permanent link
John Doran (9182) | answered Apr 20 '09, 4:25 p.m.
I think the exception is being caused because the work item you are referencing has already been updated from a previous change and you are still referencing the old work item.
So let's say you are updating multiple attributes but each independently. The pseudo-code would be something like this ...

get work item handle
get working copy
edit attribute 1
save working copy

get fresh copy of work item
get working copy
edit attribute 2
save working copy

get fresh copy of work item
...



// get fresh copy

workItem = workItemServer.findWorkItemById(workItem.getId(),
IWorkItem.FULL_PROFILE, monitor);

permanent link
Morten Madsen (3053150) | answered Sep 30 '15, 11:11 a.m.
Actually the problem might be, that after doing:

wcManager.connect(handle, profile, monitor);

A disconnect should be performed. Else you will always access the same work item (cached) on subsequent calls to the manager:

public void disconnectWCPYManager(IWorkItemHandle wihdl)
{
    getWorkItemClient().getWorkItemWorkingCopyManager().disconnect(wihdl);
}

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.