Skip to content

Commit 2caa7db

Browse files
authored
Allow @internalapi annotation on classes not meant to be constructed outside of the OpenSearch core (#14575) (#14579)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io> (cherry picked from commit 391dee2)
1 parent 58467f6 commit 2caa7db

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3030
- unsignedLongRangeQuery now returns MatchNoDocsQuery if the lower bounds are greater than the upper bounds ([#14416](https://github.com/opensearch-project/OpenSearch/pull/14416))
3131
- Make the class CommunityIdProcessor final ([#14448](https://github.com/opensearch-project/OpenSearch/pull/14448))
3232
- Updated the `indices.query.bool.max_clause_count` setting from being static to dynamically updateable ([#13568](https://github.com/opensearch-project/OpenSearch/pull/13568))
33+
- Allow @InternalApi annotation on classes not meant to be constructed outside of the OpenSearch core ([#14575](https://github.com/opensearch-project/OpenSearch/pull/14575))
3334

3435
### Deprecated
3536

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,17 @@ public void testPublicApiWithProtectedInterface() {
473473

474474
assertThat(failure.diagnotics(), not(hasItem(matching(Diagnostic.Kind.ERROR))));
475475
}
476+
477+
/**
478+
* The constructor arguments have relaxed semantics at the moment: those could be not annotated or be annotated as {@link InternalApi}
479+
*/
480+
public void testPublicApiConstructorAnnotatedInternalApi() {
481+
final CompilerResult result = compile("PublicApiConstructorAnnotatedInternalApi.java", "NotAnnotated.java");
482+
assertThat(result, instanceOf(Failure.class));
483+
484+
final Failure failure = (Failure) result;
485+
assertThat(failure.diagnotics(), hasSize(2));
486+
487+
assertThat(failure.diagnotics(), not(hasItem(matching(Diagnostic.Kind.ERROR))));
488+
}
476489
}

libs/common/src/test/resources/org/opensearch/common/annotation/processor/InternalApiAnnotated.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
package org.opensearch.common.annotation.processor;
1010

11-
import org.opensearch.common.annotation.PublicApi;
11+
import org.opensearch.common.annotation.InternalApi;
1212

13-
@PublicApi(since = "1.0.0")
13+
@InternalApi
1414
public class InternalApiAnnotated {
1515

1616
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.InternalApi;
12+
import org.opensearch.common.annotation.PublicApi;
13+
14+
@PublicApi(since = "1.0.0")
15+
public class PublicApiConstructorAnnotatedInternalApi {
16+
/**
17+
* The constructors have relaxed semantics at the moment: those could be not annotated or be annotated as {@link InternalApi}
18+
*/
19+
@InternalApi
20+
public PublicApiConstructorAnnotatedInternalApi(NotAnnotated arg) {}
21+
}

0 commit comments

Comments
 (0)