Stale Data problem in plain client
Hi,
I have a bit of code that will run a saved query every minute which looks for workitems with a specific tag. The code will then perform an action and remove the tag. This works perfectly except for one little problem. If I manually re-add the tag to the workitem just processed, the routine fails when attempting to save the workitem with a stale data problem:- com.ibm.team.workitem.common.model.MultiStaleDataException: Stale Data This is an abstract of the code I am using:-
private List<IWorkItem> retrieveWorkItems(List<IWorkItemHandle> workitemhandles) throws TeamRepositoryException { private void addComment(IWorkItem workitem, String comment, boolean addScheduledTag) { How do I ask the client to dispose of the cached workitem or tell it to refresh it so that I don't get the stale data problem? thank you, Michael Baylis IBM Hursley |
4 answers
Hi Patrick, Yes, you are right. A fresh connect will refresh the working copy, while a second connect will connect to the existing instance, which might not be in the newest state. -- Regards, Patrick Jazz Work Item Team |
How do I ask the client to dispose of the cached workitem or tell it Instead of List<IWorkItem> listWorkItems = repository.itemManager().fetchCompleteItems(workitemhandles, IItemManager.DEFAULT, null); use List<IWorkItem> listWorkItems = repository.itemManager().fetchCompleteItems(workitemhandles, IItemManager.REFRESH, null); -- Regards, Patrick Jazz Work Item Team |
List<IWorkItem> listWorkItems = Hi Patrick, I have previously tried using REFRESH and that makes no difference. Only tried DEFAULT today to see if it makes a difference. Cheers, Michael |
List<IWorkItem> listWorkItems = Hi Patrick, I think I have found the problem, but would like confirmation please. I have put the REFRESH back in. But I realised that I had this bit of code workingCopyManager.connect(workitem, IWorkItem.FULL_PROFILE, null); but I didn't have a disconnect. I have put in a disconnect and it looks like it is working correctly now. I assume that the second connect would have realised that it was already in the workingcopymanager and not bothered to update it, so my second pass was updating the working copy of the first pass? Cheers Michael |
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.