[#1055] Segfault when reifying FileVisitor with visitFileFailed
This commit is contained in:
parent
c86b28a210
commit
2bb7499fd5
3 changed files with 36 additions and 4 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
babashka/babashka.curl {:local/root "babashka.curl"}
|
babashka/babashka.curl {:local/root "babashka.curl"}
|
||||||
babashka/fs {:local/root "fs"}
|
babashka/fs {:local/root "fs"}
|
||||||
borkdude/graal.locking {:mvn/version "0.0.2"},
|
borkdude/graal.locking {:mvn/version "0.0.2"},
|
||||||
org.clojure/core.async {:mvn/version "1.3.618"},
|
org.clojure/core.async {:mvn/version "1.4.627"},
|
||||||
org.clojure/tools.cli {:mvn/version "1.0.206"},
|
org.clojure/tools.cli {:mvn/version "1.0.206"},
|
||||||
org.clojure/data.csv {:mvn/version "1.0.0"},
|
org.clojure/data.csv {:mvn/version "1.0.0"},
|
||||||
cheshire/cheshire {:mvn/version "5.10.1"}
|
cheshire/cheshire {:mvn/version "5.10.1"}
|
||||||
|
|
@ -39,8 +39,7 @@
|
||||||
rewrite-clj/rewrite-clj {:mvn/version "1.0.699-alpha"}
|
rewrite-clj/rewrite-clj {:mvn/version "1.0.699-alpha"}
|
||||||
selmer/selmer {:mvn/version "1.12.44"}
|
selmer/selmer {:mvn/version "1.12.44"}
|
||||||
com.taoensso/timbre {:mvn/version "5.1.2"}
|
com.taoensso/timbre {:mvn/version "5.1.2"}
|
||||||
org.clojure/tools.logging {:mvn/version "1.1.0"}
|
org.clojure/tools.logging {:mvn/version "1.1.0"}}
|
||||||
#_#_borkdude/edamame {:local/root "../edamame"}}
|
|
||||||
:aliases {:babashka/dev
|
:aliases {:babashka/dev
|
||||||
{:main-opts ["-m" "babashka.main"]}
|
{:main-opts ["-m" "babashka.main"]}
|
||||||
:profile
|
:profile
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@
|
||||||
java.nio.file.FileVisitor
|
java.nio.file.FileVisitor
|
||||||
{preVisitDirectory [[this p attrs]]
|
{preVisitDirectory [[this p attrs]]
|
||||||
postVisitDirectory [[this p attrs]]
|
postVisitDirectory [[this p attrs]]
|
||||||
visitFile [[this p attrs]]}
|
visitFile [[this p attrs]]
|
||||||
|
visitFileFailed [[this p ex]]}
|
||||||
|
|
||||||
java.io.FileFilter
|
java.io.FileFilter
|
||||||
{accept [[this f]]}
|
{accept [[this f]]}
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,35 @@
|
||||||
(toString [_] (str :foo))))
|
(toString [_] (str :foo))))
|
||||||
(hash m)
|
(hash m)
|
||||||
")))))
|
")))))
|
||||||
|
|
||||||
|
(deftest reify-file-visitor-test
|
||||||
|
(let [prog '(do (ns dude
|
||||||
|
(:import
|
||||||
|
[java.io File]
|
||||||
|
[java.nio.file FileSystems FileVisitor FileVisitResult Files Path])
|
||||||
|
(:gen-class))
|
||||||
|
|
||||||
|
(defn match-paths
|
||||||
|
"Match glob to paths under root and return a collection of Path objects"
|
||||||
|
[^File root glob]
|
||||||
|
(let [root-path (.toPath root)
|
||||||
|
matcher (.getPathMatcher (FileSystems/getDefault) (str "glob:" glob))
|
||||||
|
paths (volatile! [])
|
||||||
|
visitor (reify FileVisitor
|
||||||
|
(visitFile [_ path attrs]
|
||||||
|
(when (.matches matcher (.relativize root-path ^Path path))
|
||||||
|
(vswap! paths conj path))
|
||||||
|
FileVisitResult/CONTINUE)
|
||||||
|
(visitFileFailed [_ path ex]
|
||||||
|
FileVisitResult/CONTINUE)
|
||||||
|
(preVisitDirectory [_ _ _] FileVisitResult/CONTINUE)
|
||||||
|
(postVisitDirectory [_ _ _] FileVisitResult/CONTINUE))]
|
||||||
|
(Files/walkFileTree root-path visitor)
|
||||||
|
@paths))
|
||||||
|
|
||||||
|
[(count (match-paths (File. ".") "**"))
|
||||||
|
;; visitFileFailed is implemented
|
||||||
|
(count (match-paths (File. "xxx") "**"))])
|
||||||
|
[x y] (bb nil prog)]
|
||||||
|
(is (pos? x))
|
||||||
|
(is (zero? y))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue