Skip to content

Commit

Permalink
Added missed API visibility annotations for public APIs and enable th…
Browse files Browse the repository at this point in the history
…e check at the build time (opensearch-project#12872)

* Added missed API visibility annotations for public APIs and enable the check at the build time

Signed-off-by: Andriy Redko <[email protected]>

* Address code review comments

Signed-off-by: Andriy Redko <[email protected]>

---------

Signed-off-by: Andriy Redko <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
reta authored and shiv0408 committed Apr 25, 2024
1 parent 2d75866 commit 867a2d5
Show file tree
Hide file tree
Showing 61 changed files with 203 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Dependencies

### Changed
- [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
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,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 @@ -1052,8 +1053,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
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/action/ActionRequest.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.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.api
*/
@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.api
*/
@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 [email protected] (Jesse Wilson)
* @author [email protected] (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 [email protected] (Bob Lee)
* @author [email protected] (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 [email protected] (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 [email protected] (Bob Lee)
* @author [email protected] (Jesse Wilson)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Injector {

/**
Expand Down
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/common/inject/Key.java
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 [email protected] (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 [email protected] (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 [email protected] (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 [email protected] (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Provider<T> {

/**
Expand Down
5 changes: 4 additions & 1 deletion server/src/main/java/org/opensearch/common/inject/Scope.java
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 [email protected] (Bob Lee)
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Scope {

/**
Expand Down
5 changes: 4 additions & 1 deletion server/src/main/java/org/opensearch/common/inject/Stage.java
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 [email protected] (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 [email protected] (Bob Lee)
* @author [email protected] (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 [email protected] (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 [email protected] (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 [email protected] (Jesse Wilson)
* @since 2.0
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface AnnotatedElementBuilder {

/**
Expand Down
Loading

0 comments on commit 867a2d5

Please sign in to comment.