[GRADLE-2131] Exception with "Discarding connection." message Created: 28/Feb/12  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 13


 Description   

Today our build started to throw strange exceptions during gradle build (this one never happened before). If I run build with debug messaging turned on I see lots of following messages:

TRACE - 28 Feb 02012 12:48:44.348 - Outgoing Connection [3443153e-30fc-4a50-b9c4-f430632aa45c port:53113, addresses:[/0:0:0:0:0:0:0:1%1, /127.0.0.1]]:0 worker - org.hibernate.type.descriptor.sql.BasicBinder | binding parameter [1] as [BOOLEAN] - true
TRACE - 28 Feb 02012 12:48:44.348 - Outgoing Connection [3443153e-30fc-4a50-b9c4-f430632aa45c port:53113, addresses:[/0:0:0:0:0:0:0:1%1, /127.0.0.1]]:0 worker - org.hibernate.type.descriptor.sql.BasicBinder | binding parameter [2] as [VARCHAR] -
TRACE - 28 Feb 02012 12:48:44.349 - Outgoing Connection [3443153e-30fc-4a50-b9c4-f430632aa45c port:53113, addresses:[/0:0:0:0:0:0:0:1%1, /127.0.0.1]]:0 worker - org.hibernate.type.EnumType | Binding

{0}

to parameter: 3

Which eventually leads to following exception:

Could not receive message from connection. Discarding connection.
org.gradle.messaging.remote.internal.MessageIOException: Could not read message from '/0:0:0:0:0:0:0:1:59280'.
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:81)
at org.gradle.messaging.remote.internal.DelegatingConnection.receive(DelegatingConnection.java:31)
at org.gradle.messaging.remote.internal.MessageHub$EndOfStreamConnection.receive(MessageHub.java:210)
at org.gradle.messaging.remote.internal.MessageHub$EndOfStreamConnection.receive(MessageHub.java:195)
at org.gradle.messaging.remote.internal.AsyncConnectionAdapter$ConnectionReceive.receive(AsyncConnectionAdapter.java:77)
at org.gradle.messaging.dispatch.AsyncReceive.receiveMessages(AsyncReceive.java:142)
at org.gradle.messaging.dispatch.AsyncReceive.access$000(AsyncReceive.java:36)
at org.gradle.messaging.dispatch.AsyncReceive$1.run(AsyncReceive.java:88)
at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassCastException: cannot assign instance of org.gradle.messaging.remote.internal.PlaceholderException to field java.sql.SQLException.next of type java.sql.SQLException in instance of java.sql.BatchUpdateException
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2039)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1952)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.read(Message.java:93)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.getCause(Message.java:121)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.read(Message.java:80)
at org.gradle.messaging.remote.internal.Message$ExceptionReplacingObjectInputStream.resolveObject(Message.java:158)
at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1376)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1666)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1322)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.gradle.messaging.remote.internal.Message.receive(Message.java:38)
at org.gradle.messaging.remote.internal.DefaultMessageSerializer.read(DefaultMessageSerializer.java:31)
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:76)
... 11 more

Anyone ever happend to have the same issue ?



 Comments   
Comment by Gradle Forums [ 28/Feb/12 ]

It looks like a test is throwing a `java.sql.BatchUpdateException`, and the test JVM fails to inform the Gradle JVM of that event (tests run in a separate JVM). This looks like a Gradle bug. Until this gets fixed, your best chance is to prevent tests from throwing that particular exception, for example by wrapping affected tests in a try-catch and throwing a RuntimeException instead. You can copy over message and stack trace, but do not chain the original exception.

Comment by Kallin Nagelberg [ 21/Mar/12 ]

I'm having the same issue13:02:29.643 [ERROR] [org.gradle.messaging.remote.internal.MessageHub$EndOfStreamConnection] Could not receive message from connection. Discarding connection.
org.gradle.messaging.remote.internal.MessageIOException: Could not read message from '/0:0:0:0:0:0:0:1%0:53225'.
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
at org.gradle.messaging.remote.internal.DelegatingConnection.receive(DelegatingConnection.java:31)
at org.gradle.messaging.remote.internal.MessageHub$EndOfStreamConnection.receive(MessageHub.java:210)
at org.gradle.messaging.remote.internal.MessageHub$EndOfStreamConnection.receive(MessageHub.java:195)
at org.gradle.messaging.remote.internal.AsyncConnectionAdapter$ConnectionReceive.receive(AsyncConnectionAdapter.java:77)
at org.gradle.messaging.dispatch.AsyncReceive.receiveMessages(AsyncReceive.java:142)
at org.gradle.messaging.dispatch.AsyncReceive.access$000(AsyncReceive.java:36)
at org.gradle.messaging.dispatch.AsyncReceive$1.run(AsyncReceive.java:88)
at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassCastException: cannot assign instance of org.gradle.messaging.remote.internal.PlaceholderException to field java.sql.SQLException.next of type java.sql.SQLException in instance of java.sql.BatchUpdateException

