Merge branch 'stable-3.8'
* stable-3.8:
Allow specify either avgKeySize or avgValueSize as command parameters
Fix avg value and key size calculation when auto-adjusting caches
Apply Flogger fixes from Ia4e5a3c513
Change-Id: I52e6e7d9f435740653077f03fbef667b3dd17e8a
diff --git a/BUILD b/BUILD
index a782456..97158dc 100644
--- a/BUILD
+++ b/BUILD
@@ -46,12 +46,34 @@
":chroniclemap-test-lib",
"@chronicle-bytes//jar",
],
+ jvm_flags =[
+ "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
+ "--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
+ "--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED",
+ "--add-opens=java.base/java.lang=ALL-UNNAMED",
+ "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
+ "--add-opens=java.base/java.io=ALL-UNNAMED",
+ "--add-opens=java.base/java.util=ALL-UNNAMED",
+ ],
)
[junit_tests(
name = f[:f.index(".")].replace("/", "_"),
srcs = [f],
tags = ["server"],
+ jvm_flags =[
+ "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
+ "--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
+ "--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED",
+ "--add-opens=java.base/java.lang=ALL-UNNAMED",
+ "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
+ "--add-opens=java.base/java.io=ALL-UNNAMED",
+ "--add-opens=java.base/java.util=ALL-UNNAMED",
+ ],
deps = [
":cache-chroniclemap__plugin",
":chroniclemap-test-lib",
diff --git a/README.md b/README.md
index 870dd90..ded63bf 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,22 @@
installModule = com.googlesource.gerrit.modules.cache.chroniclemap.ChronicleMapCacheModule
```
+Note that in order to run on JDK 17 (or newer) the following parameters needs to be added
+to `$GERRIT_SITE/etc/gerrit.config`:
+
+```
+[container]
+ javaOptions = --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
+ javaOptions = --add-exports=java.base/sun.nio.ch=ALL-UNNAMED
+ javaOptions = --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
+ javaOptions = --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
+ javaOptions = --add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
+ javaOptions = --add-opens=java.base/java.lang=ALL-UNNAMED
+ javaOptions = --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
+ javaOptions = --add-opens=java.base/java.io=ALL-UNNAMED
+ javaOptions = --add-opens=java.base/java.util=ALL-UNNAMED
+```
+
For further information and supported options, refer to [config](src/main/resources/Documentation/config.md)
documentation.
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 652b328..f65fe10 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -34,4 +34,24 @@
```sh
bazelisk test plugins/cache-chroniclemap/...
-```
\ No newline at end of file
+```
+
+## Run tests in IDE
+
+The cache-chroniclemap internals are JDK 17 compatible however JDK since that
+version is more restrictive on which modules are by default accessible to the
+third party libraries. Considering that, in order to run tests in IDE (e.g.
+Eclipse), one needs to add the following VM arguments to the particular test's
+_Debug/Run Configuration_:
+
+```
+--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
+--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
+--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
+--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
+--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
+--add-opens=java.base/java.lang=ALL-UNNAMED
+--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
+--add-opens=java.base/java.io=ALL-UNNAMED
+--add-opens=java.base/java.util=ALL-UNNAMED
+```
diff --git a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/MigrateH2CachesLocalDiskIT.java b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/MigrateH2CachesLocalDiskIT.java
index 57de6cd..469fcf8 100644
--- a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/MigrateH2CachesLocalDiskIT.java
+++ b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/MigrateH2CachesLocalDiskIT.java
@@ -48,6 +48,7 @@
import com.google.inject.Inject;
import com.google.inject.Key;
import com.google.inject.Module;
+import com.google.inject.name.Named;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.nio.file.Path;
@@ -305,7 +306,8 @@
Annotation annotation = entry.getKey().getAnnotation();
return className.equals(classNameMatch)
&& annotation != null
- && annotation.toString().endsWith(String.format("Named(value=\"%s\")", named));
+ && annotation instanceof Named
+ && annotation.toString().contains(String.format("\"%s\"", named));
}
private <K, V> ChronicleMapCacheImpl<K, V> chronicleCacheFor(String cacheName) throws Exception {