From 8451909353710da3efa94330ab2d068150322b35 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 3 Apr 2025 09:05:12 +0200 Subject: [PATCH 1/2] Fix TsdbDocValueBwcTests test failure. Don't perform version check assertion in TsdbDocValueBwcTests if security manager is active. By default, with jvm version 24 entitlements are used instead security manager and assertOldDocValuesFormatVersion() / assertNewDocValuesFormatVersion() work as expected. Making these methods work with security manager would require granting the server entire test codebase suppressAccessChecks and suppressAccessChecks privileges. This is undesired from a security manager perspective. Instead, only assert doc values format checks if security manager isn't active, which is always the case jvm version 24 or higher is used. Closes #126174 --- .../codec/tsdb/TsdbDocValueBwcTests.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java b/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java index 28282b4c4e038..8e905d2da7794 100644 --- a/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java +++ b/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java @@ -235,8 +235,16 @@ private IndexWriterConfig getTimeSeriesIndexWriterConfig(String hostnameField, S // A hacky way to figure out whether doc values format is written in what version. Need to use reflection, because // PerFieldDocValuesFormat hides the doc values formats it wraps. - private static void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, + private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, IOException { + if (System.getSecurityManager() != null) { + // With jvm version 24 entitlements are used and security manager is nog longer used. + // Making this assertion work with security manager requires granting the entire test codebase privileges to use + // suppressAccessChecks and accessDeclaredMembers. This is undesired from a security manager perspective. + logger.info("not asserting doc values format version, because security manager is used"); + return; + } + for (var leafReaderContext : reader.leaves()) { var leaf = (SegmentReader) leafReaderContext.reader(); var dvReader = leaf.getDocValuesReader(); @@ -248,8 +256,16 @@ private static void assertOldDocValuesFormatVersion(DirectoryReader reader) thro } } - private static void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, + private void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, IOException, ClassNotFoundException { + if (System.getSecurityManager() != null) { + // With jvm version 24 entitlements are used and security manager is nog longer used. + // Making this assertion work with security manager requires granting the entire test codebase privileges to use + // suppressAccessChecks and suppressAccessChecks. This is undesired from a security manager perspective. + logger.info("not asserting doc values format version, because security manager is used"); + return; + } + for (var leafReaderContext : reader.leaves()) { var leaf = (SegmentReader) leafReaderContext.reader(); var dvReader = leaf.getDocValuesReader(); From 8000d52f99b4b0c9813df3a9f816e5c10c6bb2bb Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Thu, 3 Apr 2025 07:14:01 +0000 Subject: [PATCH 2/2] [CI] Auto commit changes from spotless --- .../index/codec/tsdb/TsdbDocValueBwcTests.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java b/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java index 8e905d2da7794..32b2a90322911 100644 --- a/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java +++ b/server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java @@ -235,8 +235,7 @@ private IndexWriterConfig getTimeSeriesIndexWriterConfig(String hostnameField, S // A hacky way to figure out whether doc values format is written in what version. Need to use reflection, because // PerFieldDocValuesFormat hides the doc values formats it wraps. - private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, - IOException { + private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, IOException { if (System.getSecurityManager() != null) { // With jvm version 24 entitlements are used and security manager is nog longer used. // Making this assertion work with security manager requires granting the entire test codebase privileges to use @@ -256,8 +255,8 @@ private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSu } } - private void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, - IOException, ClassNotFoundException { + private void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, IOException, + ClassNotFoundException { if (System.getSecurityManager() != null) { // With jvm version 24 entitlements are used and security manager is nog longer used. // Making this assertion work with security manager requires granting the entire test codebase privileges to use