Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319937 - ClassCast exception can occur while updating XML model adapted to two EMF models
Summary: ClassCast exception can occur while updating XML model adapted to two EMF models
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Chuck Bridgham CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks: 321794
  Show dependency tree
 
Reported: 2010-07-14 22:58 EDT by Chuck Bridgham CLA
Modified: 2010-08-04 16:20 EDT (History)
3 users (show)

See Also:
david_williams: pmc_approved+
thatnitind: review+
ccc: review+


Attachments
patch (3.04 KB, patch)
2010-07-14 23:01 EDT, Chuck Bridgham CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chuck Bridgham CLA 2010-07-14 22:58:12 EDT
An adopter product is getting  a class cast exception on a few scenarios where the wrong EMF2DOM Adapter is retrieved..

Exception follows:

!ENTRY org.eclipse.wst.sse.core 4 4 2010-06-17 09:17:44.500
!MESSAGE A structured model client, EMF2DOMSSEAdapter(web-app,WebAppImpl) threw following exception during adapter notification (STRUCTURE_CHANGED )
!STACK 0
java.lang.ClassCastException: org.eclipse.jst.javaee.web.internal.impl. ServletImpl incompatible with org.eclipse.jst.j2ee.webapplication.WebTy pe
    at org.eclipse.jst.j2ee.webapplication.internal. impl.ServletImpl.eSet(ServletImpl.java:49 6)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl. eSet(BasicEObjectImpl.java:1081)
  ;   at org.eclipse.wst.common.internal.emf.utilities. ExtendedEcoreUtil.eSetOrAdd(ExtendedEcoreUtil. java:79)
    at org.eclipse.wst.common.internal.emf.resource. Translator.setMOFValue(Translator.java:62 0)
    at org.eclipse.wst.common.internal.emf.resource. Translator.setMOFValue(Translator.java:63 5)
    at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.primUpdateMOFFeature(E MF2DOMAdapterImpl.java:1497)
 &nb sp;  at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.updateMOFFeature(EMF2D OMAdapterImpl.java:1840)
  & nbsp; at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.primUpdateMOF(EMF2DOMAdapterImpl. java:993)
    at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.updateMOF(EMF2DOMAdapterImpl. java:973)
    at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.primUpdateMOFMultiFeat ure(EMF2DOMAdapterImpl.java:482)
  ;   at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.primUpdateMOFMultiFeat ure(EMF2DOMAdapterImpl.java:1553)
&nbs p;   at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.updateMOFMultiFeature( EMF2DOMAdapterImpl.java:1767)
 &n bsp;  at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.updateMOFFeature(EMF2D OMAdapterImpl.java:1822)
  & nbsp; at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.primUpdateMOF(EMF2DOMAdapterImpl. java:993)
    at org.eclipse.wst.common.internal.emf.resource. EMF2DOMAdapterImpl.updateMOF(EMF2DOMAdapterImpl. java:973)
    at org.eclipse.wst.xml.core.internal.emf2xml. EMF2DOMSSEAdapter.notifyChanged(EMF2DOMSSEAdapter. java:230)
    at org.eclipse.wst.sse.core.internal.provisional. AbstractNotifier.notify(AbstractNotifier. java:202)
    at org.eclipse.wst.xml.core.internal.document. XMLModelNotifierImpl.notifyStructureChang
Comment 1 Chuck Bridgham CLA 2010-07-14 23:01:41 EDT
Created attachment 174368 [details]
patch

In rare cases the wrong adapter was being chosen from the list of adapters.

I found a way to pass the correct translator instance that ensures the right translator is used.  a new method was needed to pass the translator
Comment 2 Chuck Bridgham CLA 2010-07-14 23:10:31 EDT
Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.

Exceptions thrown when two models are listening to the same xml model. And a series of events cause adapters to be in wrong order.  Algorithm in place didn't have enough information in hand to make correct decision.

Is there a work-around? If so, why do you believe the work-around is insufficient?

No - exception will be thrown

How has the fix been tested? 

Junits run


Give a brief technical overview. Who has reviewed this fix?

The case where this is failing.. the adapters "translator" instance is known, and now passed, and an equality check ensures the right adapter is chosen.

Carl reviewed the patch


What is the risk associated with this fix?

Low risk - Only rare path has been altered, and now can intelligently make decision.
Comment 3 Carl Anderson CLA 2010-07-14 23:35:01 EDT
I approve of this patch.
Comment 4 David Williams CLA 2010-07-15 11:12:54 EDT
changing this code sounds risky, since "deep" code, used indirectly all the time ... so please test well ... but I'm assuming the only thing that's changed from previous method is the last if-clause that uses 'childMap' ... so should be rare that the new code path is executed. (right?) 

Thanks,
Comment 5 Carl Anderson CLA 2010-07-15 12:03:28 EDT
Wow - I just moved this to Source Editing (once I realized that this was in EMF2DOMSSEAdapter and not Common's EMF2DOMAdapter), and it did weird things with the flags.  I am clearing them all out.
Comment 6 Carl Anderson CLA 2010-07-15 12:05:37 EDT
David Williams and Tim deBoer had approved this at a PMC level... but we need the proper project lead's review, so I am marking this for Nitin's review.
Comment 7 Carl Anderson CLA 2010-07-15 12:05:53 EDT
I am restoring my review flag.
Comment 8 Nitin Dahyabhai CLA 2010-07-15 14:05:14 EDT
Approving, since there's nothing new obviously wrong.  I'd still like to understand why there are multiple adapters that respond to the same adapter key on Nodes.
Comment 9 Nitin Dahyabhai CLA 2010-07-15 16:41:16 EDT
Released to 3.2.1.