RTC API add/remove user corupts team area
I have a straightforward code to manipulate members in a team are:
The code works for most of the time, but time-to-time the project area is corrupted, showing an exception below in the project view.
Does my code need any kind of synchronization/transaction etc.?
com.ibm.team.repository.service.internal.RepositoryItemService.doFetchItem(RepositoryItemService.java:575) com.ibm.team.repository.service.internal.RepositoryItemService.access$4(RepositoryItemService.java:568) com.ibm.team.repository.service.internal.RepositoryItemService$5.run(RepositoryItemService.java:548) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:567) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:342) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withNewDeferredConnection(ConnectionPoolService.java:545) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentDeferredConnection(ConnectionPoolService.java:563) sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) java.lang.reflect.Method.invoke(Method.java:611) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) com.sun.proxy.$Proxy143.withCurrentDeferredConnection(Unknown Source) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:339)
IContributorManager conManager = repo.contributorManager(); IContributor contributor = conManager.fetchContributorByUserId(uid, new NullProgressMonitor()); IProcessItemService itemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class); List<IProjectArea> areas = itemService.findAllProjectAreas(null, null); for (IProjectArea projectArea : areas) { IProjectArea mutableProjectCopy = (IProjectArea) itemService.getMutableCopy(projectArea); if ("some logic") {
processArea.addMember(contributor);
} else {
processArea.removeMember(contributor);
}
// similar code omitted here for add/remove administrator
itemService.save(new IProjectArea[] {mutableProjectCopy}, null);
}
The code works for most of the time, but time-to-time the project area is corrupted, showing an exception below in the project view.
Does my code need any kind of synchronization/transaction etc.?
com.ibm.team.repository.service.internal.RepositoryItemService.doFetchItem(RepositoryItemService.java:575) com.ibm.team.repository.service.internal.RepositoryItemService.access$4(RepositoryItemService.java:568) com.ibm.team.repository.service.internal.RepositoryItemService$5.run(RepositoryItemService.java:548) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:567) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:342) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withNewDeferredConnection(ConnectionPoolService.java:545) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentDeferredConnection(ConnectionPoolService.java:563) sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) java.lang.reflect.Method.invoke(Method.java:611) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) com.sun.proxy.$Proxy143.withCurrentDeferredConnection(Unknown Source) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:339)