Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lmcoursier.internal

import java.io.File
import java.lang.ref.WeakReference
import java.net.URL
import java.util.{Collections, GregorianCalendar, WeakHashMap}
import coursier.cache.CacheUrl
Expand All @@ -17,16 +16,16 @@ import scala.annotation.tailrec
private[internal] object SbtUpdateReport {

private def caching[K, V](f: K => V): K => V = {
val cache = Collections.synchronizedMap(new WeakHashMap[K, WeakReference[V]])
val cache = Collections.synchronizedMap(new WeakHashMap[K, V])

key =>
val previousValueOpt = Option(cache.get(key))

previousValueOpt.fold {
previousValueOpt.getOrElse {
val value = f(key)
val concurrentValueOpt = Option(cache.putIfAbsent(key, new WeakReference(value)))
concurrentValueOpt.fold(value)(_.get())
}(_.get())
val concurrentValueOpt = Option(cache.putIfAbsent(key, value))
concurrentValueOpt.getOrElse(value)
}
}

private def infoProperties(project: Project): Seq[(String, String)] =
Expand Down