Skip to content

Commit 797feb0

Browse files
committed
Remove some reflection warnings
1 parent e6df590 commit 797feb0

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/clj_ssh/keychain.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
(format "%s" path)
2626
"-g")]
2727
(when (zero? (result :exit))
28-
(when-let [pw (second (re-find #"password: \"(.*)\"" (result :err)))]
28+
(when-let [^String pw (second
29+
(re-find #"password: \"(.*)\"" (result :err)))]
2930
(.getBytes pw "UTF-8")))))
3031

3132
(defn passphrase

src/clj_ssh/ssh.clj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@
9393
;;; Agent
9494
(defn ssh-agent
9595
"Create a ssh-agent. By default a system ssh-agent is preferred."
96-
[{:keys [use-system-ssh-agent known-hosts-path]
96+
[{:keys [use-system-ssh-agent ^String known-hosts-path]
9797
:or {use-system-ssh-agent true
98-
known-hosts-path (str (. System getProperty "user.home") "/.ssh/known_hosts")}}]
98+
known-hosts-path (str (. System getProperty "user.home")
99+
"/.ssh/known_hosts")}}]
99100
(let [agent (JSch.)]
100101
(when use-system-ssh-agent
101102
(agent/connect agent))
@@ -145,13 +146,13 @@
145146
;; LocalIdentityRepository is not public, so we can't use
146147
;; instance?
147148
(= "com.jcraft.jsch.LocalIdentityRepository"
148-
(.getName (type id-repo))))]
149+
(.getName ^Class (type id-repo))))]
149150
(cond
150151
identity
151152
(.addIdentity agent identity passphrase)
152153

153154
(and public-key private-key)
154-
(let [id-repo (id-repository)]
155+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
155156
(if (local-repo? id-repo)
156157
(.addIdentity agent name private-key public-key passphrase)
157158
(let [keypair (KeyPair/load agent private-key-path public-key-path)]
@@ -160,7 +161,7 @@
160161
(.add id-repo (.forSSHAgent keypair)))))
161162

162163
(and public-key-path private-key-path)
163-
(let [id-repo (id-repository)]
164+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
164165
(if (local-repo? id-repo)
165166
(.addIdentity
166167
agent
@@ -172,7 +173,7 @@
172173
(.add id-repo (.forSSHAgent keypair)))))
173174

174175
private-key-path
175-
(let [id-repo (id-repository)]
176+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
176177
(if (local-repo? id-repo)
177178
(.addIdentity agent (file-path private-key-path) passphrase)
178179
(let [keypair (KeyPair/load agent private-key-path)]
@@ -425,7 +426,7 @@ keys. All other option key pairs will be passed as SSH config options."
425426
(Thread/sleep 100))
426427
{:exit (.getExitStatus shell)
427428
:out (if (= :bytes out)
428-
(.toByteArray out-stream)
429+
(.toByteArray ^ByteArrayOutputStream out-stream)
429430
(.toString out-stream))}))))
430431

431432
(defn ssh-exec
@@ -464,10 +465,10 @@ keys. All other option key pairs will be passed as SSH config options."
464465
(Thread/sleep 100))
465466
{:exit (.getExitStatus exec)
466467
:out (if (= :bytes out)
467-
(.toByteArray out-stream)
468+
(.toByteArray ^ByteArrayOutputStream out-stream)
468469
(.toString out-stream))
469470
:err (if (= :bytes out)
470-
(.toByteArray err-stream)
471+
(.toByteArray ^ByteArrayOutputStream err-stream)
471472
(.toString err-stream))}))))
472473

473474
(defn ssh

0 commit comments

Comments
 (0)