Skip to content

Commit

Permalink
Fix it-mongo compile fail on Java11 (apache#32243)
Browse files Browse the repository at this point in the history
* Fix it-mongo compile fail on Java11

* Fix more checkFramework
  • Loading branch information
Abacn authored Aug 20, 2024
1 parent 714f08b commit 6582e7a
Show file tree
Hide file tree
Showing 26 changed files with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import java.time.Duration;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.common.utils.ExceptionUtils;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.CassandraContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.beam.sdk.Pipeline;
import org.checkerframework.checker.nullness.qual.Nullable;

/** Client for working with Cloud Dataflow. */
@SuppressWarnings({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.apache.beam.it.common.utils;

import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;

/** Utility class for handling exceptions in tests or resource managers. */
public class ExceptionUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.util.List;
import java.util.Random;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.hash.HashFunction;
import org.apache.commons.lang3.RandomStringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.beam.it.conditions;

import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
import org.apache.http.HttpHost;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.bulk.BulkRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.apache.beam.it.common.PipelineLauncher;
import org.apache.beam.it.common.PipelineLauncher.LaunchInfo;
import org.apache.beam.it.common.PipelineOperator;
import org.apache.beam.it.common.TestProperties;
import org.apache.beam.it.gcp.bigquery.BigQueryResourceManager;
import org.apache.beam.it.gcp.monitoring.MonitoringClient;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.MoreObjects;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import com.google.auto.value.AutoValue;
import com.google.cloud.bigquery.TableId;
import javax.annotation.Nullable;
import org.apache.beam.it.conditions.ConditionCheck;
import org.apache.beam.it.gcp.bigquery.BigQueryResourceManager;
import org.checkerframework.checker.nullness.qual.Nullable;

/** ConditionCheck to validate if BigQuery has received a certain number of rows. */
@AutoValue
Expand All @@ -33,8 +33,7 @@ public abstract class BigQueryRowsCheck extends ConditionCheck {

abstract Integer minRows();

@Nullable
abstract Integer maxRows();
abstract @Nullable Integer maxRows();

@Override
public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.bp.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.apache.beam.it.common.PipelineLauncher;
import org.apache.beam.it.common.TestProperties;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.beam.it.common.PipelineLauncher.LaunchInfo;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import com.google.pubsub.v1.SubscriptionName;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.beam.it.conditions.ConditionCheck;
import org.apache.beam.it.gcp.pubsub.PubsubResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.MoreObjects;
import org.checkerframework.checker.nullness.qual.Nullable;

/** ConditionCheck to validate if Pub/Sub has received a certain amount of messages. */
@AutoValue
Expand All @@ -38,8 +38,7 @@ public abstract class PubsubMessagesCheck extends ConditionCheck {

abstract Integer minMessages();

@Nullable
abstract Integer maxMessages();
abstract @Nullable Integer maxMessages();

private final List<ReceivedMessage> receivedMessageList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
import dev.failsafe.RetryPolicy;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.common.utils.ExceptionUtils;
import org.apache.beam.it.gcp.spanner.utils.SpannerResourceManagerUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ abstract static class TestConfiguration {
* The expected table to check against for correctness. If unset, the test will run a batch
* FILE_LOADS job and use the resulting table as a source of truth.
*/
@Nullable
abstract String getExpectedTable();
abstract @Nullable String getExpectedTable();

static TestConfiguration of(
int numMin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
Expand All @@ -35,6 +34,7 @@
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
Expand Down
4 changes: 4 additions & 0 deletions it/mongodb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ dependencies {
permitUsedUndeclared library.java.guava
testImplementation library.java.commons_lang3
testRuntimeOnly library.java.slf4j_simple

// Otherwise checkerframework crashes on Java11
compileOnly library.java.error_prone_annotations
permitUsedUndeclared library.java.error_prone_annotations
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
import org.bson.Document;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.MongoDBContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package org.apache.beam.it.mongodb.conditions;

import com.google.auto.value.AutoValue;
import javax.annotation.Nullable;
import org.apache.beam.it.conditions.ConditionCheck;
import org.apache.beam.it.mongodb.MongoDBResourceManager;
import org.checkerframework.checker.nullness.qual.Nullable;

/** ConditionCheck to validate if MongoDB has received a certain amount of documents. */
@AutoValue
Expand All @@ -32,8 +32,7 @@ public abstract class MongoDBDocumentsCheck extends ConditionCheck {

abstract Integer minDocuments();

@Nullable
abstract Integer maxDocuments();
abstract @Nullable Integer maxDocuments();

@Override
public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.beam.it.conditions.ConditionCheck;
import org.apache.beam.it.neo4j.Neo4jResourceManager;
import org.checkerframework.checker.nullness.qual.Nullable;

@AutoValue
public abstract class Neo4jQueryCheck extends ConditionCheck {
Expand All @@ -36,8 +36,7 @@ public abstract class Neo4jQueryCheck extends ConditionCheck {

abstract String query();

@Nullable
abstract Map<String, Object> parameters();
abstract @Nullable Map<String, Object> parameters();

@Override
public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.testcontainers.TestContainerResourceManager;
import org.apache.beam.sdk.io.splunk.SplunkEvent;
Expand All @@ -44,6 +43,7 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.awaitility.Awaitility;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,21 @@
package org.apache.beam.it.splunk.conditions;

import com.google.auto.value.AutoValue;
import javax.annotation.Nullable;
import org.apache.beam.it.conditions.ConditionCheck;
import org.apache.beam.it.splunk.SplunkResourceManager;
import org.checkerframework.checker.nullness.qual.Nullable;

/** ConditionCheck to validate if Splunk has received a certain amount of events. */
@AutoValue
public abstract class SplunkEventsCheck extends ConditionCheck {

abstract SplunkResourceManager resourceManager();

@Nullable
abstract String query();
abstract @Nullable String query();

abstract Integer minEvents();

@Nullable
abstract Integer maxEvents();
abstract @Nullable Integer maxEvents();

@Override
public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package org.apache.beam.it.testcontainers;

import java.util.concurrent.Callable;
import javax.annotation.Nullable;
import org.apache.beam.it.common.ResourceManager;
import org.apache.beam.it.common.TestProperties;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.beam.it.common.PipelineLauncher.LaunchInfo;
import org.apache.beam.it.common.PipelineOperator.Result;
import org.checkerframework.checker.nullness.qual.Nullable;

/** Assert utilities for Template DSL-like tests. */
public class PipelineAsserts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Subject that has assertion operations for record lists, usually coming from the result of a
Expand Down

0 comments on commit 6582e7a

Please sign in to comment.