File tree Expand file tree Collapse file tree 5 files changed +36
-6
lines changed Expand file tree Collapse file tree 5 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 232
232
(d/error! d (CancellationException. " future is cancelled." ))
233
233
234
234
(some? (.cause f))
235
- (if (instance? ClosedChannelException (.cause f))
236
- (d/success! d false )
237
- (d/error! d (.cause f)))
235
+ (d/error! d (.cause f))
238
236
239
237
:else
240
238
(d/error! d (IllegalStateException. " future in unknown state" ))))
Original file line number Diff line number Diff line change 53
53
54
54
:channel-inactive
55
55
([_ ctx]
56
- ( s/close! @in )
57
- (.fireChannelInactive ctx))
56
+ ( some-> @in s/close!)
57
+ (.fireChannelInactive ctx))
58
58
59
59
:channel-active
60
60
([_ ctx]
Original file line number Diff line number Diff line change
1
+ (ns aleph.netty-test
2
+ (:require
3
+ [aleph.netty :as netty]
4
+ [clojure.test :refer [deftest is]]
5
+ [manifold.stream :as s])
6
+ (:import
7
+ (io.netty.channel.embedded EmbeddedChannel)))
8
+
9
+ (deftest closing-a-channel-sink
10
+ (let [ch (EmbeddedChannel. )
11
+ s (netty/sink ch)]
12
+ (is (= true @(s/put! s " foo" )))
13
+ (is (nil? @(netty/wrap-future (netty/close ch))))
14
+ (is (= false @(s/put! s " foo" )))))
Original file line number Diff line number Diff line change 2
2
(:require
3
3
[aleph.netty :as netty])
4
4
(:import
5
- (io.netty.handler.ssl ClientAuth SslContextBuilder)
6
5
(java.io ByteArrayInputStream)
7
6
(java.security KeyFactory PrivateKey)
8
7
(java.security.cert CertificateFactory X509Certificate)
Original file line number Diff line number Diff line change 61
61
:trust-store (into-array X509Certificate [ssl/ca-cert])})})]
62
62
(is (nil? @(s/take! c)))
63
63
(is (nil? @ssl-session) " SSL session should be undefined" )))))
64
+
65
+ (deftest test-connection-close-during-ssl-handshake
66
+ (let [ssl-session (atom nil )
67
+ connection-closed (promise )
68
+ notify-connection-closed #_:clj-kondo/ignore (netty/channel-handler
69
+ :channel-inactive
70
+ ([_ ctx]
71
+ (deliver connection-closed true )
72
+ (.fireChannelInactive ctx)))]
73
+ (with-server (tcp/start-server (ssl-echo-handler ssl-session)
74
+ {:port 10001
75
+ :ssl-context ssl/server-ssl-context
76
+ :pipeline-transform (fn [p]
77
+ (.addLast p notify-connection-closed))})
78
+ (let [c @(tcp/client {:host " localhost"
79
+ :port 10001 })]
80
+ (s/close! c)
81
+ (is (deref connection-closed 1000 false ))
82
+ (is (nil? @ssl-session) " SSL session should be undefined" )))))
You can’t perform that action at this time.
0 commit comments