Skip to content

Commit e277f97

Browse files
committed
Merge remote-tracking branch 'upstream/main' into instanceof
2 parents dfc56ac + 68d868a commit e277f97

File tree

21 files changed

+154
-40
lines changed

21 files changed

+154
-40
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2222
- Onboarding new maven snapshots publishing to s3 ([#19619](https://github.com/opensearch-project/OpenSearch/pull/19619))
2323
- Remove MultiCollectorWrapper and use MultiCollector in Lucene instead ([#19595](https://github.com/opensearch-project/OpenSearch/pull/19595))
2424
- Change implementation for `percentiles` aggregation for latency improvement ([#19648](https://github.com/opensearch-project/OpenSearch/pull/19648))
25+
- Wrap checked exceptions in painless.DefBootstrap to support JDK-25 ([#19706](https://github.com/opensearch-project/OpenSearch/pull/19706))
2526
- Refactor the ThreadPoolStats.Stats class to use the Builder pattern instead of constructors ([#19306](https://github.com/opensearch-project/OpenSearch/pull/19306))
2627
- Refactor the IndexingStats.Stats class to use the Builder pattern instead of constructors ([#19306](https://github.com/opensearch-project/OpenSearch/pull/19306))
2728

@@ -32,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3233
- Fix pull-based ingestion out-of-bounds offset scenarios and remove persisted offsets ([#19607](https://github.com/opensearch-project/OpenSearch/pull/19607))
3334
- Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377))
3435
- [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683))
36+
- Fix potential concurrent modification exception when updating allocation filters ([#19701])(https://github.com/opensearch-project/OpenSearch/pull/19701))
3537

3638
### Dependencies
3739
- Update to Gradle 9.1 ([#19575](https://github.com/opensearch-project/OpenSearch/pull/19575))
@@ -41,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4143
- Bump `com.azure:azure-storage-common` from 12.30.2 to 12.30.3 ([#19615](https://github.com/opensearch-project/OpenSearch/pull/19615))
4244
- Bump `peter-evans/create-issue-from-file` from 5 to 6 ([#19616](https://github.com/opensearch-project/OpenSearch/pull/19616))
4345
- Bump `com.squareup.okhttp3:okhttp` from 5.1.0 to 5.2.1 ([#19614](https://github.com/opensearch-project/OpenSearch/pull/19614))
46+
- Bump `com.microsoft.azure:msal4j` from 1.21.0 to 1.23.1 ([#19688](https://github.com/opensearch-project/OpenSearch/pull/19688))
4447
- Bump `commons-net:commons-net` from 3.11.1 to 3.12.0 ([#19687](https://github.com/opensearch-project/OpenSearch/pull/19687))
4548
- Bump `org.apache.avro:avro` from 1.12.0 to 1.12.1 ([#19692](https://github.com/opensearch-project/OpenSearch/pull/19692))
4649
- Bump `com.github.spotbugs:spotbugs-annotations` from 4.9.6 to 4.9.8 ([#19691](https://github.com/opensearch-project/OpenSearch/pull/19691))

modules/lang-painless/src/main/java/org/opensearch/painless/DefBootstrap.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ private DefBootstrap() {} // no instance!
112112
*/
113113
public static final int OPERATOR_EXPLICIT_CAST = 1 << 2;
114114

115+
/**
116+
* ClassValue.getFromHashMap will wrap checked exceptions with Errors. To get
117+
* around that we wrap any checked exceptions with this RuntimeException and
118+
* unwrap them later.
119+
*/
120+
static final class WrappedCheckedException extends RuntimeException {
121+
private WrappedCheckedException(Exception cause) {
122+
super(cause);
123+
}
124+
}
125+
115126
/**
116127
* CallSite that implements the polymorphic inlining cache (PIC).
117128
*/
@@ -204,7 +215,10 @@ protected MethodHandle computeValue(Class<?> receiverType) {
204215
try {
205216
return lookup(flavor, name, receiverType).asType(type);
206217
} catch (Throwable t) {
207-
Def.rethrow(t);
218+
switch (t) {
219+
case Exception e -> throw new WrappedCheckedException(e);
220+
default -> Def.rethrow(t);
221+
}
208222
throw new AssertionError();
209223
}
210224
}

modules/lang-painless/src/main/java/org/opensearch/painless/PainlessScript.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ public interface PainlessScript {
6565
/**
6666
* Adds stack trace and other useful information to exceptions thrown
6767
* from a Painless script.
68-
* @param t The throwable to build an exception around.
68+
* @param originalThrowable The throwable to build an exception around.
6969
* @return The generated ScriptException.
7070
*/
71-
default ScriptException convertToScriptException(Throwable t, Map<String, List<String>> extraMetadata) {
71+
default ScriptException convertToScriptException(Throwable originalThrowable, Map<String, List<String>> extraMetadata) {
72+
final Throwable unwrapped = switch (originalThrowable) {
73+
case DefBootstrap.WrappedCheckedException w -> w.getCause();
74+
default -> originalThrowable;
75+
};
7276
// create a script stack: this is just the script portion
7377
List<String> scriptStack = new ArrayList<>();
7478
ScriptException.Position pos = null;
75-
for (StackTraceElement element : t.getStackTrace()) {
79+
for (StackTraceElement element : unwrapped.getStackTrace()) {
7680
if (WriterConstants.CLASS_NAME.equals(element.getClassName())) {
7781
// found the script portion
7882
int originalOffset = element.getLineNumber();
@@ -106,7 +110,14 @@ default ScriptException convertToScriptException(Throwable t, Map<String, List<S
106110
scriptStack.add(element.toString());
107111
}
108112
}
109-
ScriptException scriptException = new ScriptException("runtime error", t, scriptStack, getName(), PainlessScriptEngine.NAME, pos);
113+
ScriptException scriptException = new ScriptException(
114+
"runtime error",
115+
unwrapped,
116+
scriptStack,
117+
getName(),
118+
PainlessScriptEngine.NAME,
119+
pos
120+
);
110121
for (Map.Entry<String, List<String>> entry : extraMetadata.entrySet()) {
111122
scriptException.addMetadata(entry.getKey(), entry.getValue());
112123
}

modules/lang-painless/src/test/java/org/opensearch/painless/DefBootstrapTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import java.util.Collections;
4747
import java.util.HashMap;
4848

49+
import static org.hamcrest.Matchers.instanceOf;
50+
4951
public class DefBootstrapTests extends OpenSearchTestCase {
5052
private final PainlessLookup painlessLookup = PainlessLookupBuilder.buildFromAllowlists(Allowlist.BASE_ALLOWLISTS);
5153

@@ -157,9 +159,11 @@ public void testMegamorphic() throws Throwable {
157159
map.put("a", "b");
158160
assertEquals(2, (int) handle.invokeExact((Object) map));
159161

160-
final IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> {
162+
final DefBootstrap.WrappedCheckedException wrapped = expectThrows(DefBootstrap.WrappedCheckedException.class, () -> {
161163
Integer.toString((int) handle.invokeExact(new Object()));
162164
});
165+
assertThat(wrapped.getCause(), instanceOf(IllegalArgumentException.class));
166+
final IllegalArgumentException iae = (IllegalArgumentException) wrapped.getCause();
163167
assertEquals("dynamic method [java.lang.Object, size/0] not found", iae.getMessage());
164168
assertTrue("Does not fail inside ClassValue.computeValue()", Arrays.stream(iae.getStackTrace()).anyMatch(e -> {
165169
return e.getMethodName().equals("computeValue") && e.getClassName().startsWith("org.opensearch.painless.DefBootstrap$PIC$");

plugins/ingestion-fs/src/test/java/org/opensearch/plugin/ingestion/fs/FileBasedIngestionSingleNodeTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public void setupIngestionFile() throws Exception {
7171
try (FileChannel channel = FileChannel.open(shardFile, StandardOpenOption.READ)) {
7272
channel.force(true);
7373
}
74+
75+
// Wait for file to be fully visible by reading it back
76+
// This prevents race conditions where tests start before file is ready
77+
assertBusy(() -> {
78+
java.util.List<String> lines = Files.readAllLines(shardFile, StandardCharsets.UTF_8);
79+
assertEquals("File should have exactly 2 lines", 2, lines.size());
80+
assertTrue("First line should contain alice", lines.get(0).contains("alice"));
81+
assertTrue("Second line should contain bob", lines.get(1).contains("bob"));
82+
});
7483
}
7584

7685
public void testFileIngestion() throws Exception {

plugins/repository-azure/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dependencies {
6161
// Start of transitive dependencies for azure-identity
6262
api 'com.microsoft.azure:msal4j-persistence-extension:1.3.0'
6363
api "net.java.dev.jna:jna-platform:${versions.jna}"
64-
api 'com.microsoft.azure:msal4j:1.21.0'
64+
api 'com.microsoft.azure:msal4j:1.23.1'
6565
api 'com.nimbusds:oauth2-oidc-sdk:11.29.2'
6666
api 'com.nimbusds:nimbus-jose-jwt:10.5'
6767
api 'com.nimbusds:content-type:2.3'

plugins/repository-azure/licenses/msal4j-1.21.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6c722b514873b24a4e1ce9c22dca36ea3c22bdbe

server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/filecache/PruneFileCacheIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public void testPruneCacheWithRealData() throws Exception {
8383
}
8484

8585
assertBusy(() -> {
86-
long usage = getFileCacheUsage();
86+
long usage = getFileCacheUsage(client);
8787
assertTrue("Cache should be populated after index access", usage > 0);
8888
}, 30, TimeUnit.SECONDS);
8989

90-
long usageBefore = getFileCacheUsage();
90+
long usageBefore = getFileCacheUsage(client);
9191
logger.info("--> File cache usage before prune: {} bytes", usageBefore);
9292
assertTrue("File cache should have data before prune", usageBefore > 0);
9393

@@ -109,7 +109,7 @@ public void testPruneCacheWithRealData() throws Exception {
109109
assertTrue("Should have pruned bytes", response.getTotalPrunedBytes() > 0);
110110

111111
// Verify cache usage after prune
112-
long usageAfter = getFileCacheUsage();
112+
long usageAfter = getFileCacheUsage(client);
113113
logger.info("--> File cache usage after prune: {} bytes", usageAfter);
114114

115115
// Cache should be reduced (might not be zero if files are still referenced)
@@ -148,11 +148,11 @@ public void testPruneResponseMetrics() throws Exception {
148148
assertDocCount(restoredIndexName, 100L);
149149

150150
assertBusy(() -> {
151-
long usage = getFileCacheUsage();
151+
long usage = getFileCacheUsage(client);
152152
assertTrue("Cache should be populated", usage > 0);
153153
}, 30, TimeUnit.SECONDS);
154154

155-
long usageBefore = getFileCacheUsage();
155+
long usageBefore = getFileCacheUsage(client);
156156

157157
PruneFileCacheRequest request = new PruneFileCacheRequest();
158158
PlainActionFuture<PruneFileCacheResponse> future = new PlainActionFuture<>();
@@ -170,7 +170,7 @@ public void testPruneResponseMetrics() throws Exception {
170170
assertTrue("Node should have cache capacity", nodeResponse.getCacheCapacity() > 0);
171171
assertTrue("Node should report pruned bytes", nodeResponse.getPrunedBytes() >= 0);
172172

173-
long usageAfter = getFileCacheUsage();
173+
long usageAfter = getFileCacheUsage(client);
174174
long expectedPruned = usageBefore - usageAfter;
175175
assertEquals("Response should match actual cache reduction", expectedPruned, response.getTotalPrunedBytes());
176176
}
@@ -261,8 +261,8 @@ private void assertRemoteSnapshotIndexSettings(Client client, String... indexNam
261261
/**
262262
* Returns total file cache usage across all warm nodes in bytes.
263263
*/
264-
private long getFileCacheUsage() {
265-
NodesStatsResponse response = client().admin().cluster().nodesStats(new NodesStatsRequest().all()).actionGet();
264+
private long getFileCacheUsage(Client client) {
265+
NodesStatsResponse response = client.admin().cluster().nodesStats(new NodesStatsRequest().all()).actionGet();
266266

267267
long totalUsage = 0L;
268268
for (NodeStats stats : response.getNodes()) {

server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeFilters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static DiscoveryNodeFilters buildOrUpdateFromKeyValue(
9797
updated = new DiscoveryNodeFilters(opType, new HashMap<>());
9898
} else {
9999
assert opType == original.opType : "operation type should match with node filter parameter";
100-
updated = new DiscoveryNodeFilters(original.opType, original.filters);
100+
updated = new DiscoveryNodeFilters(original.opType, new HashMap<>(original.filters));
101101
}
102102
for (Map.Entry<String, String> entry : filters.entrySet()) {
103103
String[] values = Strings.tokenizeToStringArray(entry.getValue(), ",");

0 commit comments

Comments
 (0)