[GRADLE-1996] StackOverflowError when test throws exception that implements writeReplace() Created: 12/Dec/11  Updated: 25/Nov/13  Resolved: 25/Nov/13

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-6
Fix Version/s: 1.10-rc-1

Type: Bug
Reporter: Peter Niederwieser Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   
:spock-specs:test
Could not dispatch message [Request consumer: dfa38e52-8f78-47d5-901d-954e4339549f, payload: org.gradle.messaging.remote.internal.protocol.RemoteMethodInvocation@2]. Discarding message.
java.lang.StackOverflowError
	at java.lang.AssertionError.<init>(AssertionError.java:57)
	at org.junit.ComparisonFailure.<init>(ComparisonFailure.java:28)
	at org.spockframework.runtime.SpockComparisonFailure.<init>(SpockComparisonFailure.java:32)
	at org.spockframework.runtime.SpockComparisonFailure.writeReplace(SpockComparisonFailure.java:58)
	at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1032)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1115)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
	at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.<init>(Message.java:64)
	at org.gradle.messaging.remote.internal.Message$TopLevelExceptionPlaceholder.<init>(Message.java:130)
	at org.gradle.messaging.remote.internal.Message$TopLevelExceptionPlaceholder.<init>(Message.java:128)
	at org.gradle.messaging.remote.internal.Message$ExceptionReplacingObjectOutputStream.replaceObject(Message.java:143)
	at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder$1.replaceObject(Message.java:60)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1124)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
	at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.<init>(Message.java:64)

I think the problem is that org.gradle.messaging.remote.internal.Message.ExceptionPlaceholder.ExceptionReplacingObjectOutputStream$1#replaceObject assumes that it will at some point be passed the exception to be serialized (see the identity comparison), which isn't the case if the exception implements writeReplace().


Generated at Wed Jun 30 12:09:58 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.