@@ -20,7 +20,6 @@ import java.nio.file.Files
20
20
import java .nio .file .Path
21
21
import java .nio .file .Paths
22
22
import java .nio .file .attribute .PosixFilePermission
23
- import java .util .concurrent .locks .ReentrantLock
24
23
import java .util .regex .Pattern
25
24
26
25
import scala .collection .JavaConverters ._
@@ -213,7 +212,6 @@ object CondaEnvironmentManager extends Logging {
213
212
private [this ] val httpUrlToken =
214
213
Pattern .compile(" (\\ b\\ w+://[^:/@]*:)([^/@]+)(?=@([\\ w-.]+)(:\\ d+)?\\ b)" )
215
214
216
- private [this ] val initializedEnvironmentsLock = new ReentrantLock ()
217
215
private [this ] val initializedEnvironments =
218
216
mutable.HashMap [CondaSetupInstructions , CondaEnvironment ]()
219
217
@@ -249,17 +247,14 @@ object CondaEnvironmentManager extends Logging {
249
247
* a new one if none exists.
250
248
*/
251
249
def getOrCreateCondaEnvironment (instructions : CondaSetupInstructions ): CondaEnvironment = {
252
- initializedEnvironmentsLock.lock()
253
- try {
250
+ this .synchronized {
254
251
initializedEnvironments.get(instructions) match {
255
252
case Some (condaEnv) => condaEnv
256
253
case None =>
257
254
val condaEnv = createCondaEnvironment(instructions)
258
255
initializedEnvironments.put(instructions, condaEnv)
259
256
condaEnv
260
257
}
261
- } finally {
262
- initializedEnvironmentsLock.unlock()
263
258
}
264
259
}
265
260
0 commit comments