Bug on org.eclipse.emf.compare.ide.ui.internal.logical.EMFResourceMapping [message #1065584] |
Wed, 26 June 2013 11:05  |
Eclipse User |
|
|
|
Hi guys,
we recently introduced the RCP/IDE/UI bundles of the EMF Compare 2.1.0 release into our product and found that for some reason CVS commits (our app does it programatically) were failing with an NPE. I also managed to reproduce it by:
1. Create an empty project
2. add an ecore model to this project
3. commit to CVS
This is the exception:
java.lang.NullPointerException
at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation$TraversalMapEntry.add(RepositoryProviderOperation.java:87)
at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation.getProviderTraversalMapping(RepositoryProviderOperation.java:338)
at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation.execute(RepositoryProviderOperation.java:204)
at org.eclipse.team.internal.ccvs.ui.operations.CVSOperation.run(CVSOperation.java:81)
at org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard$AddAndCommitOperation.execute(CommitWizard.java:99)
at org.eclipse.team.internal.ccvs.ui.operations.CVSOperation.run(CVSOperation.java:81)
at org.eclipse.team.internal.ui.actions.JobRunnableContext.run(JobRunnableContext.java:144)
at org.eclipse.team.internal.ui.actions.JobRunnableContext$ResourceJob.runInWorkspace(JobRunnableContext.java:72)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
The bug is caused by an issue in org.eclipse.emf.compare.ide.ui.internal.logical.EMFResourceMapping.getModelObject()
Each time getModelObject() is called, a new Resource instance is created.
Unfortunatelly enough, ResourceMapping.hashCode() is overriden, and the hashcode is calculated from the getModelObject() returned value hashcode. Since this method returns a new instance each time is called, a new hashcode is returned eachtime anything ask for it (for instance, Java Map.put() and Map.get() implementations make use of hashcode).
Given the above scenario, any map.get() call would fail on getting a EMFResourceMapping instance.
The proposed solution is (pretty much like WorkspaceResourceMapper does) to cache the Resource instance returned by getModelObject().
Should I submit a bugzilla?
Cheers,
Víctor.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03279 seconds