0
votes

lein repl on a project:

user=> (javax.swing.JFrame. "My Frame")
SocketException Connection reset
        java.net.SocketInputStream.read (SocketInputStream.java:209)
        java.net.SocketInputStream.read (SocketInputStream.java:141)
        java.io.BufferedInputStream.fill (BufferedInputStream.java:246)
        java.io.BufferedInputStream.read (BufferedInputStream.java:265)
        java.io.FilterInputStream.read (FilterInputStream.java:83)
        java.io.PushbackInputStream.read (PushbackInputStream.java:139)
        clojure.tools.nrepl.bencode/read-byte (bencode.clj:84)
        clojure.tools.nrepl.bencode/read-byte (bencode.clj:-1)
        clojure.tools.nrepl.bencode/read-token (bencode.clj:236)
        clojure.tools.nrepl.bencode/read-token (bencode.clj:234)
        clojure.tools.nrepl.bencode/read-bencode (bencode.clj:254)
        clojure.tools.nrepl.bencode/read-bencode (bencode.clj:251)
Bye for now!

However on a fresh project / lein repl without a project, it does work.

user=> (javax.swing.JFrame. "My Frame")
#object[javax.swing.JFrame 0x2ee69c3e "javax.swing.JFrame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=My Frame,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]"]

I updated my JDK and JRE but it didn't help.

I initially noticed it while trying to use seesaw (where seesaw and Clojure were my only project dependencies). It crashed as well and then I noticed that even trying to use Swing directly causes a crash too. Removing seesaw from the dependencies made it work again. Now my project has other dependencies (none of them have to do with AWT/Swing, all of them are: clojure 1.8.0, clj-http 2.3.0, data.json 0.2.6, camel-snake-kebab 0.4.0, and clj-time 0.13.0) and it's happening again. I will try to see if I can find the minimal case.
Edit: the minimal cases is when having only Clojure and [clj-http "2.3.0"] or only Clojure and seesaw.

I also tried to make sure I'm running from the EDT (with EventQueue.invokeLater) but it didn't help and the program crashed.

Then I tried with just AWT (java.awt.Frame.) and I got the same crash.

Finally, fwiw, this is happening on:
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_121-b13
Windows 10 Pro x64

I now also tried to make a uberjar and it seems to work fine.
So it seems to only crash the lein repl and CIDER's REPL (so I assume the nREPL?).

How can I diagnose and solve this?

1
@HovercraftFullOfEels afaik lein creates 2 JVMs, one for itself and one for the program, and this happens when the program crashes so the connection is closed. I think that either way it's irrelevant since the only thing there is in common is the exception type.MasterMastic
I am not an expert in this type of exception which is why I did not "dup-hammer" your question, but I do know that the exception can occur when the socket is closed from the other side.Hovercraft Full Of Eels

1 Answers

0
votes

I can't reproduce it on the minimal project

(defproject km "0.1.0-SNAPSHOT"
   :dependencies [
     [org.clojure/clojure "1.8.0"]
     [clj-http "2.3.0"]
   ]
)

Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 1.8.0_112-b16 REPL-y 0.3.7, nREPL 0.2.12 MacOS Sierra

Do you have more lines in 'project.clj'?