@@ -41,40 +41,42 @@ open class BasicMapsOwner(val cachesDir: File) : Closeable {
41
41
forEachMapSafe(" flush" , BasicMap <* , * >::flush)
42
42
}
43
43
44
- override fun close () {
45
- forEachMapSafe(" close" , BasicMap <* , * >::close)
46
- }
47
-
48
44
open fun deleteStorageFiles () {
49
45
forEachMapSafe(" deleteStorageFiles" , BasicMap <* , * >::deleteStorageFiles)
50
46
}
51
47
52
48
/* *
53
- * DEPRECATED: This API should be removed because
54
- * - It's not clear what [memoryCachesOnly] means.
55
- * - In the past, when `memoryCachesOnly=true` we applied a small optimization: Checking
56
- * [com.intellij.util.io.PersistentHashMap.isDirty] before calling [com.intellij.util.io.PersistentHashMap.force]. However, if that
57
- * optimization is useful, it's better to always do it (perhaps inside the [com.intellij.util.io.PersistentHashMap.force] method
58
- * itself) rather than doing it based on the value of this parameter.
59
- *
60
- * Instead, just call [flush] (without a parameter) directly.
49
+ * Please do not remove or modify this function.
50
+ * It is implementing [org.jetbrains.jps.incremental.storage.StorageOwner] interface and needed for correct JPS compilation.
51
+ */
52
+ override fun close () {
53
+ forEachMapSafe(" close" , BasicMap <* , * >::close)
54
+ }
55
+
56
+ /* *
57
+ * Please do not remove or modify this function.
58
+ * It is implementing [org.jetbrains.jps.incremental.storage.StorageOwner] interface and needed for correct JPS compilation.
61
59
*/
62
60
fun flush (@Suppress(" UNUSED_PARAMETER" ) memoryCachesOnly : Boolean ) {
63
61
flush()
64
62
}
65
63
66
64
/* *
67
- * DEPRECATED: This API should be removed because:
68
- * - It's not obvious what "clean" means: It does not exactly describe the current implementation, and it also sounds similar to
69
- * "clear" which means removing all the map entries, but this method does not do that.
70
- * - This method currently calls [close] (and [deleteStorageFiles]). However, [close] is often already called separately and
71
- * automatically, so this API makes it more likely for [close] to be accidentally called twice.
65
+ * Please do not remove or modify this function.
66
+ * It is implementing [org.jetbrains.jps.incremental.storage.StorageOwner] interface and needed for correct JPS compilation.
67
+ * Calling [org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.close] here is unnecessary and will produce race conditions
68
+ * for JPS build because JPS can modify caches of dependant modules.
72
69
*
73
- * Instead, just call [close] and/or [deleteStorageFiles] explicitly.
70
+ * More context:
71
+ * 1) While compiling module Foo, thread A can open caches of dependent module Bar
72
+ * 2) When we will compile module Bar in thread B we can decide to rebuild the module (e.g. configuration of facet changed)
73
+ * 3) Thread B will call `clean` action on caches of module Bar
74
+ * 4) If `clean` action also call `close` action,
75
+ * it will close opened map and will make it unusable when it tries to add info after recompilation,
76
+ * which will cause a "Storage already closed" exception.
74
77
*/
75
78
fun clean () {
76
- close()
77
- deleteStorageFiles()
79
+ forEachMapSafe(" clean" , BasicMap <* , * >::clean)
78
80
}
79
81
80
82
@Synchronized
0 commit comments