It's all about the answers!

Ask a question

Getting ClassCastException randomly when calling IItemManager.fetchPartialItem(Location location, int flags, Collection requiredProperties, IProgressMonitor monitor)


Buu Huynh (11) | asked Apr 13, 12:16 a.m.
Hello,

I am facing the following exception
java.lang.ClassCastException: com.sun.proxy.$Proxy88 cannot be cast to com.ibm.team.repository.common.IAuditableHandle
    at com.ibm.team.repository.client.internal.ItemManager.addDuplicates(ItemManager.java:1406)
    at com.ibm.team.repository.client.internal.ItemManager.buildListFromFetchResult(ItemManager.java:878)
    at com.ibm.team.repository.client.internal.ItemManager.applyItemUpdatesOrRefresh(ItemManager.java:800)
    at com.ibm.team.repository.client.internal.ItemManager.fetchPartialItem(ItemManager.java:1102)
when I call IItemManager.fetchPartialItem(Location location, int flags, Collection requiredProperties, IProgressMonitor monitor) with inputs
  • The location is created from a URI of a snapshot (baseline set)
  • The flags is IItemManager.DEFAULT
  • The requiredProperties is Collections.emptyList()
  • The monitor is null
This issue happens randomly with the same input.

Accepted answer


permanent link
David Lafreniere (4.6k7) | answered Jun 04, 12:40 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Jun 04, 12:41 p.m.

Thank you for raising this issue.

I looked into the code base and confirmed there is indeed a defect when calling the .fetch*() methods that take a Location instead of an IItemHandle. This defect would manifest when the backed item is an ISimpleItem instead of an IAuditableHandle (which is the case for snapshots [which are IBaselineSets]).
As a workaround, if you could parse the URL to pull out the itemId of the snapshot and build up a IBaselineSetHandle.
Then you can use IItemManager.fetchCompleteItem(IItemHandle itemHandle, int flags, IProgressMonitor monitor) to avoid this ClassCastException.

Rosa Naranjo selected this answer as the correct answer

Comments
Rosa Naranjo commented Jun 04, 1:01 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Thanks


Buu Huynh commented Jun 07, 10:22 p.m.

Thank David! I have another a workaround, if you face the ClassCastException, catch that exception and call the .fetch*() method again, it will run well.

2 other answers



permanent link
Ralph Schoon (58.2k23642) | answered Apr 14, 4:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 I would suggest to open a case with support.


Comments
Buu Huynh commented Apr 14, 7:03 a.m.

Thank Ralph


permanent link
Rosa Naranjo (2.9k11421) | answered Jun 04, 10:03 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hello
When opening a case with support that involves API, please keep in mind this technote:

Your answer


Register or to post your answer.