Skip to content

Commit 717d00d

Browse files
authored
Fix TsdbDocValueBwcTests test failure. (#126182)
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 ecaa0b1 commit 717d00d

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,15 @@ 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,
239-
IOException {
238+
private void assertOldDocValuesFormatVersion(DirectoryReader reader) throws NoSuchFieldException, IllegalAccessException, IOException {
239+
if (System.getSecurityManager() != null) {
240+
// With jvm version 24 entitlements are used and security manager is nog longer used.
241+
// Making this assertion work with security manager requires granting the entire test codebase privileges to use
242+
// suppressAccessChecks and accessDeclaredMembers. This is undesired from a security manager perspective.
243+
logger.info("not asserting doc values format version, because security manager is used");
244+
return;
245+
}
246+
240247
for (var leafReaderContext : reader.leaves()) {
241248
var leaf = (SegmentReader) leafReaderContext.reader();
242249
var dvReader = leaf.getDocValuesReader();
@@ -248,8 +255,16 @@ private static void assertOldDocValuesFormatVersion(DirectoryReader reader) thro
248255
}
249256
}
250257

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

0 commit comments

Comments
 (0)