Skip to content

Commit df6f165

Browse files
fp7bbatsov
andauthored
Filter non file urls from classpath response (#667)
Not all urls on a classpath are necessarily files. Eg. spring boot adds "jar:file:..." urls Co-authored-by: Bozhidar Batsov <[email protected]>
1 parent 0c58841 commit df6f165

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
* [#667](https://github.com/clojure-emacs/cider-nrepl/pull/667): Filter non file urls from classpath response.
8+
59
## 0.25.2 (2020-06-07)
610

711
### Bugs fixed

src/cider/nrepl/middleware/classpath.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
(:require
33
[cider.nrepl.middleware.util.error-handling :refer [with-safe-transport]]
44
[clojure.java.io :as io]
5-
[orchard.java.classpath :as cp]))
5+
[orchard.java.classpath :as cp]
6+
[orchard.misc :as misc]))
7+
8+
(defn file-url?
9+
[u]
10+
(and (misc/url? u)
11+
(= (.getProtocol ^java.net.URL u) "file")))
612

713
(defn classpath-reply [msg]
814
{:classpath (->> (cp/classpath)
15+
(filter file-url?)
916
(map io/as-file)
1017
(map str))})
1118

test/clj/cider/nrepl/middleware/classpath_test.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
(is (.startsWith (:err response) "java.lang.Exception: cp error"))
2222
(is (= (:ex response) "class java.lang.Exception"))
2323
(is (:pp-stacktrace response)))))
24+
25+
(deftest file-url?-test
26+
(is (file-url? (.toURL (.toURI (java.io.File. "")))))
27+
(is (not (file-url? (java.net.URL. "jar:file:/tmp/test.jar!/BOOT-INF/classes")))))

0 commit comments

Comments
 (0)