0

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?

MasterMastic
  • 20,711
  • 12
  • 68
  • 90
  • Possible duplicate of [What's causing my java.net.SocketException: Connection reset?](http://stackoverflow.com/questions/585599/whats-causing-my-java-net-socketexception-connection-reset) – Hovercraft Full Of Eels Feb 01 '17 at 14:33
  • @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 Feb 01 '17 at 14:37
  • 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 Feb 01 '17 at 14:39

1 Answers1

0

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'?

burnall
  • 832
  • 5
  • 10
  • I don't. I also made a project just to test but it crashed. Thank you very very much for testing it. Perhaps I should try to reinstall the JVM+JDK, and not just update. – MasterMastic Feb 01 '17 at 23:12
  • Unfortunately it didn't help. I think more and more it has to do with nREPL. Thanks again! – MasterMastic Feb 01 '17 at 23:29
  • You're welcome! Seems this is relevant https://github.com/clojure-emacs/cider-nrepl/issues/259 Could you check your lein profil? – burnall Feb 02 '17 at 12:23
  • I don't have anything like that. In fact, I can't even create a frame. Merely calling the constructor makes the program crash. – MasterMastic Feb 02 '17 at 23:57
  • I can't reproduce it on Windows in Virtual Box either. Have you tried to uninstall Leinengen? – burnall Feb 03 '17 at 08:39
  • I did along with all its data and it did not help. I really think it's an issue with nREPL by the way. I kind of worked around the problem for now by developing in Linux (which I prefer anyway :P). Thankfully when it's outside of nREPL, it does work, so at least I could deploy. Thank you so much for your effort! – MasterMastic Feb 03 '17 at 08:58