Skip to content

Commit

Permalink
Close client before discarding
Browse files Browse the repository at this point in the history
  • Loading branch information
romainreuillon committed Dec 11, 2024
1 parent 3ba755b commit bd87766
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ssh/src/main/scala/gridscale/ssh/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ object SSH:
def use[T](c: FixedConnection)(f: SSHClient => T): T =
val client =
c.synchronized:
if !c.client.isConnected then c.client = c.connect()
if !c.client.isConnected
then
util.Try(c.client.close())
c.client = c.connect()

c.client

f(client)
Expand Down

0 comments on commit bd87766

Please sign in to comment.