Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364873

Summary: Calling Equal on an EntityManagerFactoryBuilder causes ClassCastException
Product: [RT] Gemini.JPA Reporter: Christoph Laeubrich <laeubi>
Component: CoreAssignee: Michael Keith <michael.keith>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gunnar
Version: unspecifiedFlags: michael.keith: iplog+
Target Milestone: 1.1.0 M1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
patch for handling calls to equals method none

Description Christoph Laeubrich CLA 2011-11-25 16:24:54 EST
Build Identifier: gemini-jpa-1.0.0.RC3

java.lang.ClassCastException: $Proxy1 cannot be cast to java.util.Map
	at org.eclipse.gemini.jpa.proxy.EMFBuilderServiceProxyHandler.invoke(EMFBuilderServiceProxyHandler.java:63)
	at $Proxy1.equals(Unknown Source)

Reproducible: Always

Steps to Reproduce:
1. Fetch an instance of EntityManagerFactoryBuilder
2. call equals (either direct or for example lock up the reference in a Map or Collection)
3. java.lang.ClassCastException: $Proxy1 cannot be cast to java.util.Map is thrown
Comment 1 Gunnar Wagenknecht CLA 2012-01-04 06:17:06 EST
Created attachment 208999 [details]
patch for handling calls to equals method

The attached patch should fix the issue. It adds handling of the #equals method.
Comment 2 Christoph Laeubrich CLA 2012-01-04 13:13:33 EST
Maybe you want handling the hashCode method also, I'm not sure if there is any issue with this, but normally if you hand over the equals to the proxy you should also use hashCode of the proxy to be consistent with the general contract of hashcode/equals.
Comment 3 Gunnar Wagenknecht CLA 2012-01-04 15:07:02 EST
Handling for hashCode as well as toString is already implemented in the proxy.
Comment 4 Christoph Laeubrich CLA 2012-01-04 15:33:14 EST
Right haven't seen that, thanks for the patch hopefully someone is applying it soon :)
Comment 5 Michael Keith CLA 2012-03-20 16:36:14 EDT
Merged in.
Thanks for the bug report and for the fix.
Comment 6 Michael Keith CLA 2012-03-20 16:36:44 EDT
Fixed.