Skip to content

Commit

Permalink
Fix the errors reported by NullAway (line#2776)
Browse files Browse the repository at this point in the history
Motivation:

Before adopting NullAway(line#1680) or other static analysis tools.
Manually run it and clean up errors.

Modifications:

- Fix all true positives reported by NullAway

Result:

Less NullAway errors
  • Loading branch information
ikhoon authored Jun 8, 2020
1 parent c7e0cb7 commit 57f3647
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ ScheduledFuture<?> timeoutFuture() {
return timeoutFuture;
}

@Nullable
@VisibleForTesting
TimeoutTask timeoutTask() {
return timeoutTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class ObjectCollectingUtil {
* The {@link Class} instance of {@code reactor.core.publisher.Mono} of
* <a href="https://projectreactor.io/">Project Reactor</a>.
*/
@Nullable
private static final Class<?> MONO_CLASS;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ static <T extends Annotation> List<T> find(AnnotatedElement element, Class<T> an

private static <T extends Annotation> void findMetaAnnotations(
Builder<T> builder, Annotation annotation,
Class<T> annotationType, Class<? extends Annotation> containerType) {
Class<T> annotationType, @Nullable Class<? extends Annotation> containerType) {
findMetaAnnotations(builder, annotation, annotationType, containerType,
Collections.newSetFromMap(new IdentityHashMap<>()));
}

private static <T extends Annotation> boolean findMetaAnnotations(
Builder<T> builder, Annotation annotation,
Class<T> annotationType, Class<? extends Annotation> containerType,
Class<T> annotationType, @Nullable Class<? extends Annotation> containerType,
Set<Class<? extends Annotation>> visitedAnnotationTypes) {

final Class<? extends Annotation> actualAnnotationType = annotation.annotationType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> docStrings) {
return currentDocString != null ? currentDocString : docStrings.get(key);
Expand Down

0 comments on commit 57f3647

Please sign in to comment.