File tree Expand file tree Collapse file tree
atplug-runtime/src/main/java/com/diffplug/atplug Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 */
77package com.diffplug.atplug
88
9+ import java.io.EOFException
910import java.lang.Exception
1011import java.lang.IllegalArgumentException
1112import 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 {
You can’t perform that action at this time.
0 commit comments