Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible incompatilbilty with jdk8 #118

Closed
mustafaiman opened this issue Aug 4, 2015 · 3 comments
Closed

possible incompatilbilty with jdk8 #118

mustafaiman opened this issue Aug 4, 2015 · 3 comments
Labels

Comments

@mustafaiman
Copy link

EqualsVerifier.forClass(ConnectionFactoryImpl.class).usingGetClass().withPrefabValues(ManagedConnectionFactoryImpl.class,
            mock(ManagedConnectionFactoryImpl.class), mock(ManagedConnectionFactoryImpl.class))
            .suppress(Warning.NONFINAL_FIELDS).suppress(Warning.TRANSIENT_FIELDS).verify();

Above test works fine with jdk1.7.0_71 but it fails with the following error on Jdk1.8.0_51. I mocked ManagedConnectionFactoryImpl using Mockito. However it does not matter if I mock it or new ConnectionFactoyImpl() there. ConnectionFactoryImpl class has one reference to ManagedConnectionFactoryImpl but it does not use it in equals or hatched method.

java.lang.AssertionError: java.lang.ClassCastException: java.lang.Object cannot be cast to javax.naming.RefAddr
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:406)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:392)
at com.hazelcast.jca.ObjectEqualsHashcodeTests.testConnectionFactoryImpl(ObjectEqualsHashcodeTests.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at com.hazelcast.test.AbstractHazelcastClassRunner$ThreadDumpAwareRunAfters.evaluate(AbstractHazelcastClassRunner.java:134)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at com.hazelcast.test.HazelcastSerialClassRunner.runChild(HazelcastSerialClassRunner.java:44)
at com.hazelcast.test.HazelcastSerialClassRunner.runChild(HazelcastSerialClassRunner.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at com.hazelcast.test.AbstractHazelcastClassRunner$1.evaluate(AbstractHazelcastClassRunner.java:183)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
 Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to javax.naming.RefAddr
at javax.naming.Reference.equals(Reference.java:337)
at nl.jqno.equalsverifier.util.PrefabValues.getOther(PrefabValues.java:138)
at nl.jqno.equalsverifier.util.FieldAccessor$FieldChanger.modify(FieldAccessor.java:272)
at nl.jqno.equalsverifier.util.FieldAccessor.modify(FieldAccessor.java:163)
at nl.jqno.equalsverifier.util.FieldAccessor.changeField(FieldAccessor.java:153)
at nl.jqno.equalsverifier.util.ObjectAccessor.scramble(ObjectAccessor.java:153)
at nl.jqno.equalsverifier.util.ClassAccessor.getBlackAccessor(ClassAccessor.java:284)
at nl.jqno.equalsverifier.util.ClassAccessor.getBlackObject(ClassAccessor.java:273)
at nl.jqno.equalsverifier.AbstractDelegationChecker.check(AbstractDelegationChecker.java:53)
at nl.jqno.equalsverifier.EqualsVerifier.verifyWithoutExamples(EqualsVerifier.java:428)
at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:416)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:386)
... 42 more
@mustafaiman
Copy link
Author

FYI
ConnectionFactoryImpl has a field

private Reference ref;

adding the following snippet makes the test pass

.withPrefabValues(Reference.class, mock(Reference.class), mock(Reference.class))

@jqno
Copy link
Owner

jqno commented Aug 4, 2015

I've reproduced this. Nice catch. Thanks for the update too; the problem had indeed to do with the Reference class.

I'll fix this in the next release. In the mean time, using withPrefabValues is indeed the workaround that I would have suggested :).

@jqno jqno added the accepted label Aug 4, 2015
@jqno
Copy link
Owner

jqno commented Aug 17, 2015

This is fixed in version 1.7.4, which was just released.

@jqno jqno closed this as completed Aug 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants