Skip to content

Commit

Permalink
Fix reflection warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnout Roemers committed Jul 30, 2020
1 parent 5961ac8 commit 3cf8cab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [2.1.4] - 2020-07-30

Fixed reflection warnings.

## [2.1.3] - 2020-04-10

Updated docs to be hosted on cljdoc.org.
Expand Down Expand Up @@ -110,6 +114,7 @@ Updated docs to be hosted on cljdoc.org.
## 0.9
- Initial release

[2.1.4]: https://github.com/aroemers/mount-lite/compare/2.1.4...2.1.3
[2.1.3]: https://github.com/aroemers/mount-lite/compare/2.1.3...2.1.2
[2.1.2]: https://github.com/aroemers/mount-lite/compare/2.1.2...2.1.1
[2.1.1]: https://github.com/aroemers/mount-lite/compare/2.1.1...2.1.0
Expand Down
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(defproject functionalbytes/mount-lite "2.1.3"
(defproject functionalbytes/mount-lite "2.1.4"
:description "mount, but different and light"
:url "https://github.com/aroemers/mount-lite"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]]
:profiles {:test {:dependencies [[org.clojure/tools.namespace "0.2.11"]]}})
:profiles {:test {:dependencies [[org.clojure/tools.namespace "0.2.11"]]}}
:global-vars {*warn-on-reflection* true})
18 changes: 9 additions & 9 deletions src/mount/lite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
(defn- throw-started
[name]
(throw (Error. (format "state %s already started %s" name
(if (.get itl) "in this session" "")))))
(if (.get ^InheritableThreadLocal itl) "in this session" "")))))

(defn- throw-unstarted
[name]
(throw (Error. (format "state %s not started %s" name
(if (.get itl) "in this session" "")))))
(if (.get ^InheritableThreadLocal itl) "in this session" "")))))

(defn- throw-not-found
[var]
Expand All @@ -39,29 +39,29 @@
(start* [this]
(if (= :stopped (status* this))
(let [value (start-fn)]
(swap! sessions assoc (.get itl) (assoc (dissoc this :sessions) ::value value)))
(swap! sessions assoc (.get ^InheritableThreadLocal itl) (assoc (dissoc this :sessions) ::value value)))
(throw-started name)))

(stop* [this]
(let [value (deref this)
stop-fn (get-in @sessions [(.get itl) :stop-fn])]
stop-fn (get-in @sessions [(.get ^InheritableThreadLocal itl) :stop-fn])]
(stop-fn value)
(swap! sessions dissoc (.get itl))))
(swap! sessions dissoc (.get ^InheritableThreadLocal itl))))

(status* [_]
(if (get @sessions (.get itl))
(if (get @sessions (.get ^InheritableThreadLocal itl))
:started
:stopped))

(properties [this]
(-> this
(merge (get @sessions (.get itl)))
(merge (get @sessions (.get ^InheritableThreadLocal itl)))
(dissoc ::value :sessions)))

IDeref
(deref [this]
(if (= :started (status* this))
(get-in @sessions [(.get itl) ::value])
(get-in @sessions [(.get ^InheritableThreadLocal itl) ::value])
(throw-unstarted name))))

(prefer-method print-method Map IDeref)
Expand Down Expand Up @@ -202,7 +202,7 @@
[& body]
`(let [p# (promise)]
{:thread (doto (Thread. (fn []
(.set @#'itl (Thread/currentThread))
(.set ^InheritableThreadLocal @#'itl (Thread/currentThread))
(try
(deliver p# (do ~@body))
(catch Throwable t#
Expand Down
2 changes: 1 addition & 1 deletion src/mount/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
(resolve (keyword->symbol kw)))

(defn var->keyword
[var]
[^clojure.lang.Var var]
(keyword (str (.ns var)) (str (.sym var))))

0 comments on commit 3cf8cab

Please # to comment.