parent
5ad161a059
commit
e74e7ed2ca
4 changed files with 52 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ A preview of the next release can be installed from
|
|||
|
||||
- [#1507](https://github.com/babashka/babashka/issues/1507): Expose methods on java.lang.VirtualThread ([@lispyclouds](https://github.com/lispyclouds))
|
||||
- [#1510](https://github.com/babashka/babashka/issues/1510): add virtual thread interop on `Thread`
|
||||
- [#1511](https://github.com/babashka/babashka/issues/1511): support domain sockets
|
||||
|
||||
## 1.2.174 (2023-03-01)
|
||||
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@
|
|||
java.net.HttpURLConnection
|
||||
java.net.InetAddress
|
||||
java.net.InetSocketAddress
|
||||
java.net.StandardProtocolFamily
|
||||
java.net.ServerSocket
|
||||
java.net.Socket
|
||||
java.net.SocketException
|
||||
|
|
@ -351,6 +352,8 @@
|
|||
java.nio.file.StandardOpenOption
|
||||
java.nio.channels.FileChannel
|
||||
java.nio.channels.FileChannel$MapMode
|
||||
java.nio.channels.ServerSocketChannel
|
||||
java.nio.channels.SocketChannel
|
||||
java.nio.charset.Charset
|
||||
java.nio.charset.CoderResult
|
||||
java.nio.charset.CharsetEncoder
|
||||
|
|
@ -659,6 +662,10 @@
|
|||
java.nio.CharBuffer
|
||||
(instance? java.nio.channels.FileChannel v)
|
||||
java.nio.channels.FileChannel
|
||||
(instance? java.nio.channels.ServerSocketChannel v)
|
||||
java.nio.channels.ServerSocketChannel
|
||||
(instance? java.nio.channels.SocketChannel v)
|
||||
java.nio.channels.SocketChannel
|
||||
(instance? java.net.CookieStore v)
|
||||
java.net.CookieStore
|
||||
;; this makes interop on reified classes work
|
||||
|
|
|
|||
40
test-resources/domain_sockets.bb
Normal file
40
test-resources/domain_sockets.bb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
(import java.net.UnixDomainSocketAddress
|
||||
java.net.StandardProtocolFamily
|
||||
[java.nio.channels ServerSocketChannel SocketChannel])
|
||||
|
||||
(require '[clojure.java.io :as io])
|
||||
|
||||
(def sockaddr (UnixDomainSocketAddress/of
|
||||
(-> (doto (io/file "/tmp/sock")
|
||||
(.deleteOnExit))
|
||||
str)))
|
||||
|
||||
;; server
|
||||
(def server
|
||||
(future
|
||||
(let [ch (ServerSocketChannel/open StandardProtocolFamily/UNIX)]
|
||||
(.bind ch sockaddr)
|
||||
(.accept ch))))
|
||||
|
||||
(Thread/sleep 100)
|
||||
|
||||
;; client
|
||||
(let [ch (SocketChannel/open StandardProtocolFamily/UNIX)
|
||||
ch (loop [retry 0]
|
||||
(let [v (try (.connect ch sockaddr)
|
||||
(catch Exception e e))]
|
||||
(if (instance? Exception v)
|
||||
(if (< retry 10)
|
||||
(do (Thread/sleep 100)
|
||||
(recur (inc retry)))
|
||||
(throw v))
|
||||
v)))]
|
||||
#_(prn :ch ch)
|
||||
#_(.close ch))
|
||||
|
||||
@server
|
||||
|
||||
(when-not (System/getProperty "babashka.version")
|
||||
(shutdown-agents))
|
||||
|
||||
:success
|
||||
|
|
@ -19,3 +19,7 @@
|
|||
(def t (Thread. (fn [])))
|
||||
(def vt (Thread/startVirtualThread (fn [])))
|
||||
[(.isVirtual t) (.isVirtual vt)]))))))
|
||||
|
||||
(deftest domain-sockets-test
|
||||
(when-not test-utils/windows?
|
||||
(is (= :success (bb nil (slurp "test-resources/domain_sockets.bb"))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue