From f0d870fde1088114070be31b67f7df0a21e835c6 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 20 Sep 2019 16:09:47 +0900 Subject: [PATCH] Add `@Nullable` to the parameter of `equals(Object)` (#2093) Motivation: `Object.equals(Object)` accepts `null`, but many of our `equals()` implementations do not have `@Nullable` annotation on their parameters. Modifications: - Add `@Nullable` to the parameter of `equals(Object)` Result: - Better `null`-related inference --- CONTRIBUTING.md | 2 +- .../java/com/linecorp/armeria/client/ClientDecoration.java | 4 +++- .../linecorp/armeria/client/DefaultEventLoopScheduler.java | 4 +++- core/src/main/java/com/linecorp/armeria/client/Endpoint.java | 2 +- .../java/com/linecorp/armeria/client/HttpChannelPool.java | 2 +- .../linecorp/armeria/client/circuitbreaker/EventCount.java | 4 +++- .../client/endpoint/dns/DnsQuestionWithoutTrailingDot.java | 4 +++- .../java/com/linecorp/armeria/common/AbstractHttpData.java | 4 +++- .../com/linecorp/armeria/common/AbstractRequestContext.java | 4 +++- .../main/java/com/linecorp/armeria/common/CacheControl.java | 4 +++- .../java/com/linecorp/armeria/common/ClientCacheControl.java | 2 +- .../linecorp/armeria/common/DefaultAggregatedHttpRequest.java | 4 +++- .../armeria/common/DefaultAggregatedHttpResponse.java | 4 +++- .../java/com/linecorp/armeria/common/DefaultHttpHeaders.java | 2 +- .../com/linecorp/armeria/common/DefaultRequestHeaders.java | 2 +- .../com/linecorp/armeria/common/DefaultResponseHeaders.java | 2 +- .../java/com/linecorp/armeria/common/DefaultRpcRequest.java | 2 +- .../java/com/linecorp/armeria/common/HttpHeadersBase.java | 4 ++-- .../com/linecorp/armeria/common/ImmutableHttpParameters.java | 4 +++- core/src/main/java/com/linecorp/armeria/common/Scheme.java | 2 +- .../java/com/linecorp/armeria/common/SerializationFormat.java | 2 +- .../linecorp/armeria/common/SerializationFormatProvider.java | 4 +++- .../java/com/linecorp/armeria/common/ServerCacheControl.java | 2 +- .../armeria/common/logging/RequestLogAvailabilitySet.java | 4 +++- .../com/linecorp/armeria/common/metric/MeterIdPrefix.java | 4 +++- .../linecorp/armeria/common/sse/DefaultServerSentEvent.java | 2 +- .../main/java/com/linecorp/armeria/internal/PathAndQuery.java | 2 +- .../internal/annotation/AnnotatedBeanFactoryRegistry.java | 2 +- .../java/com/linecorp/armeria/server/ClientAddressSource.java | 4 +++- .../main/java/com/linecorp/armeria/server/DefaultRoute.java | 4 +++- .../com/linecorp/armeria/server/DefaultRoutingContext.java | 2 +- .../java/com/linecorp/armeria/server/ExactPathMapping.java | 2 +- .../java/com/linecorp/armeria/server/GlobPathMapping.java | 2 +- .../com/linecorp/armeria/server/ParameterizedPathMapping.java | 2 +- .../java/com/linecorp/armeria/server/PrefixPathMapping.java | 2 +- .../java/com/linecorp/armeria/server/RegexPathMapping.java | 2 +- .../linecorp/armeria/server/RegexPathMappingWithPrefix.java | 2 +- .../main/java/com/linecorp/armeria/server/RouteBuilder.java | 2 +- .../src/main/java/com/linecorp/armeria/server/ServerPort.java | 2 +- .../java/com/linecorp/armeria/server/auth/BasicToken.java | 4 +++- .../java/com/linecorp/armeria/server/auth/OAuth1aToken.java | 4 +++- .../java/com/linecorp/armeria/server/auth/OAuth2Token.java | 4 +++- .../java/com/linecorp/armeria/server/docs/EndpointInfo.java | 2 +- .../main/java/com/linecorp/armeria/server/docs/EnumInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/EnumValueInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/ExceptionInfo.java | 2 +- .../main/java/com/linecorp/armeria/server/docs/FieldInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/MethodInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/ServiceInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/StructInfo.java | 2 +- .../java/com/linecorp/armeria/server/docs/TypeSignature.java | 2 +- .../com/linecorp/armeria/server/file/HttpFileAttributes.java | 4 +++- .../com/linecorp/armeria/server/file/HttpFileService.java | 2 +- .../armeria/common/grpc/protocol/ArmeriaMessageDeframer.java | 2 +- .../armeria/common/logback/RequestContextExporter.java | 2 +- .../armeria/client/retrofit2/ArmeriaCallFactoryTest.java | 2 +- .../java/com/linecorp/armeria/server/saml/SamlEndpoint.java | 4 +++- .../armeria/spring/web/reactive/ArmeriaWebClientTest.java | 4 +++- .../com/linecorp/armeria/common/thrift/ThriftMessage.java | 4 +++- 59 files changed, 104 insertions(+), 60 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b4a36ca8ba..3465ca9d2b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -212,7 +212,7 @@ public final class MyClass { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { ... usual type check ... // OK return name.equals(((MyClass) obj).name); diff --git a/core/src/main/java/com/linecorp/armeria/client/ClientDecoration.java b/core/src/main/java/com/linecorp/armeria/client/ClientDecoration.java index 8e31f0da4fd..c28a0137249 100644 --- a/core/src/main/java/com/linecorp/armeria/client/ClientDecoration.java +++ b/core/src/main/java/com/linecorp/armeria/client/ClientDecoration.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.function.Function; +import javax.annotation.Nullable; + import com.linecorp.armeria.common.Request; import com.linecorp.armeria.common.Response; @@ -113,7 +115,7 @@ Function, Client> decorator() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/client/DefaultEventLoopScheduler.java b/core/src/main/java/com/linecorp/armeria/client/DefaultEventLoopScheduler.java index 989833fe194..57ec1b5726c 100644 --- a/core/src/main/java/com/linecorp/armeria/client/DefaultEventLoopScheduler.java +++ b/core/src/main/java/com/linecorp/armeria/client/DefaultEventLoopScheduler.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.function.ToIntFunction; +import javax.annotation.Nullable; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -262,7 +264,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/client/Endpoint.java b/core/src/main/java/com/linecorp/armeria/client/Endpoint.java index b88dbaee6b3..a1b10a762da 100644 --- a/core/src/main/java/com/linecorp/armeria/client/Endpoint.java +++ b/core/src/main/java/com/linecorp/armeria/client/Endpoint.java @@ -643,7 +643,7 @@ private static void validateWeight(int weight) { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java b/core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java index 44d6318d737..d20e1d96ba6 100644 --- a/core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java +++ b/core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java @@ -551,7 +551,7 @@ static final class PoolKey { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/EventCount.java b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/EventCount.java index 9f150d8393d..534983c7170 100644 --- a/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/EventCount.java +++ b/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/EventCount.java @@ -16,6 +16,8 @@ package com.linecorp.armeria.client.circuitbreaker; +import javax.annotation.Nullable; + /** * An immutable object that stores the count of events. */ @@ -99,7 +101,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsQuestionWithoutTrailingDot.java b/core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsQuestionWithoutTrailingDot.java index 0c605b6f2e2..310120f7232 100644 --- a/core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsQuestionWithoutTrailingDot.java +++ b/core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsQuestionWithoutTrailingDot.java @@ -19,6 +19,8 @@ import java.net.IDN; +import javax.annotation.Nullable; + import io.netty.handler.codec.dns.DnsQuestion; import io.netty.handler.codec.dns.DnsRecordType; @@ -56,7 +58,7 @@ public long timeToLive() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/AbstractHttpData.java b/core/src/main/java/com/linecorp/armeria/common/AbstractHttpData.java index 0b1d121ccea..0518f247580 100644 --- a/core/src/main/java/com/linecorp/armeria/common/AbstractHttpData.java +++ b/core/src/main/java/com/linecorp/armeria/common/AbstractHttpData.java @@ -16,6 +16,8 @@ package com.linecorp.armeria.common; +import javax.annotation.Nullable; + /** * Support APIs for creating well-behaved {@link HttpData} objects. {@link HttpData} generally should extend * {@link AbstractHttpData} to interact with other {@link HttpData} implementations, via, e.g., {@code equals}. @@ -37,7 +39,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (!(obj instanceof AbstractHttpData)) { return false; } diff --git a/core/src/main/java/com/linecorp/armeria/common/AbstractRequestContext.java b/core/src/main/java/com/linecorp/armeria/common/AbstractRequestContext.java index a90454dbb4a..54b76a56433 100644 --- a/core/src/main/java/com/linecorp/armeria/common/AbstractRequestContext.java +++ b/core/src/main/java/com/linecorp/armeria/common/AbstractRequestContext.java @@ -26,6 +26,8 @@ import java.util.function.Consumer; import java.util.function.Function; +import javax.annotation.Nullable; + import com.linecorp.armeria.common.util.SafeCloseable; import com.linecorp.armeria.server.DefaultServiceRequestContext; @@ -195,7 +197,7 @@ public final int hashCode() { } @Override - public final boolean equals(Object obj) { + public final boolean equals(@Nullable Object obj) { return super.equals(obj); } } diff --git a/core/src/main/java/com/linecorp/armeria/common/CacheControl.java b/core/src/main/java/com/linecorp/armeria/common/CacheControl.java index 04f1d0078e4..1a27cab6ea8 100644 --- a/core/src/main/java/com/linecorp/armeria/common/CacheControl.java +++ b/core/src/main/java/com/linecorp/armeria/common/CacheControl.java @@ -15,6 +15,8 @@ */ package com.linecorp.armeria.common; +import javax.annotation.Nullable; + /** * Directives for HTTP caching mechanisms in requests or responses. Use {@link ServerCacheControl} for * response-side and {@link ClientCacheControl} for request-side. @@ -115,7 +117,7 @@ final StringBuilder newHeaderValueBuffer() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/ClientCacheControl.java b/core/src/main/java/com/linecorp/armeria/common/ClientCacheControl.java index a5b3637c029..89336aceb0c 100644 --- a/core/src/main/java/com/linecorp/armeria/common/ClientCacheControl.java +++ b/core/src/main/java/com/linecorp/armeria/common/ClientCacheControl.java @@ -244,7 +244,7 @@ public String asHeaderValue() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (!super.equals(o)) { return false; } 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 4dfd132c837..ded03fc3e6b 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpRequest.java @@ -16,6 +16,8 @@ package com.linecorp.armeria.common; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; @@ -64,7 +66,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpResponse.java b/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpResponse.java index 63f2aa94f2a..a07556c353c 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpResponse.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultAggregatedHttpResponse.java @@ -18,6 +18,8 @@ import java.util.List; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; @@ -59,7 +61,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultHttpHeaders.java b/core/src/main/java/com/linecorp/armeria/common/DefaultHttpHeaders.java index 53bd360f807..d1a6cd29309 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultHttpHeaders.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultHttpHeaders.java @@ -71,7 +71,7 @@ public HttpHeadersBuilder toBuilder() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return o instanceof HttpHeaders && super.equals(o); } } diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultRequestHeaders.java b/core/src/main/java/com/linecorp/armeria/common/DefaultRequestHeaders.java index 9381947c519..196bb00c431 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultRequestHeaders.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultRequestHeaders.java @@ -64,7 +64,7 @@ public RequestHeadersBuilder toBuilder() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return o instanceof RequestHeaders && super.equals(o); } } diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultResponseHeaders.java b/core/src/main/java/com/linecorp/armeria/common/DefaultResponseHeaders.java index 0e206414bab..04cbef06d4d 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultResponseHeaders.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultResponseHeaders.java @@ -47,7 +47,7 @@ public ResponseHeadersBuilder toBuilder() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return o instanceof ResponseHeaders && super.equals(o); } } diff --git a/core/src/main/java/com/linecorp/armeria/common/DefaultRpcRequest.java b/core/src/main/java/com/linecorp/armeria/common/DefaultRpcRequest.java index 8b452665237..c6a60c0ede7 100644 --- a/core/src/main/java/com/linecorp/armeria/common/DefaultRpcRequest.java +++ b/core/src/main/java/com/linecorp/armeria/common/DefaultRpcRequest.java @@ -115,7 +115,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/HttpHeadersBase.java b/core/src/main/java/com/linecorp/armeria/common/HttpHeadersBase.java index 97062041379..5cd31ae79f8 100644 --- a/core/src/main/java/com/linecorp/armeria/common/HttpHeadersBase.java +++ b/core/src/main/java/com/linecorp/armeria/common/HttpHeadersBase.java @@ -960,7 +960,7 @@ public final int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -1142,7 +1142,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/ImmutableHttpParameters.java b/core/src/main/java/com/linecorp/armeria/common/ImmutableHttpParameters.java index e7bcaba3223..0364a7a1b61 100644 --- a/core/src/main/java/com/linecorp/armeria/common/ImmutableHttpParameters.java +++ b/core/src/main/java/com/linecorp/armeria/common/ImmutableHttpParameters.java @@ -23,6 +23,8 @@ import java.util.Map.Entry; import java.util.Set; +import javax.annotation.Nullable; + import io.netty.handler.codec.Headers; final class ImmutableHttpParameters implements HttpParameters { @@ -510,7 +512,7 @@ public int hashCode() { @Override @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return delegate.equals(obj); } diff --git a/core/src/main/java/com/linecorp/armeria/common/Scheme.java b/core/src/main/java/com/linecorp/armeria/common/Scheme.java index a17bba69764..a1561508ccb 100644 --- a/core/src/main/java/com/linecorp/armeria/common/Scheme.java +++ b/core/src/main/java/com/linecorp/armeria/common/Scheme.java @@ -145,7 +145,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return this == obj; } diff --git a/core/src/main/java/com/linecorp/armeria/common/SerializationFormat.java b/core/src/main/java/com/linecorp/armeria/common/SerializationFormat.java index 60ee951e6cd..22933ab4cc6 100644 --- a/core/src/main/java/com/linecorp/armeria/common/SerializationFormat.java +++ b/core/src/main/java/com/linecorp/armeria/common/SerializationFormat.java @@ -324,7 +324,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return this == obj; } diff --git a/core/src/main/java/com/linecorp/armeria/common/SerializationFormatProvider.java b/core/src/main/java/com/linecorp/armeria/common/SerializationFormatProvider.java index aa7f479505c..405fcfa0077 100644 --- a/core/src/main/java/com/linecorp/armeria/common/SerializationFormatProvider.java +++ b/core/src/main/java/com/linecorp/armeria/common/SerializationFormatProvider.java @@ -20,6 +20,8 @@ import java.util.Set; +import javax.annotation.Nullable; + import com.google.common.base.Ascii; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; @@ -55,7 +57,7 @@ public Entry(String uriText, MediaType primaryMediaType, MediaType... alternativ } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/ServerCacheControl.java b/core/src/main/java/com/linecorp/armeria/common/ServerCacheControl.java index 484e6d14117..eef46ec69cd 100644 --- a/core/src/main/java/com/linecorp/armeria/common/ServerCacheControl.java +++ b/core/src/main/java/com/linecorp/armeria/common/ServerCacheControl.java @@ -226,7 +226,7 @@ public String asHeaderValue() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (!super.equals(o)) { return false; } diff --git a/core/src/main/java/com/linecorp/armeria/common/logging/RequestLogAvailabilitySet.java b/core/src/main/java/com/linecorp/armeria/common/logging/RequestLogAvailabilitySet.java index 259c15d8d55..baf9d99b3b2 100644 --- a/core/src/main/java/com/linecorp/armeria/common/logging/RequestLogAvailabilitySet.java +++ b/core/src/main/java/com/linecorp/armeria/common/logging/RequestLogAvailabilitySet.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Set; +import javax.annotation.Nullable; + import com.google.common.collect.Iterators; import com.google.common.math.IntMath; @@ -103,7 +105,7 @@ public boolean contains(Object e) { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { return this == o; } diff --git a/core/src/main/java/com/linecorp/armeria/common/metric/MeterIdPrefix.java b/core/src/main/java/com/linecorp/armeria/common/metric/MeterIdPrefix.java index 738fb3467d1..e4e013a612b 100644 --- a/core/src/main/java/com/linecorp/armeria/common/metric/MeterIdPrefix.java +++ b/core/src/main/java/com/linecorp/armeria/common/metric/MeterIdPrefix.java @@ -24,6 +24,8 @@ import java.util.Collection; import java.util.List; +import javax.annotation.Nullable; + import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -207,7 +209,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/common/sse/DefaultServerSentEvent.java b/core/src/main/java/com/linecorp/armeria/common/sse/DefaultServerSentEvent.java index 95d20cfa12f..4eee3b9705c 100644 --- a/core/src/main/java/com/linecorp/armeria/common/sse/DefaultServerSentEvent.java +++ b/core/src/main/java/com/linecorp/armeria/common/sse/DefaultServerSentEvent.java @@ -91,7 +91,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java b/core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java index 3344547cd26..43da4242c5b 100644 --- a/core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java +++ b/core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java @@ -157,7 +157,7 @@ public String query() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedBeanFactoryRegistry.java b/core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedBeanFactoryRegistry.java index f2efdaed2a9..c81f60dcbbc 100644 --- a/core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedBeanFactoryRegistry.java +++ b/core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotatedBeanFactoryRegistry.java @@ -300,7 +300,7 @@ Class type() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/ClientAddressSource.java b/core/src/main/java/com/linecorp/armeria/server/ClientAddressSource.java index e1594f236ec..ccf1ae93e8d 100644 --- a/core/src/main/java/com/linecorp/armeria/server/ClientAddressSource.java +++ b/core/src/main/java/com/linecorp/armeria/server/ClientAddressSource.java @@ -20,6 +20,8 @@ import java.util.List; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; @@ -89,7 +91,7 @@ boolean isProxyProtocol() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/DefaultRoute.java b/core/src/main/java/com/linecorp/armeria/server/DefaultRoute.java index d7dc0858a97..765762f2167 100644 --- a/core/src/main/java/com/linecorp/armeria/server/DefaultRoute.java +++ b/core/src/main/java/com/linecorp/armeria/server/DefaultRoute.java @@ -24,6 +24,8 @@ import java.util.Set; import java.util.StringJoiner; +import javax.annotation.Nullable; + import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -271,7 +273,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } 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 988b294478d..eb40a60919c 100644 --- a/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java +++ b/core/src/main/java/com/linecorp/armeria/server/DefaultRoutingContext.java @@ -149,7 +149,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof DefaultRoutingContext && (this == obj || summary().equals(((DefaultRoutingContext) obj).summary())); } diff --git a/core/src/main/java/com/linecorp/armeria/server/ExactPathMapping.java b/core/src/main/java/com/linecorp/armeria/server/ExactPathMapping.java index 6f56259ff00..da0be07b474 100644 --- a/core/src/main/java/com/linecorp/armeria/server/ExactPathMapping.java +++ b/core/src/main/java/com/linecorp/armeria/server/ExactPathMapping.java @@ -82,7 +82,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof ExactPathMapping && (this == obj || exactPath.equals(((ExactPathMapping) obj).exactPath)); } diff --git a/core/src/main/java/com/linecorp/armeria/server/GlobPathMapping.java b/core/src/main/java/com/linecorp/armeria/server/GlobPathMapping.java index 875b2b52d9b..161a0873f73 100644 --- a/core/src/main/java/com/linecorp/armeria/server/GlobPathMapping.java +++ b/core/src/main/java/com/linecorp/armeria/server/GlobPathMapping.java @@ -131,7 +131,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof GlobPathMapping && (this == obj || glob.equals(((GlobPathMapping) obj).glob)); } diff --git a/core/src/main/java/com/linecorp/armeria/server/ParameterizedPathMapping.java b/core/src/main/java/com/linecorp/armeria/server/ParameterizedPathMapping.java index 257d46a1ae9..81a922c0a9c 100644 --- a/core/src/main/java/com/linecorp/armeria/server/ParameterizedPathMapping.java +++ b/core/src/main/java/com/linecorp/armeria/server/ParameterizedPathMapping.java @@ -211,7 +211,7 @@ RoutingResultBuilder doApply(RoutingContext routingCtx) { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/PrefixPathMapping.java b/core/src/main/java/com/linecorp/armeria/server/PrefixPathMapping.java index 6c5bae1e28a..661b3f8ec48 100644 --- a/core/src/main/java/com/linecorp/armeria/server/PrefixPathMapping.java +++ b/core/src/main/java/com/linecorp/armeria/server/PrefixPathMapping.java @@ -96,7 +96,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (!(obj instanceof PrefixPathMapping)) { return false; } diff --git a/core/src/main/java/com/linecorp/armeria/server/RegexPathMapping.java b/core/src/main/java/com/linecorp/armeria/server/RegexPathMapping.java index 7a1055b9e88..4f9d95bffaf 100644 --- a/core/src/main/java/com/linecorp/armeria/server/RegexPathMapping.java +++ b/core/src/main/java/com/linecorp/armeria/server/RegexPathMapping.java @@ -127,7 +127,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof RegexPathMapping && (this == obj || regex.pattern().equals(((RegexPathMapping) obj).regex.pattern())); } diff --git a/core/src/main/java/com/linecorp/armeria/server/RegexPathMappingWithPrefix.java b/core/src/main/java/com/linecorp/armeria/server/RegexPathMappingWithPrefix.java index dbba07e6abb..3c45ff76015 100644 --- a/core/src/main/java/com/linecorp/armeria/server/RegexPathMappingWithPrefix.java +++ b/core/src/main/java/com/linecorp/armeria/server/RegexPathMappingWithPrefix.java @@ -91,7 +91,7 @@ public List paths() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/RouteBuilder.java b/core/src/main/java/com/linecorp/armeria/server/RouteBuilder.java index e3dd10ced87..4bca3273b7d 100644 --- a/core/src/main/java/com/linecorp/armeria/server/RouteBuilder.java +++ b/core/src/main/java/com/linecorp/armeria/server/RouteBuilder.java @@ -285,7 +285,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/ServerPort.java b/core/src/main/java/com/linecorp/armeria/server/ServerPort.java index 6b6e802549a..717e6dc0adc 100644 --- a/core/src/main/java/com/linecorp/armeria/server/ServerPort.java +++ b/core/src/main/java/com/linecorp/armeria/server/ServerPort.java @@ -185,7 +185,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/auth/BasicToken.java b/core/src/main/java/com/linecorp/armeria/server/auth/BasicToken.java index 3b721e0fc0e..1eb34841208 100644 --- a/core/src/main/java/com/linecorp/armeria/server/auth/BasicToken.java +++ b/core/src/main/java/com/linecorp/armeria/server/auth/BasicToken.java @@ -20,6 +20,8 @@ import java.util.Objects; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; /** @@ -51,7 +53,7 @@ public String password() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/auth/OAuth1aToken.java b/core/src/main/java/com/linecorp/armeria/server/auth/OAuth1aToken.java index 6547e44a3c0..4a024c588fa 100644 --- a/core/src/main/java/com/linecorp/armeria/server/auth/OAuth1aToken.java +++ b/core/src/main/java/com/linecorp/armeria/server/auth/OAuth1aToken.java @@ -20,6 +20,8 @@ import java.util.Map.Entry; import java.util.Set; +import javax.annotation.Nullable; + import com.google.common.base.Ascii; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; @@ -185,7 +187,7 @@ public Map additionals() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/auth/OAuth2Token.java b/core/src/main/java/com/linecorp/armeria/server/auth/OAuth2Token.java index 6f3e4d55ffb..793e8e40fbf 100644 --- a/core/src/main/java/com/linecorp/armeria/server/auth/OAuth2Token.java +++ b/core/src/main/java/com/linecorp/armeria/server/auth/OAuth2Token.java @@ -18,6 +18,8 @@ import static java.util.Objects.requireNonNull; +import javax.annotation.Nullable; + /** * The bearer token of OAuth 2.0 authentication. */ @@ -41,7 +43,7 @@ public String accessToken() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/EndpointInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/EndpointInfo.java index 43d7600213c..137893696f7 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/EndpointInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/EndpointInfo.java @@ -128,7 +128,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (!(obj instanceof EndpointInfo)) { return false; } 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 e6affc89cd0..f10b1f43bf6 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 @@ -102,7 +102,7 @@ public String docString() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/EnumValueInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/EnumValueInfo.java index ba25aec066b..a11132efb23 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/EnumValueInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/EnumValueInfo.java @@ -104,7 +104,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } 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 248273bde2c..8b0bd74caff 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 @@ -83,7 +83,7 @@ public Set findNamedTypes() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/FieldInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/FieldInfo.java index a1fabd50d10..6bd92e44a22 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/FieldInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/FieldInfo.java @@ -116,7 +116,7 @@ public String docString() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/MethodInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/MethodInfo.java index 5d81f2ef2a6..f503c9894f3 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/MethodInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/MethodInfo.java @@ -186,7 +186,7 @@ public String docString() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/ServiceInfo.java b/core/src/main/java/com/linecorp/armeria/server/docs/ServiceInfo.java index f303cd91a71..00a7eb39f17 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/ServiceInfo.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/ServiceInfo.java @@ -143,7 +143,7 @@ public List exampleHttpHeaders() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } 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 da3fa16afee..f99a775b33c 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 @@ -83,7 +83,7 @@ public Set findNamedTypes() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/docs/TypeSignature.java b/core/src/main/java/com/linecorp/armeria/server/docs/TypeSignature.java index 12a648de10f..871e90c44f5 100644 --- a/core/src/main/java/com/linecorp/armeria/server/docs/TypeSignature.java +++ b/core/src/main/java/com/linecorp/armeria/server/docs/TypeSignature.java @@ -299,7 +299,7 @@ public boolean isUnresolved() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/src/main/java/com/linecorp/armeria/server/file/HttpFileAttributes.java b/core/src/main/java/com/linecorp/armeria/server/file/HttpFileAttributes.java index 592147b7c25..af84df48a2e 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/HttpFileAttributes.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/HttpFileAttributes.java @@ -19,6 +19,8 @@ import java.util.Date; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; import io.netty.handler.codec.DateFormatter; @@ -66,7 +68,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == null || obj.getClass() != HttpFileAttributes.class) { return false; } diff --git a/core/src/main/java/com/linecorp/armeria/server/file/HttpFileService.java b/core/src/main/java/com/linecorp/armeria/server/file/HttpFileService.java index 308b3500548..8083e0c8ef8 100644 --- a/core/src/main/java/com/linecorp/armeria/server/file/HttpFileService.java +++ b/core/src/main/java/com/linecorp/armeria/server/file/HttpFileService.java @@ -373,7 +373,7 @@ private static final class PathAndEncoding { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java b/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java index 4d25effbec3..b4efef3afc1 100644 --- a/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java +++ b/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java @@ -131,7 +131,7 @@ public int type() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/logback/src/main/java/com/linecorp/armeria/common/logback/RequestContextExporter.java b/logback/src/main/java/com/linecorp/armeria/common/logback/RequestContextExporter.java index 16b070b0845..29ab7ac6269 100644 --- a/logback/src/main/java/com/linecorp/armeria/common/logback/RequestContextExporter.java +++ b/logback/src/main/java/com/linecorp/armeria/common/logback/RequestContextExporter.java @@ -471,7 +471,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/retrofit2/src/test/java/com/linecorp/armeria/client/retrofit2/ArmeriaCallFactoryTest.java b/retrofit2/src/test/java/com/linecorp/armeria/client/retrofit2/ArmeriaCallFactoryTest.java index 34e9a963d1f..4d81c9d273f 100644 --- a/retrofit2/src/test/java/com/linecorp/armeria/client/retrofit2/ArmeriaCallFactoryTest.java +++ b/retrofit2/src/test/java/com/linecorp/armeria/client/retrofit2/ArmeriaCallFactoryTest.java @@ -91,7 +91,7 @@ public static class Pojo { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (o == this) { return true; } diff --git a/saml/src/main/java/com/linecorp/armeria/server/saml/SamlEndpoint.java b/saml/src/main/java/com/linecorp/armeria/server/saml/SamlEndpoint.java index c2f04be3a52..e294050ac0e 100644 --- a/saml/src/main/java/com/linecorp/armeria/server/saml/SamlEndpoint.java +++ b/saml/src/main/java/com/linecorp/armeria/server/saml/SamlEndpoint.java @@ -22,6 +22,8 @@ import java.net.URI; import java.net.URISyntaxException; +import javax.annotation.Nullable; + import com.google.common.base.MoreObjects; import com.linecorp.armeria.common.util.Exceptions; @@ -120,7 +122,7 @@ public SamlBindingProtocol bindingProtocol() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/spring/boot-webflux-autoconfigure/src/test/java/com/linecorp/armeria/spring/web/reactive/ArmeriaWebClientTest.java b/spring/boot-webflux-autoconfigure/src/test/java/com/linecorp/armeria/spring/web/reactive/ArmeriaWebClientTest.java index 298e7333774..ca97fbdf2a9 100644 --- a/spring/boot-webflux-autoconfigure/src/test/java/com/linecorp/armeria/spring/web/reactive/ArmeriaWebClientTest.java +++ b/spring/boot-webflux-autoconfigure/src/test/java/com/linecorp/armeria/spring/web/reactive/ArmeriaWebClientTest.java @@ -19,6 +19,8 @@ import java.time.Duration; +import javax.annotation.Nullable; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -201,7 +203,7 @@ public int age() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/thrift/src/main/java/com/linecorp/armeria/common/thrift/ThriftMessage.java b/thrift/src/main/java/com/linecorp/armeria/common/thrift/ThriftMessage.java index f10c221bb7d..690b6e4be32 100644 --- a/thrift/src/main/java/com/linecorp/armeria/common/thrift/ThriftMessage.java +++ b/thrift/src/main/java/com/linecorp/armeria/common/thrift/ThriftMessage.java @@ -18,6 +18,8 @@ import static java.util.Objects.requireNonNull; +import javax.annotation.Nullable; + import org.apache.thrift.protocol.TMessage; import org.apache.thrift.protocol.TMessageType; @@ -45,7 +47,7 @@ public int hashCode() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; }