Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] [2.x] Added missed API visibility annotations for public APIs and enable the check at the build time (#12872) #12875

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Quickly compute terms aggregations when the top-level query is functionally match-all for a segment ([#11643](https://github.com/opensearch-project/OpenSearch/pull/11643))
- Mark fuzzy filter GA and remove experimental setting ([12631](https://github.com/opensearch-project/OpenSearch/pull/12631))
- Keep the election scheduler open until cluster state has been applied ([#11699](https://github.com/opensearch-project/OpenSearch/pull/11699))
- [BWC and API enforcement] Enforcing the presence of API annotations at build time ([#12872](https://github.com/opensearch-project/OpenSearch/pull/12872))

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ tasks.withType(JavaCompile).configureEach {

compileJava {
options.compilerArgs += ['-processor', ['org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor',
'org.opensearch.common.annotation.processor.ApiAnnotationProcessor'].join(','), '-AcontinueOnFailingChecks']
'org.opensearch.common.annotation.processor.ApiAnnotationProcessor'].join(',')]
}

tasks.named("internalClusterTest").configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.common.NamedRegistry;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.AbstractModule;
import org.opensearch.common.inject.TypeLiteral;
import org.opensearch.common.inject.multibindings.MapBinder;
Expand Down Expand Up @@ -1029,8 +1030,9 @@ public RestController getRestController() {
* <p>
* This class is modeled after {@link NamedRegistry} but provides both register and unregister capabilities.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.7.0")
public static class DynamicActionRegistry {
// This is the unmodifiable actions map created during node bootstrap, which
// will continue to link ActionType and TransportAction pairs from core and plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.action;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.transport.TransportRequest;
Expand All @@ -43,6 +44,7 @@
*
* @opensearch.internal
*/
@PublicApi(since = "1.0.0")
public abstract class ActionRequest extends TransportRequest {

public ActionRequest() {
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/action/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.action;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;
Expand All @@ -43,6 +44,7 @@
*
* @opensearch.internal
*/
@PublicApi(since = "1.0.0")
public class ActionType<Response extends ActionResponse> {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lease.Releasable;
import org.opensearch.common.lease.Releasables;
import org.opensearch.common.util.concurrent.ThreadContext;
Expand All @@ -52,8 +53,9 @@
/**
* Base class for a transport action
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class TransportAction<Request extends ActionRequest, Response extends ActionResponse> {

public final String actionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.opensearch.client.Client;
import org.opensearch.client.support.AbstractClient;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.action.ActionResponse;
Expand All @@ -53,8 +54,9 @@
/**
* Client that executes actions on the local node.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class NodeClient extends AbstractClient {

private DynamicActionRegistry actionRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.binder.AnnotatedBindingBuilder;
import org.opensearch.common.inject.binder.AnnotatedConstantBindingBuilder;
import org.opensearch.common.inject.binder.LinkedBindingBuilder;
Expand Down Expand Up @@ -198,8 +199,9 @@
* @author jessewilson@google.com (Jesse Wilson)
* @author kevinb@google.com (Kevin Bourrillion)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Binder {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.spi.BindingScopingVisitor;
import org.opensearch.common.inject.spi.BindingTargetVisitor;
import org.opensearch.common.inject.spi.Element;
Expand Down Expand Up @@ -69,8 +70,9 @@
* @author crazybob@google.com (Bob Lee)
* @author jessewilson@google.com (Jesse Wilson)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Binding<T> extends Element {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.internal.Errors;
import org.opensearch.common.inject.spi.Message;

Expand All @@ -46,8 +47,9 @@
* @author jessewilson@google.com (Jesse Wilson)
* @since 2.0
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class ConfigurationException extends RuntimeException {
private final Set<Message> messages;
private Object partialValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

import java.util.List;

/**
Expand All @@ -54,8 +56,9 @@
* @author crazybob@google.com (Bob Lee)
* @author jessewilson@google.com (Jesse Wilson)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Injector {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.internal.Annotations;
import org.opensearch.common.inject.internal.MoreTypes;
import org.opensearch.common.inject.internal.ToStringBuilder;
Expand Down Expand Up @@ -59,8 +60,9 @@
*
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class Key<T> {

private final AnnotationStrategy annotationStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

/**
* Injects dependencies into the fields and methods on instances of type {@code T}. Ignores the
* presence or absence of an injectable constructor.
Expand All @@ -38,8 +40,9 @@
* @author jessewilson@google.com (Jesse Wilson)
* @since 2.0
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface MembersInjector<T> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

/**
* A module contributes configuration information, typically interface
* bindings, which will be used to create an {@link Injector}. A Guice-based
Expand All @@ -43,8 +45,9 @@
* Use scope and binding annotations on these methods to configure the
* bindings.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Module {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.binder.AnnotatedElementBuilder;

/**
Expand All @@ -38,8 +39,9 @@
* @author jessewilson@google.com (Jesse Wilson)
* @since 2.0
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface PrivateBinder extends Binder {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

/**
* An object capable of providing instances of type {@code T}. Providers are used in numerous ways
* by Guice:
Expand All @@ -50,8 +52,9 @@
* @param <T> the type of object this provides
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Provider<T> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

/**
* A scope is a level of visibility that instances provided by Guice may have.
* By default, an instance created by the {@link Injector} has <i>no scope</i>,
Expand All @@ -42,8 +44,9 @@
*
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Scope {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;

/**
* The stage we're running in.
*
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public enum Stage {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package org.opensearch.common.inject;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.inject.internal.MoreTypes;
import org.opensearch.common.inject.util.Types;

Expand Down Expand Up @@ -77,8 +78,9 @@
* @author crazybob@google.com (Bob Lee)
* @author jessewilson@google.com (Jesse Wilson)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class TypeLiteral<T> {

final Class<? super T> rawType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@

package org.opensearch.common.inject.binder;

import org.opensearch.common.annotation.PublicApi;

import java.lang.annotation.Annotation;

/**
* See the EDSL examples at {@link org.opensearch.common.inject.Binder}.
*
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface AnnotatedBindingBuilder<T> extends LinkedBindingBuilder<T> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@

package org.opensearch.common.inject.binder;

import org.opensearch.common.annotation.PublicApi;

import java.lang.annotation.Annotation;

/**
* See the EDSL examples at {@link org.opensearch.common.inject.Binder}.
*
* @author crazybob@google.com (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface AnnotatedConstantBindingBuilder {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

package org.opensearch.common.inject.binder;

import org.opensearch.common.annotation.PublicApi;

import java.lang.annotation.Annotation;

/**
Expand All @@ -37,8 +39,9 @@
* @author jessewilson@google.com (Jesse Wilson)
* @since 2.0
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface AnnotatedElementBuilder {

/**
Expand Down
Loading
Loading