Skip to content

Commit

Permalink
fix: Update POMs to run errorprone analyzers and fix found issues (#677)
Browse files Browse the repository at this point in the history
* fix: Update POMs to run errorprone analyzers and fix found issues

* fix: Disable ErrorProne until I can figure out how to enable it long term, but keep other pom changes.

* fix: Add back errorprone blocks commented out
  • Loading branch information
dpcollins-google committed Jun 8, 2021
1 parent d583623 commit fb1cab4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
public class AssignerSettingsTest {
@Test
public void testBuilder() {
AssignerSettings.newBuilder()
.setSubscriptionPath(
SubscriptionPath.newBuilder()
.setLocation(CloudZone.of(CloudRegion.of("us-central1"), 'a'))
.setProject(ProjectNumber.of(3))
.setName(SubscriptionName.of("abc"))
.build())
.setReceiver(mock(PartitionAssignmentReceiver.class))
.setServiceClient(mock(PartitionAssignmentServiceClient.class))
.build();
AssignerSettings unusedSettings =
AssignerSettings.newBuilder()
.setSubscriptionPath(
SubscriptionPath.newBuilder()
.setLocation(CloudZone.of(CloudRegion.of("us-central1"), 'a'))
.setProject(ProjectNumber.of(3))
.setName(SubscriptionName.of("abc"))
.build())
.setReceiver(mock(PartitionAssignmentReceiver.class))
.setServiceClient(mock(PartitionAssignmentServiceClient.class))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void waitUntilEmptyReturnsWhenEmpty() throws Exception {

@Test
public void waitUntilEmptyReturnsOnShutdown() throws Exception {
committer.commitOffset(Offset.of(10));
Future<?> unusedFuture = committer.commitOffset(Offset.of(10));

CountDownLatch latch = new CountDownLatch(1);
Future<?> waitFuture =
Expand Down Expand Up @@ -246,7 +246,7 @@ public void waitUntilEmptyReturnsOnShutdown() throws Exception {

@Test
public void waitUntilEmptyThrowsOnPermanentError() throws Exception {
committer.commitOffset(Offset.of(10));
Future<?> unusedFuture = committer.commitOffset(Offset.of(10));

Future<?> waitFuture =
executorService.submit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.cloud.pubsublite.internal.testing.FakeApiService;
import com.google.protobuf.ByteString;
import java.time.Duration;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -109,8 +110,8 @@ public void testPublishWithKey() throws Exception {
when(mockRoutingPolicy.route(message0.key())).thenReturn(Partition.of(0));
when(mockRoutingPolicy.route(message1.key())).thenReturn(Partition.of(1));

publisher.publish(message0);
publisher.publish(message1);
Future<?> unusedFuture0 = publisher.publish(message0);
Future<?> unusedFuture1 = publisher.publish(message1);

verify(publisher0).publish(message0);
verify(publisher1).publish(message1);
Expand All @@ -125,8 +126,8 @@ public void testPublishWithoutKey() throws Exception {
.thenReturn(Partition.of(0))
.thenReturn(Partition.of(1));

publisher.publish(messageA);
publisher.publish(messageB);
Future<?> unusedFutureA = publisher.publish(messageA);
Future<?> unusedFutureB = publisher.publish(messageB);

verify(publisher0).publish(messageA);
verify(publisher1).publish(messageB);
Expand All @@ -137,7 +138,7 @@ public void testPublishWithBadRouting() throws Exception {
Message message = Message.builder().build();

when(mockRoutingPolicy.routeWithoutKey()).thenReturn(Partition.of(4));
publisher.publish(message);
Future<?> unusedFuture = publisher.publish(message);

ApiExceptionMatcher.assertThrowableMatches(
publisher.failureCause(), StatusCode.Code.FAILED_PRECONDITION);
Expand Down Expand Up @@ -181,9 +182,9 @@ public void testIncreaseSucceeds() throws Exception {
when(mockRoutingPolicy.route(message1.key())).thenReturn(Partition.of(1));
when(mockRoutingPolicy.route(message2.key())).thenReturn(Partition.of(2));

publisher.publish(message0);
publisher.publish(message1);
publisher.publish(message2);
Future<?> unusedFuture0 = publisher.publish(message0);
Future<?> unusedFuture1 = publisher.publish(message1);
Future<?> unusedFuture2 = publisher.publish(message2);

verify(publisher0).publish(message0);
verify(publisher1).publish(message1);
Expand All @@ -199,8 +200,8 @@ public void testDecreaseIgnored() throws Exception {
when(mockRoutingPolicy.route(message0.key())).thenReturn(Partition.of(0));
when(mockRoutingPolicy.route(message1.key())).thenReturn(Partition.of(1));

publisher.publish(message0);
publisher.publish(message1);
Future<?> unusedFuture0 = publisher.publish(message0);
Future<?> unusedFuture1 = publisher.publish(message1);

verify(publisher0).publish(message0);
verify(publisher1).publish(message1);
Expand All @@ -216,8 +217,8 @@ public void testNoopConfigUpdate() throws Exception {
when(mockRoutingPolicy.route(message0.key())).thenReturn(Partition.of(0));
when(mockRoutingPolicy.route(message1.key())).thenReturn(Partition.of(1));

publisher.publish(message0);
publisher.publish(message1);
Future<?> unusedFuture0 = publisher.publish(message0);
Future<?> unusedFuture1 = publisher.publish(message1);

verify(publisher0).publish(message0);
verify(publisher1).publish(message1);
Expand Down
33 changes: 19 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<artifactId>auto-service-annotations</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
Expand Down Expand Up @@ -98,7 +103,13 @@
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgument>-Xlint:unchecked</compilerArgument>
<compilerArgs>
<arg>-Xlint:all</arg>
<!-- UNCOMMENT FOR ERRORPRONE>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
</!-->
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.value</groupId>
Expand All @@ -110,6 +121,13 @@
<artifactId>auto-service</artifactId>
<version>1.0</version>
</path>
<!-- UNCOMMENT FOR ERRORPRONE>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.7.1</version>
</path>
</!-->
</annotationProcessorPaths>
</configuration>
</plugin>
Expand All @@ -125,19 +143,6 @@
</modules>

<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>[8,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
</dependencies>
</profile>

<profile>
<id>include-samples</id>
<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ private SubscriberServiceClient newSubscriberServiceClient(Partition partition)
throws ApiException {
try {
SubscriberServiceSettings.Builder settingsBuilder = SubscriberServiceSettings.newBuilder();
addDefaultMetadata(
PubsubContext.of(FRAMEWORK),
RoutingMetadata.of(subscriptionPath(), partition),
settingsBuilder);
settingsBuilder =
addDefaultMetadata(
PubsubContext.of(FRAMEWORK),
RoutingMetadata.of(subscriptionPath(), partition),
settingsBuilder);
return SubscriberServiceClient.create(
addDefaultSettings(subscriptionPath().location().region(), settingsBuilder));
} catch (Throwable t) {
Expand Down

0 comments on commit fb1cab4

Please sign in to comment.