Skip to content

Commit 092397a

Browse files
authored
Merge branch '2.x' into backport/backport-14454-to-2.x
Signed-off-by: Pranshu Shukla <[email protected]>
2 parents 00d4d7e + 5653ed6 commit 092397a

File tree

136 files changed

+8650
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+8650
-853
lines changed

CHANGELOG.md

Lines changed: 9 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
- [Workload Management] QueryGroup resource tracking framework changes ([#13897](https://github.com/opensearch-project/OpenSearch/pull/13897))
2323
- Support filtering on a large list encoded by bitmap ([#14774](https://github.com/opensearch-project/OpenSearch/pull/14774))
2424
- Add slice execution listeners to SearchOperationListener interface ([#15153](https://github.com/opensearch-project/OpenSearch/pull/15153))
25+
- Make balanced shards allocator timebound ([#15239](https://github.com/opensearch-project/OpenSearch/pull/15239))
2526
- Add allowlist setting for ingest-geoip and ingest-useragent ([#15325](https://github.com/opensearch-project/OpenSearch/pull/15325))
2627
- Adding access to noSubMatches and noOverlappingMatches in Hyphenation ([#13895](https://github.com/opensearch-project/OpenSearch/pull/13895))
2728
- Star tree mapping changes ([#14605](https://github.com/opensearch-project/OpenSearch/pull/14605))
@@ -30,6 +31,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3031
- Add concurrent search support for Derived Fields ([#15326](https://github.com/opensearch-project/OpenSearch/pull/15326))
3132
- [Workload Management] Add query group stats constructs ([#15343](https://github.com/opensearch-project/OpenSearch/pull/15343)))
3233
- Add runAs to Subject interface and introduce IdentityAwarePlugin extension point ([#14630](https://github.com/opensearch-project/OpenSearch/pull/14630))
34+
- [Workload Management] Add rejection logic for co-ordinator and shard level requests ([#15428](https://github.com/opensearch-project/OpenSearch/pull/15428)))
35+
- Adding translog durability validation in index templates ([#15494](https://github.com/opensearch-project/OpenSearch/pull/15494))
36+
- [Workload Management] Add query group level failure tracking ([#15227](https://github.com/opensearch-project/OpenSearch/pull/15527))
37+
- [Reader Writer Separation] Add searchOnly replica routing configuration ([#15410](https://github.com/opensearch-project/OpenSearch/pull/15410))
3338
- Optimize NodeIndicesStats output behind flag ([#14454](https://github.com/opensearch-project/OpenSearch/pull/14454))
3439

3540
### Dependencies
@@ -62,10 +67,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6267
- Add lower limit for primary and replica batch allocators timeout ([#14979](https://github.com/opensearch-project/OpenSearch/pull/14979))
6368
- Optimize regexp-based include/exclude on aggregations when pattern matches prefixes ([#14371](https://github.com/opensearch-project/OpenSearch/pull/14371))
6469
- Replace and block usages of org.apache.logging.log4j.util.Strings ([#15238](https://github.com/opensearch-project/OpenSearch/pull/15238))
70+
- Remote publication using minimum node version for backward compatibility ([#15216](https://github.com/opensearch-project/OpenSearch/pull/15216))
71+
6572

6673
### Deprecated
6774

6875
### Removed
76+
- Remove some unused code in the search backpressure package ([#15518](https://github.com/opensearch-project/OpenSearch/pull/15518))
6977

7078
### Fixed
7179
- Fix constraint bug which allows more primary shards than average primary shards per index ([#14908](https://github.com/opensearch-project/OpenSearch/pull/14908))
@@ -79,6 +87,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7987
- Fix indexing error when flat_object field is explicitly null ([#15375](https://github.com/opensearch-project/OpenSearch/pull/15375))
8088
- Fix split response processor not included in allowlist ([#15393](https://github.com/opensearch-project/OpenSearch/pull/15393))
8189
- Fix unchecked cast in dynamic action map getter ([#15394](https://github.com/opensearch-project/OpenSearch/pull/15394))
90+
- Fix null values indexed as "null" strings in flat_object field ([#14069](https://github.com/opensearch-project/OpenSearch/pull/14069))
8291

8392
### Security
8493

libs/common/src/main/java/org/opensearch/common/annotation/processor/ApiAnnotationProcessor.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
5959
private static final String OPENSEARCH_PACKAGE = "org.opensearch";
6060

6161
private final Set<Element> reported = new HashSet<>();
62+
private final Set<Element> validated = new HashSet<>();
6263
private final Set<AnnotatedConstruct> processed = new HashSet<>();
6364
private Kind reportFailureAs = Kind.ERROR;
6465

@@ -85,6 +86,8 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
8586
);
8687

8788
for (var element : elements) {
89+
validate(element);
90+
8891
if (!checkPackage(element)) {
8992
continue;
9093
}
@@ -100,6 +103,64 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
100103
return false;
101104
}
102105

106+
private void validate(Element element) {
107+
// The element was validated already
108+
if (validated.contains(element)) {
109+
return;
110+
}
111+
112+
validated.add(element);
113+
114+
final PublicApi publicApi = element.getAnnotation(PublicApi.class);
115+
if (publicApi != null) {
116+
if (!validateVersion(publicApi.since())) {
117+
processingEnv.getMessager()
118+
.printMessage(
119+
reportFailureAs,
120+
"The type " + element + " has @PublicApi annotation with unparseable OpenSearch version: " + publicApi.since()
121+
);
122+
}
123+
}
124+
125+
final DeprecatedApi deprecatedApi = element.getAnnotation(DeprecatedApi.class);
126+
if (deprecatedApi != null) {
127+
if (!validateVersion(deprecatedApi.since())) {
128+
processingEnv.getMessager()
129+
.printMessage(
130+
reportFailureAs,
131+
"The type "
132+
+ element
133+
+ " has @DeprecatedApi annotation with unparseable OpenSearch version: "
134+
+ deprecatedApi.since()
135+
);
136+
}
137+
}
138+
}
139+
140+
private boolean validateVersion(String version) {
141+
String[] parts = version.split("[.-]");
142+
if (parts.length < 3 || parts.length > 4) {
143+
return false;
144+
}
145+
146+
int major = Integer.parseInt(parts[0]);
147+
if (major > 3 || major < 0) {
148+
return false;
149+
}
150+
151+
int minor = Integer.parseInt(parts[1]);
152+
if (minor < 0) {
153+
return false;
154+
}
155+
156+
int patch = Integer.parseInt(parts[2]);
157+
if (patch < 0) {
158+
return false;
159+
}
160+
161+
return true;
162+
}
163+
103164
/**
104165
* Check top level executable element
105166
* @param executable top level executable element

libs/common/src/test/java/org/opensearch/common/annotation/processor/ApiAnnotationProcessorTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,35 @@ public void testPublicApiConstructorAnnotatedInternalApi() {
486486

487487
assertThat(failure.diagnotics(), not(hasItem(matching(Diagnostic.Kind.ERROR))));
488488
}
489+
490+
public void testPublicApiUnparseableVersion() {
491+
final CompilerResult result = compile("PublicApiAnnotatedUnparseable.java");
492+
assertThat(result, instanceOf(Failure.class));
493+
494+
final Failure failure = (Failure) result;
495+
assertThat(failure.diagnotics(), hasSize(3));
496+
497+
assertThat(
498+
failure.diagnotics(),
499+
hasItem(
500+
matching(
501+
Diagnostic.Kind.ERROR,
502+
containsString(
503+
"The type org.opensearch.common.annotation.processor.PublicApiAnnotatedUnparseable has @PublicApi annotation with unparseable OpenSearch version: 2.x"
504+
)
505+
)
506+
)
507+
);
508+
}
509+
510+
public void testPublicApiWithDeprecatedApiMethod() {
511+
final CompilerResult result = compile("PublicApiWithDeprecatedApiMethod.java");
512+
assertThat(result, instanceOf(Failure.class));
513+
514+
final Failure failure = (Failure) result;
515+
assertThat(failure.diagnotics(), hasSize(2));
516+
517+
assertThat(failure.diagnotics(), not(hasItem(matching(Diagnostic.Kind.ERROR))));
518+
}
519+
489520
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.common.annotation.processor;
10+
11+
import org.opensearch.common.annotation.PublicApi;
12+
13+
@PublicApi(since = "2.x")
14+
public class PublicApiAnnotatedUnparseable {
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.common.annotation.processor;
10+
11+
import org.opensearch.common.annotation.DeprecatedApi;
12+
import org.opensearch.common.annotation.PublicApi;
13+
14+
@PublicApi(since = "1.0.0")
15+
public class PublicApiWithDeprecatedApiMethod {
16+
@DeprecatedApi(since = "0.1.0")
17+
public void method() {
18+
19+
}
20+
}

plugins/transport-reactor-netty4/src/javaRestTest/java/org/opensearch/rest/ReactorNetty4BadRequestIT.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,16 @@ public void testInvalidHeaderValue() throws IOException {
112112
assertThat(map.get("type"), equalTo("content_type_header_exception"));
113113
assertThat(map.get("reason"), equalTo("java.lang.IllegalArgumentException: invalid Content-Type header []"));
114114
}
115+
116+
public void testUnsupportedContentType() throws IOException {
117+
final Request request = new Request("POST", "/_bulk/stream");
118+
final RequestOptions.Builder options = request.getOptions().toBuilder();
119+
request.setOptions(options);
120+
final ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(request));
121+
final Response response = e.getResponse();
122+
assertThat(response.getStatusLine().getStatusCode(), equalTo(406));
123+
final ObjectPath objectPath = ObjectPath.createFromResponse(response);
124+
final String error = objectPath.evaluate("error");
125+
assertThat(error, equalTo("Content-Type header [] is not supported"));
126+
}
115127
}

0 commit comments

Comments
 (0)