Skip to content

Commit d3641a3

Browse files
committed
SocketOwner now gives a more helpful exception when the problem is "java.io.EOFException: Unexpected end of ZLIB input stream"
1 parent 80b6345 commit d3641a3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

atplug-runtime/src/main/java/com/diffplug/atplug/SocketOwner.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.diffplug.atplug
88

9+
import java.io.EOFException
910
import java.lang.Exception
1011
import java.lang.IllegalArgumentException
1112
import java.lang.RuntimeException
@@ -188,13 +189,15 @@ abstract class SocketOwner<T>(val socketClass: Class<T>) {
188189
return generatorForSocket(socket)
189190
}
190191
} catch (e: Throwable) {
192+
rethrowIfEOF(e)
191193
firstAttempt = e
192194
}
193195
try {
194196
val socketOwnerClass = Class.forName(socketClass.name + "\$Socket").kotlin
195197
val socket = socketOwnerClass.objectInstance!! as SocketOwner<T>
196198
return generatorForSocket(socket)
197199
} catch (secondAttempt: Throwable) {
200+
rethrowIfEOF(secondAttempt)
198201
val e =
199202
IllegalArgumentException(
200203
"To create metadata for `$socketClass` we need either a field `static final SocketOwner socket` or a kotlin `object Socket`.",
@@ -204,6 +207,12 @@ abstract class SocketOwner<T>(val socketClass: Class<T>) {
204207
}
205208
}
206209

210+
private fun rethrowIfEOF(exception: Throwable) {
211+
if (rootCause(exception) is EOFException) {
212+
throw Error("The JVM needs to be restarted (gradew --stop) to fix", exception)
213+
}
214+
}
215+
207216
private fun <T> generatorForSocket(socket: SocketOwner<T>): Function<T, String> {
208217
return Function { plug ->
209218
try {

0 commit comments

Comments
 (0)