Skip to content

Commit 8451909

Browse files
committed
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
1 parent b563145 commit 8451909

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

server/src/test/java/org/elasticsearch/index/codec/tsdb/TsdbDocValueBwcTests.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,16 @@ private IndexWriterConfig getTimeSeriesIndexWriterConfig(String hostnameField, S
235235

236236
// A hacky way to figure out whether doc values format is written in what version. Need to use reflection, because
237237
// PerFieldDocValuesFormat hides the doc values formats it wraps.
238-
private static void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException,
238+
private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException,
239239
IOException {
240+
if (System.getSecurityManager() != null) {
241+
// With jvm version 24 entitlements are used and security manager is nog longer used.
242+
// Making this assertion work with security manager requires granting the entire test codebase privileges to use
243+
// suppressAccessChecks and accessDeclaredMembers. This is undesired from a security manager perspective.
244+
logger.info("not asserting doc values format version, because security manager is used");
245+
return;
246+
}
247+
240248
for (var leafReaderContext : reader.leaves()) {
241249
var leaf = (SegmentReader) leafReaderContext.reader();
242250
var dvReader = leaf.getDocValuesReader();
@@ -248,8 +256,16 @@ private static void assertOldDocValuesFormatVersion(DirectoryReader reader) thro
248256
}
249257
}
250258

251-
private static void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException,
259+
private void assertNewDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException,
252260
IOException, ClassNotFoundException {
261+
if (System.getSecurityManager() != null) {
262+
// With jvm version 24 entitlements are used and security manager is nog longer used.
263+
// Making this assertion work with security manager requires granting the entire test codebase privileges to use
264+
// suppressAccessChecks and suppressAccessChecks. This is undesired from a security manager perspective.
265+
logger.info("not asserting doc values format version, because security manager is used");
266+
return;
267+
}
268+
253269
for (var leafReaderContext : reader.leaves()) {
254270
var leaf = (SegmentReader) leafReaderContext.reader();
255271
var dvReader = leaf.getDocValuesReader();

0 commit comments

Comments
 (0)