diff --git a/build.gradle b/build.gradle index 9bc7436c7e4a..210e24b3f176 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id 'com.google.osdetector' version '1.6.2' apply false - // If you want to change `org.jetbrains.kotlin.jvm` version, + // If you want to change `org.jetbrains.kotlin.jvm` version, // you also need to change `org.jetbrains.kotlin:kotlin-allopen` version in `dependencies.yml`. id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false } diff --git a/core/src/main/java/com/linecorp/armeria/client/Client.java b/core/src/main/java/com/linecorp/armeria/client/Client.java index fd679055ab70..144063c6dd96 100644 --- a/core/src/main/java/com/linecorp/armeria/client/Client.java +++ b/core/src/main/java/com/linecorp/armeria/client/Client.java @@ -18,6 +18,8 @@ import static java.util.Objects.requireNonNull; +import javax.annotation.Nullable; + import com.linecorp.armeria.common.HttpRequest; import com.linecorp.armeria.common.HttpResponse; import com.linecorp.armeria.common.Request; @@ -71,6 +73,7 @@ public interface Client extends Unwrappab * @see ClientFactory#unwrap(Object, Class) * @see Unwrappable */ + @Nullable @Override default T as(Class type) { requireNonNull(type, "type"); diff --git a/core/src/main/java/com/linecorp/armeria/client/ClientRequestContextWrapper.java b/core/src/main/java/com/linecorp/armeria/client/ClientRequestContextWrapper.java index 76cdc005e35b..074fe4210994 100644 --- a/core/src/main/java/com/linecorp/armeria/client/ClientRequestContextWrapper.java +++ b/core/src/main/java/com/linecorp/armeria/client/ClientRequestContextWrapper.java @@ -49,16 +49,19 @@ public ClientRequestContext newDerivedContext(RequestId id, @Nullable HttpReques return delegate().newDerivedContext(id, req, rpcReq, endpoint); } + @Nullable @Override public EndpointGroup endpointGroup() { return delegate().endpointGroup(); } + @Nullable @Override public Endpoint endpoint() { return delegate().endpoint(); } + @Nullable @Override public String fragment() { return delegate().fragment(); diff --git a/core/src/main/java/com/linecorp/armeria/client/DecoratingClientFactory.java b/core/src/main/java/com/linecorp/armeria/client/DecoratingClientFactory.java index f6fce3356323..b8d99d2170eb 100644 --- a/core/src/main/java/com/linecorp/armeria/client/DecoratingClientFactory.java +++ b/core/src/main/java/com/linecorp/armeria/client/DecoratingClientFactory.java @@ -118,11 +118,13 @@ public Object newClient(ClientBuilderParams params) { return delegate().newClient(params); } + @Nullable @Override public ClientBuilderParams clientBuilderParams(T client) { return delegate().clientBuilderParams(client); } + @Nullable @Override public T unwrap(Object client, Class type) { return delegate().unwrap(client, type); diff --git a/core/src/main/java/com/linecorp/armeria/client/DefaultClientFactory.java b/core/src/main/java/com/linecorp/armeria/client/DefaultClientFactory.java index c91a4ab525d5..7ed3cad6a272 100644 --- a/core/src/main/java/com/linecorp/armeria/client/DefaultClientFactory.java +++ b/core/src/main/java/com/linecorp/armeria/client/DefaultClientFactory.java @@ -153,6 +153,7 @@ public Object newClient(ClientBuilderParams params) { return factory.newClient(params); } + @Nullable @Override public T unwrap(Object client, Class type) { final T params = ClientFactory.super.unwrap(client, type); diff --git a/core/src/main/java/com/linecorp/armeria/client/DefaultClientRequestContext.java b/core/src/main/java/com/linecorp/armeria/client/DefaultClientRequestContext.java index 11d2de961c67..ecacc3f956e2 100644 --- a/core/src/main/java/com/linecorp/armeria/client/DefaultClientRequestContext.java +++ b/core/src/main/java/com/linecorp/armeria/client/DefaultClientRequestContext.java @@ -393,11 +393,13 @@ public ClientOptions options() { @Override public EndpointGroup endpointGroup() { + checkState(endpointGroup != null, "Should call init(endpoint) before invoking this method."); return endpointGroup; } @Override public Endpoint endpoint() { + checkState(endpoint != null, "Should call init(endpoint) before invoking this method."); return endpoint; } diff --git a/core/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java b/core/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java index 088f17cde29c..008d7e2ac14d 100644 --- a/core/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java +++ b/core/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java @@ -122,6 +122,7 @@ final class HttpSessionHandler extends ChannelDuplexHandler implements HttpSessi this.pingIntervalMillis = pingIntervalMillis; } + @Nullable @Override public SessionProtocol protocol() { return protocol; diff --git a/core/src/main/java/com/linecorp/armeria/client/RefreshingAddressResolver.java b/core/src/main/java/com/linecorp/armeria/client/RefreshingAddressResolver.java index 93ec2400e8db..dd12d43fafb4 100644 --- a/core/src/main/java/com/linecorp/armeria/client/RefreshingAddressResolver.java +++ b/core/src/main/java/com/linecorp/armeria/client/RefreshingAddressResolver.java @@ -327,7 +327,7 @@ public void run() { servedFromCache = false; numAttemptsSoFar = 1; - if (entry.address().equals(address) && entry.ttlMillis() == ttlMillis) { + if (address.equals(entry.address()) && entry.ttlMillis() == ttlMillis) { scheduleRefresh(ttlMillis); } else { // Replace the old entry with the new one. diff --git a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/NonBlockingCircuitBreaker.java b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/NonBlockingCircuitBreaker.java index f6fc1373147d..6f5491d91fa8 100644 --- a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/NonBlockingCircuitBreaker.java +++ b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/NonBlockingCircuitBreaker.java @@ -289,11 +289,13 @@ public EventCount count() { return EventCount.ZERO; } + @Nullable @Override public EventCount onSuccess() { return null; } + @Nullable @Override public EventCount onFailure() { return null; diff --git a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/SlidingWindowCounter.java b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/SlidingWindowCounter.java index 20af85a58b62..165b40ed3f78 100644 --- a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/SlidingWindowCounter.java +++ b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/SlidingWindowCounter.java @@ -67,11 +67,13 @@ public EventCount count() { return snapshot.get(); } + @Nullable @Override public EventCount onSuccess() { return onEvent(Event.SUCCESS); } + @Nullable @Override public EventCount onFailure() { return onEvent(Event.FAILURE); diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/DynamicEndpointGroup.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/DynamicEndpointGroup.java index 5ebbd02f49bf..1bc5ccc2d4d2 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/DynamicEndpointGroup.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/DynamicEndpointGroup.java @@ -26,6 +26,8 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import javax.annotation.Nullable; + import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -81,6 +83,7 @@ public final EndpointSelectionStrategy selectionStrategy() { return selectionStrategy; } + @Nullable @Override public final Endpoint select(ClientRequestContext ctx) { return maybeCreateSelector().select(ctx); diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/EndpointGroup.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/EndpointGroup.java index 78de996eeb9c..ed45b37c5c45 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/EndpointGroup.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/EndpointGroup.java @@ -23,6 +23,8 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; +import javax.annotation.Nullable; + import com.google.common.collect.ImmutableList; import com.linecorp.armeria.client.ClientRequestContext; @@ -139,6 +141,7 @@ static EndpointGroup of(EndpointSelectionStrategy selectionStrategy, * which was specified when constructing this {@link EndpointGroup}, * or {@code null} if this {@link EndpointGroup} is empty. */ + @Nullable @Override Endpoint select(ClientRequestContext ctx); diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/OrElseEndpointGroup.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/OrElseEndpointGroup.java index 2ae694bc1629..59135cbe68f4 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/OrElseEndpointGroup.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/OrElseEndpointGroup.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.concurrent.CompletableFuture; +import javax.annotation.Nullable; + import com.linecorp.armeria.client.ClientRequestContext; import com.linecorp.armeria.client.Endpoint; import com.linecorp.armeria.common.util.AbstractListenable; @@ -66,6 +68,7 @@ public EndpointSelectionStrategy selectionStrategy() { return first.selectionStrategy(); } + @Nullable @Override public Endpoint select(ClientRequestContext ctx) { return selector.select(ctx); diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/RoundRobinStrategy.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/RoundRobinStrategy.java index 0750eadcc08e..6e5536818f91 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/RoundRobinStrategy.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/RoundRobinStrategy.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nullable; + import com.linecorp.armeria.client.ClientRequestContext; import com.linecorp.armeria.client.Endpoint; @@ -49,6 +51,7 @@ static class RoundRobinSelector implements EndpointSelector { this.endpointGroup = requireNonNull(endpointGroup, "endpointGroup"); } + @Nullable @Override public Endpoint select(ClientRequestContext ctx) { diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/StaticEndpointGroup.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/StaticEndpointGroup.java index 311d814d496e..04969b97f8a7 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/StaticEndpointGroup.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/StaticEndpointGroup.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.concurrent.CompletableFuture; +import javax.annotation.Nullable; + import com.google.common.collect.ImmutableList; import com.linecorp.armeria.client.ClientRequestContext; @@ -57,6 +59,7 @@ public EndpointSelectionStrategy selectionStrategy() { return selectionStrategy; } + @Nullable @Override public Endpoint select(ClientRequestContext ctx) { return selector.select(ctx); diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/StickyEndpointSelectionStrategy.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/StickyEndpointSelectionStrategy.java index 8e50d7059cbb..5fac5e63cebb 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/StickyEndpointSelectionStrategy.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/StickyEndpointSelectionStrategy.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.function.ToLongFunction; +import javax.annotation.Nullable; + import com.google.common.hash.Hashing; import com.linecorp.armeria.client.ClientRequestContext; @@ -80,6 +82,7 @@ private static final class StickyEndpointSelector implements EndpointSelector { this.endpointGroup = requireNonNull(endpointGroup, "endpointGroup"); } + @Nullable @Override public Endpoint select(ClientRequestContext ctx) { diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java index 82b03820dafb..bac6c829e1c6 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java @@ -61,6 +61,7 @@ private static final class WeightedRoundRobinSelector implements EndpointSelecto endpointGroup.addListener(endpoints -> endpointsAndWeights = new EndpointsAndWeights(endpoints)); } + @Nullable @Override public Endpoint select(ClientRequestContext ctx) { final int currentSequence = sequence.getAndIncrement(); diff --git a/core/src/main/java/com/linecorp/armeria/client/retry/Backoff.java b/core/src/main/java/com/linecorp/armeria/client/retry/Backoff.java index 1bc102dd038f..6aef7cce550a 100644 --- a/core/src/main/java/com/linecorp/armeria/client/retry/Backoff.java +++ b/core/src/main/java/com/linecorp/armeria/client/retry/Backoff.java @@ -23,6 +23,8 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.function.Supplier; +import javax.annotation.Nullable; + import com.linecorp.armeria.common.util.Unwrappable; /** @@ -149,6 +151,7 @@ static Backoff of(String specification) { * * @see Unwrappable */ + @Nullable @Override default T as(Class type) { return Unwrappable.super.as(type); diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java b/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java index ded03fc3e6bb..6ef43c56606f 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java @@ -47,11 +47,13 @@ public String path() { return headers.path(); } + @Nullable @Override public String scheme() { return headers.scheme(); } + @Nullable @Override public String authority() { return headers.authority(); diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultCookie.java b/core/src/main/java/com/linecorp/armeria/common/DefaultCookie.java index 0fbec278283a..9d6ab7f396d5 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultCookie.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultCookie.java @@ -87,11 +87,13 @@ public boolean isValueQuoted() { return valueQuoted; } + @Nullable @Override public String domain() { return domain; } + @Nullable @Override public String path() { return path; @@ -112,6 +114,7 @@ public boolean isHttpOnly() { return httpOnly; } + @Nullable @Override public String sameSite() { return sameSite; diff --git a/core/src/main/java/com/linecorp/armeria/common/MediaType.java b/core/src/main/java/com/linecorp/armeria/common/MediaType.java index 9875a1ae0f4a..8f74f8143437 100644 --- a/core/src/main/java/com/linecorp/armeria/common/MediaType.java +++ b/core/src/main/java/com/linecorp/armeria/common/MediaType.java @@ -1214,6 +1214,7 @@ private static final class KnownTypesByString { .distinct() .collect(toImmutableMap(MediaType::toString, Function.identity(), (a, b) -> a)); + @Nullable static MediaType get(String input) { return KNOWN_TYPES_BY_STRING.get(input); } diff --git a/core/src/main/java/com/linecorp/armeria/common/NonWrappingRequestContext.java b/core/src/main/java/com/linecorp/armeria/common/NonWrappingRequestContext.java index 8388f1afad8c..f1cd7c0a8bfd 100644 --- a/core/src/main/java/com/linecorp/armeria/common/NonWrappingRequestContext.java +++ b/core/src/main/java/com/linecorp/armeria/common/NonWrappingRequestContext.java @@ -80,11 +80,13 @@ protected NonWrappingRequestContext( this.rpcReq = rpcReq; } + @Nullable @Override public HttpRequest request() { return req; } + @Nullable @Override public RpcRequest rpcRequest() { return rpcReq; @@ -174,6 +176,7 @@ public final String decodedPath() { return this.decodedPath = ArmeriaHttpUtil.decodePath(path); } + @Nullable @Override public final String query() { return query; diff --git a/core/src/main/java/com/linecorp/armeria/common/RequestContextWrapper.java b/core/src/main/java/com/linecorp/armeria/common/RequestContextWrapper.java index 9ef1a2d1b8f3..8b2c3038e81b 100644 --- a/core/src/main/java/com/linecorp/armeria/common/RequestContextWrapper.java +++ b/core/src/main/java/com/linecorp/armeria/common/RequestContextWrapper.java @@ -168,6 +168,7 @@ public String decodedPath() { return delegate().decodedPath(); } + @Nullable @Override public String query() { return delegate().query(); diff --git a/core/src/main/java/com/linecorp/armeria/common/logging/DefaultRequestLog.java b/core/src/main/java/com/linecorp/armeria/common/logging/DefaultRequestLog.java index 95292e57248d..6b2dc2790e84 100644 --- a/core/src/main/java/com/linecorp/armeria/common/logging/DefaultRequestLog.java +++ b/core/src/main/java/com/linecorp/armeria/common/logging/DefaultRequestLog.java @@ -566,6 +566,7 @@ public long requestStartTimeNanos() { return requestStartTimeNanos; } + @Nullable @Override public Long requestFirstBytesTransferredTimeNanos() { ensureAvailable(RequestLogProperty.REQUEST_FIRST_BYTES_TRANSFERRED_TIME); @@ -584,6 +585,7 @@ public long requestDurationNanos() { return requestEndTimeNanos - requestStartTimeNanos; } + @Nullable @Override public Throwable requestCause() { ensureAvailable(RequestLogProperty.REQUEST_CAUSE); @@ -623,12 +625,14 @@ private void session0(@Nullable Channel channel, SessionProtocol sessionProtocol updateFlags(RequestLogProperty.SESSION); } + @Nullable @Override public Channel channel() { ensureAvailable(RequestLogProperty.SESSION); return channel; } + @Nullable @Override public SSLSession sslSession() { ensureAvailable(RequestLogProperty.SESSION); @@ -771,6 +775,7 @@ public void requestHeaders(RequestHeaders requestHeaders) { updateFlags(RequestLogProperty.REQUEST_HEADERS); } + @Nullable @Override public Object requestContent() { ensureAvailable(RequestLogProperty.REQUEST_CONTENT); @@ -792,12 +797,14 @@ public void requestContent(@Nullable Object requestContent, @Nullable Object raw } } + @Nullable @Override public Object rawRequestContent() { ensureAvailable(RequestLogProperty.REQUEST_CONTENT); return rawRequestContent; } + @Nullable @Override public String requestContentPreview() { ensureAvailable(RequestLogProperty.REQUEST_CONTENT_PREVIEW); @@ -983,6 +990,7 @@ public long responseStartTimeNanos() { return responseStartTimeNanos; } + @Nullable @Override public Long responseFirstBytesTransferredTimeNanos() { ensureAvailable(RequestLogProperty.RESPONSE_FIRST_BYTES_TRANSFERRED_TIME); @@ -1007,6 +1015,7 @@ public long totalDurationNanos() { return responseEndTimeNanos - requestStartTimeNanos; } + @Nullable @Override public Throwable responseCause() { ensureAvailable(RequestLogProperty.RESPONSE_CAUSE); @@ -1090,6 +1099,7 @@ public void responseHeaders(ResponseHeaders responseHeaders) { updateFlags(RequestLogProperty.RESPONSE_HEADERS); } + @Nullable @Override public Object responseContent() { ensureAvailable(RequestLogProperty.RESPONSE_CONTENT); @@ -1117,6 +1127,7 @@ public void responseContent(@Nullable Object responseContent, @Nullable Object r updateFlags(RequestLogProperty.RESPONSE_CONTENT); } + @Nullable @Override public String responseContentPreview() { ensureAvailable(RequestLogProperty.RESPONSE_CONTENT_PREVIEW); @@ -1138,6 +1149,7 @@ public void responseContentPreview(@Nullable String responseContentPreview) { updateFlags(RequestLogProperty.RESPONSE_CONTENT_PREVIEW); } + @Nullable @Override public Object rawResponseContent() { ensureAvailable(RequestLogProperty.RESPONSE_CONTENT); @@ -1633,6 +1645,7 @@ public long requestStartTimeNanos() { return requestStartTimeNanos; } + @Nullable @Override public Long requestFirstBytesTransferredTimeNanos() { return requestFirstBytesTransferredTimeNanosSet ? requestFirstBytesTransferredTimeNanos : null; @@ -1747,6 +1760,7 @@ public long responseStartTimeNanos() { return responseStartTimeNanos; } + @Nullable @Override public Long responseFirstBytesTransferredTimeNanos() { return responseFirstBytesTransferredTimeNanosSet ? responseFirstBytesTransferredTimeNanos : null; diff --git a/core/src/main/java/com/linecorp/armeria/common/util/AbstractUnwrappable.java b/core/src/main/java/com/linecorp/armeria/common/util/AbstractUnwrappable.java index 6aeb315a028e..6fb49c16b53a 100644 --- a/core/src/main/java/com/linecorp/armeria/common/util/AbstractUnwrappable.java +++ b/core/src/main/java/com/linecorp/armeria/common/util/AbstractUnwrappable.java @@ -17,6 +17,8 @@ import static java.util.Objects.requireNonNull; +import javax.annotation.Nullable; + /** * Skeletal {@link Unwrappable} implementation. * @@ -41,6 +43,7 @@ protected final U delegate() { return (U) delegate; } + @Nullable @Override public final U as(Class type) { final U result = Unwrappable.super.as(type); diff --git a/core/src/main/java/com/linecorp/armeria/internal/common/DefaultTimeoutController.java b/core/src/main/java/com/linecorp/armeria/internal/common/DefaultTimeoutController.java index c93049108ebb..e2403533e67e 100644 --- a/core/src/main/java/com/linecorp/armeria/internal/common/DefaultTimeoutController.java +++ b/core/src/main/java/com/linecorp/armeria/internal/common/DefaultTimeoutController.java @@ -253,6 +253,7 @@ private void invokeTimeoutTask() { } } + @Nullable @Override public Long startTimeNanos() { return state != State.INIT ? firstExecutionTimeNanos : null; @@ -269,6 +270,7 @@ ScheduledFuture timeoutFuture() { return timeoutFuture; } + @Nullable @VisibleForTesting TimeoutTask timeoutTask() { return timeoutTask; diff --git a/core/src/main/java/com/linecorp/armeria/internal/common/util/ObjectCollectingUtil.java b/core/src/main/java/com/linecorp/armeria/internal/common/util/ObjectCollectingUtil.java index 1e75aab0c128..2bf0bd585b7c 100644 --- a/core/src/main/java/com/linecorp/armeria/internal/common/util/ObjectCollectingUtil.java +++ b/core/src/main/java/com/linecorp/armeria/internal/common/util/ObjectCollectingUtil.java @@ -42,6 +42,7 @@ public final class ObjectCollectingUtil { * The {@link Class} instance of {@code reactor.core.publisher.Mono} of * Project Reactor. */ + @Nullable private static final Class MONO_CLASS; static { diff --git a/core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotationUtil.java b/core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotationUtil.java index 37e83988ec9f..2eedc8e82f6c 100644 --- a/core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotationUtil.java +++ b/core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotationUtil.java @@ -220,14 +220,14 @@ static List find(AnnotatedElement element, Class an private static void findMetaAnnotations( Builder builder, Annotation annotation, - Class annotationType, Class containerType) { + Class annotationType, @Nullable Class containerType) { findMetaAnnotations(builder, annotation, annotationType, containerType, Collections.newSetFromMap(new IdentityHashMap<>())); } private static boolean findMetaAnnotations( Builder builder, Annotation annotation, - Class annotationType, Class containerType, + Class annotationType, @Nullable Class containerType, Set> visitedAnnotationTypes) { final Class actualAnnotationType = annotation.getClass(); diff --git a/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java b/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java index 7beda3b5ff34..1125c6daa0e7 100644 --- a/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java +++ b/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java @@ -149,6 +149,7 @@ public void deferStatusException(HttpStatusException deferredCause) { this.deferredCause = requireNonNull(deferredCause, "deferredCause"); } + @Nullable @Override public HttpStatusException deferredStatusException() { return deferredCause; diff --git a/core/src/main/java/com/linecorp/armeria/server/RoutingContextWrapper.java b/core/src/main/java/com/linecorp/armeria/server/RoutingContextWrapper.java index c110ca7e29bf..b62df638dead 100644 --- a/core/src/main/java/com/linecorp/armeria/server/RoutingContextWrapper.java +++ b/core/src/main/java/com/linecorp/armeria/server/RoutingContextWrapper.java @@ -85,6 +85,7 @@ public void deferStatusException(HttpStatusException cause) { delegate.deferStatusException(cause); } + @Nullable @Override public HttpStatusException deferredStatusException() { return delegate.deferredStatusException(); diff --git a/core/src/main/java/com/linecorp/armeria/server/Service.java b/core/src/main/java/com/linecorp/armeria/server/Service.java index 92309df74471..58ffbddce647 100644 --- a/core/src/main/java/com/linecorp/armeria/server/Service.java +++ b/core/src/main/java/com/linecorp/armeria/server/Service.java @@ -70,6 +70,7 @@ default void serviceAdded(ServiceConfig cfg) throws Exception {} * * @see Unwrappable */ + @Nullable @Override default T as(Class type) { requireNonNull(type, "type"); diff --git a/core/src/main/java/com/linecorp/armeria/server/annotation/DefaultHttpResult.java b/core/src/main/java/com/linecorp/armeria/server/annotation/DefaultHttpResult.java index 27a422a23889..be90039128a5 100644 --- a/core/src/main/java/com/linecorp/armeria/server/annotation/DefaultHttpResult.java +++ b/core/src/main/java/com/linecorp/armeria/server/annotation/DefaultHttpResult.java @@ -50,6 +50,7 @@ public HttpHeaders headers() { return headers; } + @Nullable @Override public T content() { return content; diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/DocService.java b/core/src/main/java/com/linecorp/armeria/server/docs/DocService.java index aaf4ad089d65..401d7acd033f 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/DocService.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/DocService.java @@ -301,6 +301,7 @@ private static FieldInfo addFieldDocString(NamedTypeInfo parent, FieldInfo field docString(parent.name() + '/' + field.name(), field.docString(), docStrings)); } + @Nullable private static String docString( String key, @Nullable String currentDocString, Map docStrings) { return currentDocString != null ? currentDocString : docStrings.get(key); diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/EnumInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/EnumInfo.java index 843764e32c9e..2631c5d5ccc0 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/EnumInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/EnumInfo.java @@ -99,6 +99,7 @@ public List values() { return values; } + @Nullable @Override public String docString() { return docString; diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/ExceptionInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/ExceptionInfo.java index b6b4bfd7d922..a5ba80d74b82 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/ExceptionInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/ExceptionInfo.java @@ -73,6 +73,7 @@ public List fields() { return fields; } + @Nullable @Override public String docString() { return docString; diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/StructInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/StructInfo.java index 0cf8654b58cb..1e166bf79eda 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/StructInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/StructInfo.java @@ -73,6 +73,7 @@ public List fields() { return fields; } + @Nullable @Override public String docString() { return docString; diff --git a/core/src/main/java/com/linecorp/armeria/server/file/FileSystemHttpFile.java b/core/src/main/java/com/linecorp/armeria/server/file/FileSystemHttpFile.java index 6b27d17b2f1c..c89755cb4684 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/FileSystemHttpFile.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/FileSystemHttpFile.java @@ -55,6 +55,7 @@ protected String pathOrUri() { return path.toString(); } + @Nullable @Override public HttpFileAttributes readAttributes() throws IOException { if (!Files.exists(path)) { @@ -73,6 +74,7 @@ public HttpFileAttributes readAttributes() throws IOException { return null; } + @Nullable @Override protected ByteChannel newStream() throws IOException { try { diff --git a/core/src/main/java/com/linecorp/armeria/server/file/HttpDataFile.java b/core/src/main/java/com/linecorp/armeria/server/file/HttpDataFile.java index 000693f0e774..3228877b9ef5 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/HttpDataFile.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/HttpDataFile.java @@ -75,6 +75,7 @@ public HttpFileAttributes readAttributes() { return attrs; } + @Nullable @Override public ResponseHeaders readHeaders() { try { diff --git a/core/src/main/java/com/linecorp/armeria/server/file/NonExistentHttpFile.java b/core/src/main/java/com/linecorp/armeria/server/file/NonExistentHttpFile.java index 55d89c0acf74..c2837dc36ec2 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/NonExistentHttpFile.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/NonExistentHttpFile.java @@ -45,6 +45,7 @@ public ResponseHeaders readHeaders() { return null; } + @Nullable @Override public HttpResponse read(Executor fileReadExecutor, ByteBufAllocator alloc) { return null; diff --git a/core/src/main/java/com/linecorp/armeria/server/file/StreamingHttpFile.java b/core/src/main/java/com/linecorp/armeria/server/file/StreamingHttpFile.java index 13e8781a81ee..e64836c3eaa9 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/StreamingHttpFile.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/StreamingHttpFile.java @@ -77,6 +77,7 @@ protected StreamingHttpFile(@Nullable MediaType contentType, super(contentType, clock, dateEnabled, lastModifiedEnabled, entityTagFunction, headers); } + @Nullable @Override protected final HttpResponse doRead(ResponseHeaders headers, long length, Executor fileReadExecutor, ByteBufAllocator alloc) throws IOException { diff --git a/core/src/main/java/com/linecorp/armeria/server/logging/AccessLogComponent.java b/core/src/main/java/com/linecorp/armeria/server/logging/AccessLogComponent.java index 02f12f9a3295..07983db3013b 100644 --- a/core/src/main/java/com/linecorp/armeria/server/logging/AccessLogComponent.java +++ b/core/src/main/java/com/linecorp/armeria/server/logging/AccessLogComponent.java @@ -352,6 +352,7 @@ AsciiString headerName() { return headerName; } + @Nullable @Override public Object getMessage0(RequestLog log) { return httpHeaders.apply(log).get(headerName);