Let me know if you need help replicating.

Comment by Kallin Nagelberg [ 21/Mar/12 ]

I think the relevant bit is:

cannot assign instance of org.gradle.messaging.remote.internal.PlaceholderException to field java.sql.SQLException.next of type java.sql.SQLException in instance of java.sql.BatchUpdateException

The PlaceHolderException is used when an exception cannot be serialized or deserialized. In this case an instance of BatchUpdateException is attempting to be deserialized, which is a subclass of SqlException. SqlException has a volatile field called 'next' which is also of type SqlException. It appears the messaging framework in Gradle did not want to serialize the volatile field, so instead used a PlaceHolderException, but it left the type of the 'next' field as SqlException when it is in fact now 'PlaceHolderException'. I'll keep digging..

Comment by Merlyn Albery-Speyer [ 20/May/13 ]

I've seen this same exception cause using Gradle 1.6:

10:11:06.839 [ERROR] [org.gradle.messaging.remote.internal.hub.MessageHubBackedServer] Unexpected exception thrown.
org.gradle.messaging.remote.internal.MessageIOException: Could not read message from '/0:0:0:0:0:0:0:1:58281'.
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:88)
at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionReceive.run(MessageHub.java:230)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassCastException: cannot assign instance of org.gradle.messaging.remote.internal.PlaceholderException to field java.sql.SQLException.next of type java.sql.SQLException in instance of java.sql.SQLException
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2063)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1241)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1995)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.read(Message.java:101)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.getCause(Message.java:129)
at org.gradle.messaging.remote.internal.Message$ExceptionPlaceholder.read(Message.java:88)
at org.gradle.messaging.remote.internal.Message$ExceptionReplacingObjectInputStream.resolveObject(Message.java:166)
at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1396)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1704)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1342)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at org.gradle.messaging.remote.internal.Message.receive(Message.java:38)
at org.gradle.messaging.serialize.kryo.JavaSerializer$JavaReader.read(JavaSerializer.java:50)
at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationReader.readArguments(MethodInvocationSerializer.java:112)
at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationReader.read(MethodInvocationSerializer.java:107)
at org.gradle.messaging.remote.internal.hub.MethodInvocationSerializer$MethodInvocationReader.read(MethodInvocationSerializer.java:87)
at org.gradle.messaging.serialize.kryo.TypeSafeSerializer$1.read(TypeSafeSerializer.java:37)
at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:67)
at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:53)
at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
... 5 more
10:11:06.846 [QUIET] [system.out] 10:11:06.845 [INFO] [org.gradle.api.internal.tasks.testing.worker.TestWorker] Gradle Worker 1 finished executing tests.
10:11:06.864 [QUIET] [system.out] 10:11:06.848 [DEBUG] [org.gradle.process.internal.child.ActionExecutionWorker] Completed Gradle Worker 1.

Comment by Merlyn Albery-Speyer [ 28/May/13 ]

Does anyone have a work-around for this issue?

Comment by Kallin Nagelberg [ 28/May/13 ]

I never found a workaround unfortunately. At one point I attempted to produce a failing test in the gradle source code to identify the bug but didn't get too far. If you can't workaround it that's probably your best bet at identifying the root issue and potentially producing a solution.

Comment by Merlyn Albery-Speyer [ 01/Aug/13 ]

+1 for a fix for this. This is still coming up.

Comment by Etienne Studer [ 02/Aug/13 ]

My (unconfirmed) guess is that this happens when the exception thrown in the test case is not serializable. Just a guess...

Comment by Kallin Nagelberg [ 02/Aug/13 ]

It's been awhile, but as I recall the issue had something to do with one of the 'next' chained exceptions not being serialized correctly.. Like it's transformed from its original class to something else (by Gradle) before being transported, but the other side doesn't know this, so when it tries to unserialize the 'next' field it is looking at an object of the wrong type. Wish I could be less vague!

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

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