Build Nomulus with Java 17 (#2255)

This PR makes it possible to build the Nomulus code base using Java 17.
Building with Java 11 continue to be possible and the resulting bytecodes are
still at Java 8 level. Also upgraded Gradle to 8.5.

There are several necessary changes to make this happen:

1. Some Gradle plugins need to be upgraded to support Java 17, notably
errorprone. As a result, a lot more "errors" were caught and corrected.

2. All test code are now built and run at Java 8 level. Previously it was left
undefined (which defaults to the version of the compiler) and had led to
situations where we inadvertently called Java 8+ features in production that
are not caught by tests. The change also made the java8compatibility subproject
obsolete, which is therefore removed.

3. Removed the docs subproject. Its main use is to generate flows.md, but it
relies heavily on Java internal APIs that have changed significant with each
version. Upgrading to Java 11 required extensive refactoring of the code there,
and Java 17 again removed many APIs that were used. I don't think it is worth
the maintenance effort just to have a tool to generate flows.md which no one
actually reads.

4. Capped a few GCP dependencies because the latest version depends on
 grpc-java >= 1.59.0, which includes a runtime incompatibility
 (https://github.com/grpc/grpc-java/releases/tag/v1.59.0).
This commit is contained in:
Lai Jiang
2024-01-09 15:56:37 -05:00
committed by GitHub
parent e79c63142a
commit b5d2b56426
134 changed files with 750 additions and 3731 deletions
+25 -30
View File
@@ -2,7 +2,7 @@
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
antlr:antlr:2.7.7=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
aopalliance:aopalliance:1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
aopalliance:aopalliance:1.0=annotationProcessor,compileClasspath,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
args4j:args4j:2.0.23=soy
args4j:args4j:2.0.26=css
args4j:args4j:2.33=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -18,8 +18,8 @@ com.fasterxml.jackson.datatype:jackson-datatype-joda:2.15.2=compileClasspath,dep
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson:jackson-bom:2.15.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.fasterxml:classmate:1.5.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ben-manes.caffeine:caffeine:2.7.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.github.ben-manes.caffeine:caffeine:2.9.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ben-manes.caffeine:caffeine:3.0.5=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.github.docker-java:docker-java-api:3.3.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.docker-java:docker-java-transport-zerodep:3.3.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.docker-java:docker-java-transport:3.3.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -68,8 +68,8 @@ com.google.api.grpc:proto-google-cloud-spanner-admin-instance-v1:6.55.0=compileC
com.google.api.grpc:proto-google-cloud-spanner-v1:6.55.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-storage-v2:2.23.0-alpha=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-tasks-v2:2.23.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-tasks-v2beta2:0.122.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-tasks-v2beta3:0.122.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-tasks-v2beta2:0.113.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-cloud-tasks-v2beta3:0.113.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-common-protos:2.29.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api.grpc:proto-google-iam-v1:1.24.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.api:api-common:2.21.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -98,12 +98,13 @@ com.google.appengine:appengine-api-stubs:2.0.24=testCompileClasspath,testRuntime
com.google.appengine:appengine-testing:1.9.86=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.auth:google-auth-library-credentials:1.20.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.auth:google-auth-library-oauth2-http:1.20.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.auto.service:auto-service-annotations:1.0.1=errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.auto.service:auto-service:1.1.1=annotationProcessor
com.google.auto.value:auto-value-annotations:1.10.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.auto.value:auto-value:1.10.4=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.auto:auto-common:0.10=errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.auto:auto-common:1.2.1=annotationProcessor
com.google.auto:auto-common:1.2.1=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.closure-stylesheets:closure-stylesheets:1.5.0=css
com.google.cloud.bigdataoss:gcsio:2.2.16=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud.bigdataoss:util:2.2.16=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -126,10 +127,9 @@ com.google.cloud:google-cloud-pubsublite:1.12.19=compileClasspath,deploy_jar,non
com.google.cloud:google-cloud-secretmanager:2.23.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:google-cloud-spanner:6.55.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:google-cloud-storage:2.22.6=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:google-cloud-tasks:2.32.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:google-cloud-tasks:2.23.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:grpc-gcp:1.5.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.cloud:proto-google-cloud-firestore-bundle-v1:3.15.7=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.code.findbugs:jFormatString:3.0.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.code.findbugs:jsr305:3.0.1=css
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodCompileClasspath,nonprodRuntime,nonprodRuntimeClasspath,runtime,runtimeClasspath,soy,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.10.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -139,14 +139,14 @@ com.google.dagger:dagger-compiler:2.50=annotationProcessor,testAnnotationProcess
com.google.dagger:dagger-spi:2.50=annotationProcessor,testAnnotationProcessor
com.google.dagger:dagger:2.50=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14=annotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.3.4=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.23.0=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.3.4=errorprone,nonprodAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.23.0=annotationProcessor,compileClasspath,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.7.1=checkstyle,soy
com.google.errorprone:error_prone_check_api:2.3.4=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.3.4=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_type_annotations:2.3.4=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_check_api:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_type_annotations:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.errorprone:javac-shaded:9-dev-r4023-3=annotationProcessor,testAnnotationProcessor
com.google.errorprone:javac:9+181-r4173-1=errorproneJavac
com.google.escapevelocity:escapevelocity:0.9.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
com.google.flatbuffers:flatbuffers-java:1.12.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.flogger:flogger-system-backend:0.8=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntime,nonprodRuntimeClasspath,runtime,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -155,12 +155,13 @@ com.google.flogger:google-extensions:0.8=compileClasspath,deploy_jar,nonprodComp
com.google.googlejavaformat:google-java-format:1.5=annotationProcessor,testAnnotationProcessor
com.google.guava:failureaccess:1.0.1=checkstyle,errorprone,nonprodAnnotationProcessor,soy
com.google.guava:failureaccess:1.0.2=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava-parent:32.1.1-jre=errorprone,nonprodAnnotationProcessor
com.google.guava:guava-testlib:33.0.0-jre=testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:20.0=css
com.google.guava:guava:27.0.1-jre=errorprone,nonprodAnnotationProcessor
com.google.guava:guava:31.0.1-jre=checkstyle,soy
com.google.guava:guava:32.1.1-jre=errorprone,nonprodAnnotationProcessor
com.google.guava:guava:33.0.0-jre=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.gwt:gwt-user:2.10.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client-apache-v2:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client-appengine:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -170,8 +171,8 @@ com.google.http-client:google-http-client-protobuf:1.43.3=compileClasspath,deplo
com.google.http-client:google-http-client:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.inject.extensions:guice-multibindings:4.1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
com.google.inject:guice:4.1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.inject:guice:5.1.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.inject:guice:7.0.0=soy
com.google.j2objc:j2objc-annotations:1.1=errorprone,nonprodAnnotationProcessor
com.google.j2objc:j2objc-annotations:1.3=checkstyle,soy
com.google.j2objc:j2objc-annotations:2.8=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.javascript:closure-compiler-externs:v20160713=css
@@ -189,14 +190,13 @@ com.google.oauth-client:google-oauth-client-servlet:1.34.1=compileClasspath,depl
com.google.oauth-client:google-oauth-client:1.34.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.protobuf:protobuf-java-util:3.25.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.protobuf:protobuf-java:2.5.0=css
com.google.protobuf:protobuf-java:3.19.6=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.protobuf:protobuf-java:3.25.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.protobuf:protobuf-java:3.4.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.google.protobuf:protobuf-java:4.0.0-rc-2=soy
com.google.re2j:re2j:1.7=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.template:soy:2021-02-01=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
com.google.truth.extensions:truth-java8-extension:1.2.0=testCompileClasspath,testRuntimeClasspath
com.google.truth:truth:1.2.0=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.googlecode.java-diff-utils:diffutils:1.3.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
com.googlecode.json-simple:json-simple:1.1.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.ibm.icu:icu4j:57.1=compileClasspath,nonprodCompileClasspath,soy,testCompileClasspath
com.ibm.icu:icu4j:74.2=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
@@ -237,7 +237,8 @@ io.confluent:common-utils:5.3.2=compileClasspath,deploy_jar,nonprodCompileClassp
io.confluent:kafka-avro-serializer:5.3.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.confluent:kafka-schema-registry-client:5.3.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.github.classgraph:classgraph:4.8.162=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.github.java-diff-utils:java-diff-utils:4.12=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.github.eisop:dataflow-errorprone:3.34.0-eisop1=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-alts:1.59.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-api:1.59.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-auth:1.59.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -290,7 +291,7 @@ javax.activation:activation:1.1=compileClasspath,deploy_jar,nonprodCompileClassp
javax.activation:javax.activation-api:1.2.0=compileClasspath,deploy_jar,jaxb,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.annotation:javax.annotation-api:1.3.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.annotation:jsr250-api:1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
javax.inject:javax.inject:1=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
javax.inject:javax.inject:1=annotationProcessor,compileClasspath,deploy_jar,errorprone,nonprodAnnotationProcessor,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
javax.jdo:jdo2-api:2.3-20090302111651=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.mail:mail:1.5.0-b01=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.persistence:javax.persistence-api:2.2=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
@@ -357,15 +358,12 @@ org.bouncycastle:bcprov-jdk15on:1.67=compileClasspath,deploy_jar,nonprodCompileC
org.checkerframework:checker-compat-qual:2.5.3=compileClasspath,nonprodCompileClasspath,nonprodRuntime,runtime,testCompileClasspath
org.checkerframework:checker-compat-qual:2.5.5=annotationProcessor,testAnnotationProcessor
org.checkerframework:checker-compat-qual:2.5.6=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.0.0=errorprone,nonprodAnnotationProcessor
org.checkerframework:checker-qual:3.12.0=checkstyle,soy
org.checkerframework:checker-qual:3.33.0=errorprone,nonprodAnnotationProcessor
org.checkerframework:checker-qual:3.41.0=annotationProcessor,compileClasspath,nonprodCompileClasspath,nonprodRuntime,runtime,testAnnotationProcessor
org.checkerframework:checker-qual:3.42.0=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:dataflow:3.0.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.checkerframework:javacutil:3.0.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.codehaus.jackson:jackson-core-asl:1.9.13=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.jackson:jackson-mapper-asl:1.9.13=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.17=errorprone,nonprodAnnotationProcessor
org.codehaus.mojo:animal-sniffer-annotations:1.23=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.conscrypt:conscrypt-openjdk-uber:2.5.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.easymock:easymock:3.0=css
@@ -449,10 +447,7 @@ org.ow2.asm:asm-util:9.6=compileClasspath,deploy_jar,nonprodCompileClasspath,non
org.ow2.asm:asm:7.0=soy
org.ow2.asm:asm:9.5=jacocoAnt
org.ow2.asm:asm:9.6=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.pcollections:pcollections:2.1.2=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.plumelib:plume-util:1.0.6=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.plumelib:reflection-util:0.0.2=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.plumelib:require-javadoc:0.1.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.pcollections:pcollections:3.1.4=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
org.postgresql:postgresql:42.7.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntime,nonprodRuntimeClasspath,runtime,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.reflections:reflections:0.10.2=checkstyle
org.rnorth.duct-tape:duct-tape:1.0.8=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -494,4 +489,4 @@ us.fatehi:schemacrawler-utility:16.10.1=compileClasspath,deploy_jar,nonprodCompi
us.fatehi:schemacrawler:16.10.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
xerces:xmlParserAPIs:2.6.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
xpp3:xpp3:1.1.4c=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
empty=devtool,errorproneJavac,nomulus_test
empty=devtool,nomulus_test
@@ -39,7 +39,6 @@ import google.registry.request.Action;
import google.registry.request.Response;
import google.registry.request.auth.Auth;
import google.registry.util.EmailMessage;
import java.util.Date;
import java.util.Optional;
import javax.inject.Inject;
import javax.mail.internet.AddressException;
@@ -160,12 +159,11 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
try {
ImmutableSet<InternetAddress> recipients = getEmailAddresses(registrar, Type.TECH);
ImmutableSet<InternetAddress> ccs = getEmailAddresses(registrar, Type.ADMIN);
Date expirationDate = certificateChecker.getCertificate(certificate.get()).getNotAfter();
DateTime expirationDate =
new DateTime(certificateChecker.getCertificate(certificate.get()).getNotAfter());
logger.atInfo().log(
" %s SSL certificate of registrar '%s' will expire on %s.",
certificateType.getDisplayName(),
registrar.getRegistrarName(),
expirationDate.toString());
certificateType.getDisplayName(), registrar.getRegistrarName(), expirationDate);
if (recipients.isEmpty() && ccs.isEmpty()) {
logger.atWarning().log(
"Registrar %s contains no TECH nor ADMIN email addresses to receive notification"
@@ -302,7 +300,7 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
@VisibleForTesting
@SuppressWarnings("lgtm[java/dereferenced-value-may-be-null]")
String getEmailBody(
String registrarName, CertificateType type, Date expirationDate, String registrarId) {
String registrarName, CertificateType type, DateTime expirationDate, String registrarId) {
checkArgumentNotNull(expirationDate, "Expiration date cannot be null");
checkArgumentNotNull(type, "Certificate type cannot be null");
checkArgumentNotNull(registrarId, "Registrar Id cannot be null");
@@ -310,7 +308,7 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
expirationWarningEmailBodyText,
registrarName,
type.getDisplayName(),
DATE_FORMATTER.print(new DateTime(expirationDate)),
DATE_FORMATTER.print(expirationDate),
registrarId);
}
@@ -63,7 +63,7 @@ public interface RegistryPipelineOptions extends GcpOptions {
}
/**
* Validates the GCP project and Registry environment settings in {@code option}. If project is
* Validates the GCP project and Registry environment settings in {@code options}. If project is
* undefined, it is set according to the Registry environment; if project is defined but
* inconsistent with the Registry environment, an {@link IllegalArgumentException} will be thrown.
*
@@ -144,6 +144,7 @@ public class RdeIO {
this.marshaller = new RdeMarshaller(validationMode);
}
@SuppressWarnings("unused")
@Setup
public void setup() {
Security.addProvider(new BouncyCastleProvider());
@@ -116,14 +116,14 @@ import org.joda.time.DateTime;
* <p>The pipeline is broadly divided into two parts -- creating the {@link DepositFragment}s, and
* processing them.
*
* <h1>Creating {@link DepositFragment}</h1>
* <h2>Creating {@link DepositFragment}</h2>
*
* <h2>{@link Registrar}</h2>
* <h3>{@link Registrar}</h3>
*
* Non-test registrar entities are loaded from Cloud SQL and marshalled into deposit fragments. They
* are <b>NOT</b> rewound to the watermark.
*
* <h2>{@link EppResource}</h2>
* <h3>{@link EppResource}</h3>
*
* All EPP resources are loaded from the corresponding {@link HistoryEntry}, which has the resource
* embedded. In general, we find most recent history entry before watermark and filter out the ones
@@ -158,7 +158,7 @@ import org.joda.time.DateTime;
* watermark to the domain at watermark. We then proceed to create the (pending deposit: deposit
* fragment) pair for subordinate hosts using the added domain information.
*
* <h1>Processing {@link DepositFragment}</h1>
* <h2>Processing {@link DepositFragment}</h2>
*
* The (pending deposit: deposit fragment) pairs from different resources are combined and grouped
* by pending deposit. For each pending deposit, all the relevant deposit fragments are written into
@@ -225,7 +225,7 @@ public class SafeBrowsingTransforms {
new JSONObject(
CharStreams.toString(
new InputStreamReader(response.getEntity().getContent(), UTF_8)));
logger.atInfo().log("Got response: %s", responseBody.toString());
logger.atInfo().log("Got response: %s", responseBody);
if (responseBody.length() == 0) {
logger.atInfo().log("Response was empty, no threats detected.");
} else {
@@ -144,7 +144,8 @@ public class BigqueryConnection implements AutoCloseable {
public Builder setPollInterval(Duration pollInterval) {
checkArgument(
!pollInterval.isShorterThan(MIN_POLL_INTERVAL),
"poll interval must be at least %ldms", MIN_POLL_INTERVAL.getMillis());
"poll interval must be at least %s ms",
MIN_POLL_INTERVAL.getMillis());
instance.pollInterval = pollInterval;
return this;
}
@@ -216,7 +217,7 @@ public class BigqueryConnection implements AutoCloseable {
}
public Builder timeToLive(Duration duration) {
this.table.setExpirationTime(new DateTime(UTC).plus(duration).getMillis());
this.table.setExpirationTime(DateTime.now(UTC).plus(duration).getMillis());
return this;
}
@@ -556,7 +557,6 @@ public class BigqueryConnection implements AutoCloseable {
/**
* Launch a job, but do not wait for it to complete.
*
* @throws BigqueryJobFailureException
*/
private Job launchJob(Job job, @Nullable AbstractInputStreamContent data) {
verify(job.getStatus() == null);
@@ -572,7 +572,6 @@ public class BigqueryConnection implements AutoCloseable {
/**
* Synchronously waits for a job to complete that's already been launched.
*
* @throws BigqueryJobFailureException
*/
private Job waitForJob(Job job) {
verify(job.getStatus() != null);
@@ -591,7 +590,6 @@ public class BigqueryConnection implements AutoCloseable {
/**
* Checks completed job for errors.
*
* @throws BigqueryJobFailureException
*/
private static Job checkJob(Job job) {
verify(job.getStatus() != null);
@@ -72,7 +72,7 @@ public final class BigqueryJobFailureException extends RuntimeException {
/**
* Returns a short error code describing why this job failed.
*
* <h3>Sample Reasons</h3>
* <p>Sample Reasons:
*
* <ul>
* <li>{@code "duplicate"}: The table you're trying to create already exists.
@@ -80,8 +80,8 @@ public final class BigqueryJobFailureException extends RuntimeException {
* <li>{@code "unknown"}: Non-Bigquery errors.
* </ul>
*
* @see <a href="https://cloud.google.com/bigquery/troubleshooting-errors">
* Troubleshooting Errors</a>
* @see <a href="https://cloud.google.com/bigquery/troubleshooting-errors">Troubleshooting
* Errors</a>
*/
public String getReason() {
if (jobStatus != null) {
@@ -117,10 +117,10 @@ public class BlockListFetcher {
private String readChecksum() throws IOException {
StringBuilder checksum = new StringBuilder();
char ch;
while ((ch = peekInputStream()) != (char) -1 && !Character.isWhitespace(ch)) {
while ((ch = peekInputStream()) != Character.MAX_VALUE && !Character.isWhitespace(ch)) {
checksum.append((char) inputStream.read());
}
while ((ch = peekInputStream()) != (char) -1 && Character.isWhitespace(ch)) {
while ((ch = peekInputStream()) != Character.MAX_VALUE && Character.isWhitespace(ch)) {
inputStream.read();
}
return checksum.toString();
@@ -70,7 +70,7 @@ class BsaDiffCreator {
BsaDiff createDiff(DownloadSchedule schedule, IdnChecker idnChecker) {
String currentJobName = schedule.jobName();
Optional<String> previousJobName = schedule.latestCompleted().map(CompletedJob::jobName);
/**
/*
* Memory usage is a concern when creating a diff, when the newest download needs to be held in
* memory in its entirety. The top-grade AppEngine VM has 3GB of memory, leaving less than 1.5GB
* to application memory footprint after subtracting overheads due to copying garbage collection
@@ -92,7 +92,7 @@ class BsaDiffCreator {
try (Stream<Line> currentStream = loadBlockLists(currentJobName);
Stream<Line> previousStream =
previousJobName.map(this::loadBlockLists).orElseGet(Stream::of)) {
/**
/*
* Load current label/order pairs into a multimap, which will contain both new labels and
* those that stay on when processing is done.
*/
@@ -123,7 +123,7 @@ class BsaDiffCreator {
toMultimap(
LabelOrderPair::label, LabelOrderPair::orderId, this::listBackedMultiMap));
/**
/*
* Labels in `newAndRemaining`:
*
* <ul>
@@ -245,7 +245,7 @@ class BsaDiffCreator {
abstract Long orderId();
static <K, V> LabelOrderPair of(String key, Long value) {
static LabelOrderPair of(String key, Long value) {
return new AutoValue_BsaDiffCreator_LabelOrderPair(key, value);
}
}
@@ -86,6 +86,7 @@ class BsaDomainRefresh {
return this;
}
@SuppressWarnings("AmbiguousMethodReference")
VKey<BsaDomainRefresh> vKey() {
return vKey(jobId);
}
@@ -84,9 +84,7 @@ public abstract class DownloadSchedule {
BsaDownload bsaDownload = tm().loadByKey(BsaDownload.vKey(jobId()));
verify(
bsaDownload.getStage().equals(DownloadStage.DOWNLOAD_BLOCK_LISTS),
"Invalid invocation. May only invoke during the DOWNLOAD stage.",
bsaDownload.getStage(),
stage);
"Invalid invocation. May only invoke during the DOWNLOAD stage.");
bsaDownload.setStage(stage);
bsaDownload.setChecksums(checksums);
tm().put(bsaDownload);
@@ -112,7 +112,6 @@ public class DelegatedCredentials extends GoogleCredentials {
* @param clock Used for setting token expiration times.
* @param tokenRefreshDelay The lifetime of each token. Should not exceed one hour according to
* GCP recommendations.
* @return
*/
static DelegatedCredentials createSelfSignedDelegatedCredential(
ServiceAccountSigner signer,
@@ -197,7 +196,9 @@ public class DelegatedCredentials extends GoogleCredentials {
String accessToken = validateString(responseData, "access_token", PARSE_ERROR_PREFIX);
int expiresInSeconds = validateInt32(responseData, "expires_in", PARSE_ERROR_PREFIX);
long expiresAtMilliseconds = clock.nowUtc().getMillis() + expiresInSeconds * 1000L;
return new AccessToken(accessToken, new Date(expiresAtMilliseconds));
@SuppressWarnings("JavaUtilDate")
AccessToken token = new AccessToken(accessToken, new Date(expiresAtMilliseconds));
return token;
}
String createAssertion(JsonFactory jsonFactory, long currentTime) throws IOException {
@@ -253,7 +253,11 @@ public final class RegistryConfig {
return projectId + "-zonefiles";
}
/** @see RegistryConfig#getDatabaseRetention() */
/**
* Returns the length of time before commit logs should be deleted from the database.
*
* @see RegistryConfig#getDatabaseRetention()
*/
@Provides
@Config("databaseRetention")
public static Duration provideDatabaseRetention() {
@@ -294,7 +298,11 @@ public final class RegistryConfig {
return projectId + "-icann-brda";
}
/** @see google.registry.rde.BrdaCopyAction */
/**
* Returns the day of the week on which BRDA deposits should be made.
*
* @see google.registry.rde.BrdaCopyAction
*/
@Provides
@Config("brdaDayOfWeek")
public static int provideBrdaDayOfWeek() {
@@ -53,7 +53,7 @@ import javax.inject.Inject;
/**
* Action for fanning out cron tasks shared by TLD.
*
* <h3>Parameters Reference</h3>
* <h2>Parameters Reference</h2>
*
* <ul>
* <li>{@code endpoint} (Required) URL path of servlet to launch. This may contain pathargs.
@@ -68,7 +68,7 @@ import javax.inject.Inject;
* task.
* </ul>
*
* <h3>Patharg Reference</h3>
* <h2>Patharg Reference</h2>
*
* <p>The following values may be specified inside the "endpoint" param.
*
@@ -245,12 +245,13 @@ public class DnsMetrics {
if (batchSize > 0) {
normalizedProcessingTimePerCommitDist.record(
(double) processingDuration.getMillis() / batchSize,
tld, status.name(), dnsWriter);
processingDuration.getMillis() / (double) batchSize, tld, status.name(), dnsWriter);
normalizedProcessingTimePerItemDist.record(
(double) processingDuration.getMillis() / batchSize,
processingDuration.getMillis() / (double) batchSize,
batchSize,
tld, status.name(), dnsWriter);
tld,
status.name(),
dnsWriter);
}
totalBatchSizePerCommitDist.record(batchSize, tld, status.name(), dnsWriter);
@@ -14,6 +14,7 @@
package google.registry.dns.writer;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
@@ -23,14 +24,12 @@ import javax.inject.Named;
/** Dagger module that disables DNS updates. */
@Module
public final class VoidDnsWriterModule {
public abstract class VoidDnsWriterModule {
@Provides
@Binds
@IntoMap
@StringKey(VoidDnsWriter.NAME)
static DnsWriter provideWriter(VoidDnsWriter writer) {
return writer;
}
abstract DnsWriter provideWriter(VoidDnsWriter writer);
@Provides
@IntoSet
@@ -363,8 +363,8 @@ public class CloudDnsWriter extends BaseDnsWriter {
* <p>This call should be used in conjunction with {@link #getResourceRecordsForDomains} in a
* get-and-set retry loop.
*
* <p>See {@link "<a href="https://cloud.google.com/dns/troubleshooting">Troubleshoot Cloud
* DNS</a>"} for a list of errors produced by the Google Cloud DNS API.
* <p>See <a href="https://cloud.google.com/dns/troubleshooting">Troubleshoot Cloud DNS</a> for a
* list of errors produced by the Google Cloud DNS API.
*
* @throws ZoneStateException if the operation could not be completely successfully because the
* records to delete do not exist, already exist or have been modified with different
@@ -14,6 +14,7 @@
package google.registry.dns.writer.dnsupdate;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
@@ -32,12 +33,10 @@ public abstract class DnsUpdateWriterModule {
return SocketFactory.getDefault();
}
@Provides
@Binds
@IntoMap
@StringKey(DnsUpdateWriter.NAME)
static DnsWriter provideWriter(DnsUpdateWriter writer) {
return writer;
}
abstract DnsWriter provideWriter(DnsUpdateWriter writer);
@Provides
@IntoSet
@@ -14,15 +14,13 @@
package google.registry.flows;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
/** Dagger module for the server Trid provider. */
@Module
public class ServerTridProviderModule {
public abstract class ServerTridProviderModule {
@Provides
static ServerTridProvider provideServerTridProvider(ServerTridProviderImpl defaultProvider) {
return defaultProvider;
}
@Binds
abstract ServerTridProvider provideServerTridProvider(ServerTridProviderImpl defaultProvider);
}
@@ -42,9 +42,10 @@ import org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator;
import org.bouncycastle.util.io.pem.PemObjectGenerator;
import org.bouncycastle.util.io.pem.PemWriter;
import org.joda.time.DateTime;
import org.joda.time.DateTimeComparator;
import org.joda.time.Days;
/** An utility to check that a given certificate meets our requirements */
/** A utility to check that a given certificate meets our requirements */
public class CertificateChecker {
private final ImmutableSortedMap<DateTime, Integer> maxValidityLengthSchedule;
@@ -162,9 +163,9 @@ public class CertificateChecker {
// Check if currently in validity period
Date now = clock.nowUtc().toDate();
if (certificate.getNotAfter().before(now)) {
if (DateTimeComparator.getInstance().compare(certificate.getNotAfter(), now) < 0) {
violations.add(CertificateViolation.EXPIRED);
} else if (certificate.getNotBefore().after(now)) {
} else if (DateTimeComparator.getInstance().compare(certificate.getNotBefore(), now) > 0) {
violations.add(CertificateViolation.NOT_YET_VALID);
}
@@ -231,8 +232,8 @@ public class CertificateChecker {
X509Certificate certificate = getCertificate(certificateStr);
DateTime now = clock.nowUtc();
// expiration date is one day after lastValidDate
Date lastValidDate = certificate.getNotAfter();
if (lastValidDate.before(now.toDate())) {
DateTime lastValidDate = new DateTime(certificate.getNotAfter());
if (lastValidDate.isBefore(now)) {
return false;
}
/*
@@ -242,12 +243,11 @@ public class CertificateChecker {
* 2) client has received notification but the interval between now and
* lastExpiringNotificationSentDate is greater than expirationWarningIntervalDays.
*/
return !lastValidDate.after(now.plusDays(expirationWarningDays).toDate())
return !lastValidDate.isAfter(now.plusDays(expirationWarningDays))
&& (lastExpiringNotificationSentDate.equals(START_OF_TIME)
|| !lastExpiringNotificationSentDate
.plusDays(expirationWarningIntervalDays)
.toDate()
.after(now.toDate()));
.isAfter(now));
}
private String getViolationDisplayMessage(CertificateViolation certificateViolation) {
@@ -104,9 +104,12 @@ public final class PgpHelper {
PGPPublicKey publicKey = lookupPublicKey(publics, query, want);
PGPPrivateKey privateKey;
try {
PGPSecretKey secret = verifyNotNull(privates.getSecretKey(publicKey.getKeyID()),
"Keyring missing private key associated with public key id: %x (query '%s')",
publicKey.getKeyID(), query);
PGPSecretKey secret =
verifyNotNull(
privates.getSecretKey(publicKey.getKeyID()),
"Keyring missing private key associated with public key id: %s (query %s)",
publicKey.getKeyID(),
query);
// We do not support putting a password on the private key so we're just going to
// put char[0] here.
privateKey = secret.extractPrivateKey(
@@ -57,6 +57,7 @@ public final class ResourceTransferUtils {
public static TransferResponse createTransferResponse(
EppResource eppResource, TransferData transferData) {
assertIsContactOrDomain(eppResource);
@SuppressWarnings("NonCanonicalType")
TransferResponse.Builder<? extends TransferResponse, ?> builder;
if (eppResource instanceof Contact) {
builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey());
@@ -120,7 +120,7 @@ public class DomainBase extends EppResource
* from (creationTime, deletionTime) there can only be one domain in the database with this name.
* However, there can be many domains with the same name and non-overlapping lifetimes.
*
* @invariant domainName == domainName.toLowerCase(Locale.ENGLISH)
* <p>Invariant: domainName == domainName.toLowerCase(Locale.ENGLISH)
*/
@Expose String domainName;
@@ -147,7 +147,7 @@ public class Result extends ImmutableObject {
this.msgLang = "en"; // All of our messages are English.
}
/** @return true iff the response code is in the 1xxx category, representing success. */
/** Returns true iff the response code is in the 1xxx category, representing success. */
public boolean isSuccess() {
return code < 2000;
}
@@ -122,6 +122,7 @@ public class HostBase extends EppResource {
@Deprecated
@Override
@SuppressWarnings("InlineMeSuggester")
public HostBase cloneProjectedAtTime(DateTime now) {
return this;
}
@@ -892,7 +892,11 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
return this;
}
/** @throws IllegalArgumentException if provided passcode is not 5-digit numeric */
/**
* Set the phone passcode.
*
* @throws IllegalArgumentException if provided passcode is not 5-digit numeric
*/
public Builder setPhonePasscode(String phonePasscode) {
checkArgument(
phonePasscode == null || PHONE_PASSCODE_PATTERN.matcher(phonePasscode).matches(),
@@ -14,8 +14,8 @@
package google.registry.pricing;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import google.registry.model.pricing.PremiumPricingEngine;
@@ -25,15 +25,14 @@ import google.registry.model.pricing.StaticPremiumListPricingEngine;
* Dagger module for injecting pricing engines.
*
* <p>To add a new pricing engine, create a new class that implements {@link PremiumPricingEngine},
* and add a module that provides an instance of {@link PremiumPricingEngine} with a unique
* {@link StringKey} annotation, and also <code>@Provides @IntoMap</code> annotations.
* and add a module that provides an instance of {@link PremiumPricingEngine} with a unique {@link
* StringKey} annotation, and also <code>@Provides @IntoMap</code> annotations.
*/
@Module
public class PricingModule {
public abstract class PricingModule {
@Provides @IntoMap
@Binds
@IntoMap
@StringKey(StaticPremiumListPricingEngine.NAME)
static PremiumPricingEngine provideStaticPremiumList(StaticPremiumListPricingEngine engine) {
return engine;
}
abstract PremiumPricingEngine provideStaticPremiumList(StaticPremiumListPricingEngine engine);
}
@@ -195,7 +195,9 @@ final class RdapObjectClasses {
* <p>Not part of the spec, but seems convenient.
*/
private abstract static class RdapObjectBase extends ReplyPayloadBase {
@JsonableElement final ObjectClassName objectClassName;
@SuppressWarnings("unused")
@JsonableElement
final ObjectClassName objectClassName;
@JsonableElement abstract Optional<String> handle();
@JsonableElement abstract ImmutableList<PublicId> publicIds();
@@ -44,10 +44,9 @@ import org.joda.time.DateTime;
/**
* Utility class for reading and writing data in the ghostryde container format.
*
* <p>Whenever we stage sensitive data to cloud storage (like XML RDE deposit data), we
* <a href="http://youtu.be/YPNJjL9iznY">GHOST RYDE IT</a> first to keep it safe from the prying
* eyes of anyone with access to the <a href="https://cloud.google.com/console">Google Cloud
* Console</a>.
* <p>Whenever we stage sensitive data to cloud storage (like XML RDE deposit data), we <a
* href="http://youtu.be/YPNJjL9iznY">GHOST RYDE IT</a> first to keep it safe from the prying eyes
* of anyone with access to the <a href="https://cloud.google.com/console">Google Cloud Console</a>.
*
* <p>The encryption is similar to the "regular" RyDE RDE deposit file encryption. The main
* difference (and the reason we had to create a custom encryption) is that the RDE deposit has a
@@ -63,35 +62,37 @@ import org.joda.time.DateTime;
*
* <p>Here's how you write a file:
*
* <pre> {@code
* <pre>{@code
* File in = new File("lol.txt");
* File out = new File("lol.txt.ghostryde");
* File lengthOut = new File("lol.length.ghostryde");
* try (OutputStream output = new FileOutputStream(out);
* OutputStream lengthOutput = new FileOutputStream(lengthOut);
* OutputStream ghostrydeEncoder = Ghostryde.encoder(output, publicKey, lengthOut);
* InputStream input = new FileInputStream(in)) &lbrace;
* ByteStreams.copy(input, ghostrydeEncoder);
* &rbrace;}</pre>
* InputStream input = new FileInputStream(in)) {
* ByteStreams.copy(input, ghostrydeEncoder);
* }
* }</pre>
*
* <p>Here's how you read a file:
*
* <pre> {@code
* <pre>{@code
* File in = new File("lol.txt.ghostryde");
* File out = new File("lol.txt");
* Ghostryde ghost = new Ghostryde(1024);
* try (InputStream fileInput = new FileInputStream(in);
* InputStream ghostrydeDecoder = new Ghostryde.decoder(fileInput, privateKey);
* OutputStream fileOutput = new FileOutputStream(out)) &lbrace;
* ByteStreams.copy(ghostryderDecoder, fileOutput);
* &rbrace;}</pre>
* OutputStream fileOutput = new FileOutputStream(out)) {
* ByteStreams.copy(ghostryderDecoder, fileOutput);
* }
* }</pre>
*
* <h2>Simple API</h2>
*
* <p>If you're writing test code or are certain your data can fit in memory, you might find these
* static methods more convenient:
*
* <pre> {@code
* <pre>{@code
* byte[] data = "hello kitty".getBytes(UTF_8);
* byte[] blob = Ghostryde.encode(data, publicKey);
* byte[] result = Ghostryde.decode(blob, privateKey);
@@ -86,8 +86,6 @@ final class JSchSshSession implements Closeable {
/**
* Opens a new SFTP channel over this SSH session.
*
* @throws JSchException
* @throws SftpException
* @see JSchSftpChannel
*/
public JSchSftpChannel openSftpChannel() throws JSchException, SftpException {
@@ -39,6 +39,7 @@ import google.registry.xml.XmlException;
import google.registry.xml.XmlFragmentMarshaller;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import javax.annotation.concurrent.NotThreadSafe;
import javax.xml.bind.JAXBElement;
@@ -84,14 +85,16 @@ public final class RdeMarshaller implements Serializable {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
XjcXmlTransformer.marshal(deposit, os, UTF_8, validationMode);
} catch (XmlException e) {
// TODO: Call StandardCharset.UTF_8 instead once we are one Java 17 runtime.
String rdeDocument = os.toString("UTF-8");
String marker = "<rde:contents>\n";
int startOfContents = rdeDocument.indexOf(marker);
verify(startOfContents > 0, "Bad RDE document:\n%s", rdeDocument);
return rdeDocument.substring(0, startOfContents + marker.length());
} catch (XmlException | UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
String rdeDocument = os.toString();
String marker = "<rde:contents>\n";
int startOfContents = rdeDocument.indexOf(marker);
verify(startOfContents > 0, "Bad RDE document:\n%s", rdeDocument);
return rdeDocument.substring(0, startOfContents + marker.length());
}
/** Returns bottom-portion of XML document. */
@@ -68,13 +68,13 @@ import org.joda.time.Duration;
* Action that kicks off a Dataflow job to stage escrow deposit XML files on GCS for RDE/BRDA for
* all TLDs.
*
* <h3>Pending Deposits</h3>
* <h2>Pending Deposits</h2>
*
* <p>This task starts by asking {@link PendingDepositChecker} which deposits need to be generated.
* If there's nothing to deposit, we return 204 No Content; otherwise, we fire off a job and
* redirect to its status GUI. The task can also be run in manual operation, as described below.
*
* <h3>Dataflow</h3>
* <h2>Dataflow</h2>
*
* The Dataflow job finds the most recent history entry on or before watermark for each resource
* type and loads the embedded resource from it, which is then projected to watermark time to
@@ -84,9 +84,9 @@ import org.joda.time.Duration;
* be included in the corresponding pending deposit.
*
* <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are
* not rewinded point-in-time.
* not rewound point-in-time.
*
* <h3>Afterward</h3>
* <h2>Afterward</h2>
*
* <p>The XML deposit files generated by this job are humongous. A tiny XML report file is generated
* for each deposit, telling us how much of what it contains.
@@ -98,7 +98,7 @@ import org.joda.time.Duration;
* <p>To generate escrow deposits manually and locally, use the {@code nomulus} tool command {@code
* GenerateEscrowDepositCommand}.
*
* <h3>Logging</h3>
* <h2>Logging</h2>
*
* <p>To identify the reduce worker request for a deposit in App Engine's log viewer, you can use
* search text like {@code tld=soy}, {@code watermark=2015-01-01}, and {@code mode=FULL}.
@@ -161,7 +161,7 @@ import org.joda.time.Duration;
*
* <h3>Determinism</h3>
*
* <p>The filename of an escrow deposit is determistic for a given (TLD, watermark, {@linkplain
* <p>The filename of an escrow deposit is deterministic for a given (TLD, watermark, {@linkplain
* RdeMode mode}) triplet. Its generated contents is deterministic in all the ways that we care
* about. Its view of the database is strongly consistent in Cloud SQL automatically by nature of
* the initial query for the history entry running at {@code READ_COMMITTED} transaction isolation
@@ -100,8 +100,7 @@ public final class RdeUtils {
}
/**
* Generates an ID matching the regex {@code \w&lbrace;1,13&rbrace; } from a millisecond
* timestamp.
* Generates an ID matching the regex {@code \w{1,13}} from a millisecond timestamp.
*
* <p>This routine works by turning the number of UTC milliseconds from the UNIX epoch into a
* big-endian byte-array which is then converted to a base32 string without padding that's no
@@ -145,7 +145,7 @@ public final class IcannReportingUploadAction implements Runnable {
+ " exist.",
cursorType, tldStr, filename, gcsFilename.getName(), gcsFilename.getBucket());
if (clock.nowUtc().dayOfMonth().get() == 1) {
logger.atInfo().log(logMessage + " This report may not have been staged yet.");
logger.atInfo().log("%s This report may not have been staged yet.", logMessage);
} else {
logger.atSevere().log(logMessage);
}
@@ -37,7 +37,11 @@ public class JsonResponse {
this.response = rsp;
}
/** @see Response#setStatus */
/**
* Sets the status.
*
* @see Response#setStatus
*/
public void setStatus(int status) {
response.setStatus(status);
}
@@ -54,12 +58,20 @@ public class JsonResponse {
response.setPayload(JSON_SAFETY_PREFIX + toJSONString(checkNotNull(responseMap)));
}
/** @see Response#setHeader */
/**
* Sets the header.
*
* @see Response#setHeader
*/
public void setHeader(String header, String value) {
response.setHeader(header, value);
}
/** @see Response#setDateHeader */
/**
* Sets the date header.
*
* <p>see Response#setDateHeader
*/
public void setDateHeader(String header, DateTime timestamp) {
response.setDateHeader(header, timestamp);
}
@@ -42,10 +42,11 @@ import org.joda.time.Duration;
* <p>This class creates an HTTP request processor from a Dagger component. It routes requests from
* your servlet to an {@link Action @Action} annotated handler class.
*
* <h3>Component Definition</h3>
* <h2>Component Definition</h2>
*
* <p>Action instances are supplied on a per-request basis by invoking the methods on {@code C}. For
* example:
*
* <p>Action instances are supplied on a per-request basis by invoking the methods on {@code C}.
* For example:
* <pre>
* {@literal @Component}
* interface ServerComponent {
@@ -53,12 +54,13 @@ import org.joda.time.Duration;
* }</pre>
*
* <p>The rules for component methods are as follows:
*
* <ol>
* <li>Methods whose raw return type does not implement {@code Runnable} will be ignored
* <li>Methods whose raw return type does not have an {@code @Action} annotation are ignored
* <li>Methods whose raw return type does not implement {@code Runnable} will be ignored
* <li>Methods whose raw return type does not have an {@code @Action} annotation are ignored
* </ol>
*
* <h3>Security Features</h3>
* <h2>Security Features</h2>
*
* @param <C> request component type
*/
@@ -46,6 +46,8 @@ class CommandUtilities {
}
}
// TODO: change Strings.repeat("-", n) to "-".repeat(n) once we are on Java 17 runtime.
@SuppressWarnings("InlineMeInliner")
static String addHeader(String header, String body) {
return String.format("%s:\n%s\n%s", header, Strings.repeat("-", header.length() + 1), body);
}
@@ -16,7 +16,6 @@ package google.registry.tools;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.collect.Streams;
import google.registry.model.tld.label.ReservedList.ReservedListEntry;
import google.registry.model.tld.label.ReservedListDao;
import java.util.Comparator;
@@ -37,11 +36,11 @@ public class GetReservedListCommand implements Command {
if (ReservedListDao.getLatestRevision(reservedListName).isPresent()) {
System.out.printf(
"%s\n",
Streams.stream(
ReservedListDao.getLatestRevision(reservedListName)
.get()
.getReservedListEntries()
.values())
ReservedListDao.getLatestRevision(reservedListName)
.get()
.getReservedListEntries()
.values()
.stream()
.sorted(Comparator.comparing(ReservedListEntry::getDomainLabel))
.map(ReservedListEntry::toString)
.collect(Collectors.joining("\n")));
@@ -40,10 +40,12 @@ final class GetTldCommand implements Command {
@Override
public void run() throws JsonProcessingException, UnsupportedEncodingException {
try (PrintStream printStream = new PrintStream(System.out, false, UTF_8.name())) {
for (String tld : assertTldsExist(mainParameters)) {
// Don't use try-with-resources to manage standard output streams, closing the stream will
// cause subsequent output to standard output or standard error to be lost
// See: https://errorprone.info/bugpattern/ClosingStandardOutputStreams
PrintStream printStream = new PrintStream(System.out, false, UTF_8.name());
for (String tld : assertTldsExist(mainParameters)) {
printStream.println(objectMapper.writeValueAsString(Tld.get(tld)));
}
}
}
}
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.util.RegistryEnvironment;
import google.registry.util.SystemPropertySetter;
import java.util.Map;
/** Enum of production environments, used for the {@code --environment} flag. */
public enum RegistryToolEnvironment {
@@ -93,7 +94,7 @@ public enum RegistryToolEnvironment {
void setup(SystemPropertySetter systemPropertySetter) {
instance = this;
actualEnvironment.setup(systemPropertySetter);
for (ImmutableMap.Entry<String, String> entry : extraProperties.entrySet()) {
for (Map.Entry<String, String> entry : extraProperties.entrySet()) {
systemPropertySetter.setProperty(entry.getKey(), entry.getValue());
}
}
@@ -200,10 +200,9 @@ public class ShellCommand implements Command {
private void encapsulatedRun(String[] args) throws Exception {
PrintStream orgOut = System.out;
PrintStream orgErr = System.err;
try (PrintStream newOut =
new PrintStream(new EncapsulatingOutputStream(System.out, "out: "));
PrintStream newErr =
new PrintStream(new EncapsulatingOutputStream(System.out, "err: "))) {
PrintStream newOut = new PrintStream(new EncapsulatingOutputStream(System.out, "out: "));
PrintStream newErr = new PrintStream(new EncapsulatingOutputStream(System.out, "err: "));
try {
System.setOut(newOut);
System.setErr(newErr);
runner.run(args);
@@ -16,10 +16,11 @@ package google.registry.tools.params;
import google.registry.util.TypeUtils.TypeInstantiator;
/** Base class for Enum-based parameters.
/**
* Base class for Enum-based parameters.
*
* <p>This is not necessary for single-value Enum parameters (i.e. arity = 1) as JCommander natively
* supports them, but is necessary for variable-arity ({@code List&lt;Enum&gt;}) parameters.
* supports them, but is necessary for variable-arity ({@code List<Enum>}) parameters.
*/
public abstract class EnumParameter<T extends Enum<T>> extends ParameterConverterValidator<T> {
@@ -75,7 +75,7 @@ import javax.annotation.concurrent.Immutable;
* <p>This class provides <b>full type-safety</b> <i>if and only if</i> you statically initialize
* your FormField objects and write a unit test that causes the class to be loaded.
*
* <h3>Exception Handling</h3>
* <h2>Exception Handling</h2>
*
* <p>When values passed to {@link #convert} or {@link #extract} don't meet the contract, {@link
* FormFieldException} will be thrown, which provides the field name and a short error message
@@ -35,7 +35,7 @@ import google.registry.ui.server.SoyTemplateUtils;
import google.registry.ui.soy.registrar.OteSetupConsoleSoyInfo;
import google.registry.util.RegistryEnvironment;
import google.registry.util.StringGenerator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Named;
@@ -90,7 +90,7 @@ public final class ConsoleOteSetupAction extends HtmlAction {
ConsoleOteSetupAction() {}
@Override
public void runAfterLogin(HashMap<String, Object> data) {
public void runAfterLogin(Map<String, Object> data) {
checkState(
!RegistryEnvironment.get().equals(PRODUCTION), "Can't create OT&E in prod");
@@ -122,7 +122,7 @@ public final class ConsoleOteSetupAction extends HtmlAction {
return PATH;
}
private void runPost(HashMap<String, Object> data) {
private void runPost(Map<String, Object> data) {
try {
checkState(clientId.isPresent() && email.isPresent(), "Must supply clientId and email");
@@ -162,7 +162,7 @@ public final class ConsoleOteSetupAction extends HtmlAction {
}
}
private void runGet(HashMap<String, Object> data) {
private void runGet(Map<String, Object> data) {
// set the values to pre-fill, if given
data.put("baseClientId", clientId.orElse(null));
data.put("contactEmail", email.orElse(null));
@@ -45,7 +45,7 @@ import google.registry.ui.soy.registrar.FormsSoyInfo;
import google.registry.ui.soy.registrar.RegistrarCreateConsoleSoyInfo;
import google.registry.util.RegistryEnvironment;
import google.registry.util.StringGenerator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -108,7 +108,7 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction {
@Inject ConsoleRegistrarCreatorAction() {}
@Override
public void runAfterLogin(HashMap<String, Object> data) {
public void runAfterLogin(Map<String, Object> data) {
if (!registrarAccessor.isAdmin()) {
response.setStatus(SC_FORBIDDEN);
response.setPayload(
@@ -165,7 +165,7 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction {
}
}
private void runPost(HashMap<String, Object> data) {
private void runPost(Map<String, Object> data) {
try {
checkPresent(clientId, "clientId");
checkPresent(name, "name");
@@ -263,7 +263,7 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction {
}
}
private void runGet(HashMap<String, Object> data) {
private void runGet(Map<String, Object> data) {
// set the values to pre-fill, if given
data.put("clientId", clientId.orElse(null));
data.put("name", name.orElse(null));
@@ -36,7 +36,7 @@ import google.registry.request.auth.AuthenticatedRegistrarAccessor.Role;
import google.registry.ui.server.SoyTemplateUtils;
import google.registry.ui.soy.registrar.ConsoleSoyInfo;
import google.registry.util.RegistryEnvironment;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.inject.Inject;
@@ -92,7 +92,7 @@ public final class ConsoleUiAction extends HtmlAction {
ConsoleUiAction() {}
@Override
public void runAfterLogin(HashMap<String, Object> data) {
public void runAfterLogin(Map<String, Object> data) {
SoyMapData soyMapData = new SoyMapData();
data.forEach((key, value) -> soyMapData.put(key, value));
@@ -102,7 +102,7 @@ public abstract class HtmlAction implements Runnable {
runAfterLogin(data);
}
public abstract void runAfterLogin(HashMap<String, Object> data);
public abstract void runAfterLogin(Map<String, Object> data);
public abstract String getPath();
}
@@ -27,7 +27,7 @@ import google.registry.request.auth.Auth;
import google.registry.tools.DomainLockUtils;
import google.registry.ui.server.SoyTemplateUtils;
import google.registry.ui.soy.registrar.RegistryLockVerificationSoyInfo;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
/** Action that allows for verification of registry lock / unlock requests */
@@ -63,7 +63,7 @@ public final class RegistryLockVerifyAction extends HtmlAction {
}
@Override
public void runAfterLogin(HashMap<String, Object> data) {
public void runAfterLogin(Map<String, Object> data) {
try {
boolean isAdmin = authResult.userAuthInfo().get().isUserAdmin();
final RegistryLock resultLock;
@@ -21,7 +21,7 @@ import google.registry.config.RegistryConfig.Config;
/**
* Whois module for systems that require that we not cache EPP resources (e.g. the nomulus tool).
*
* <h3>Dependencies</h3>
* <h2>Dependencies</h2>
*
* <ul>
* <li>{@link google.registry.request.RequestModule RequestModule}
@@ -24,7 +24,7 @@ import google.registry.config.RegistryConfig.Config;
/**
* Dagger module for the whois package.
*
* <h3>Dependencies</h3>
* <h2>Dependencies</h2>
*
* <ul>
* <li>{@link google.registry.request.RequestModule RequestModule}
@@ -25,9 +25,9 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
* values can commonly be formatted like so:
*
* <pre>{@code
* &lt;ns:tag&gt;
* XML value here.
* &lt;/ns:tag&gt;
* <ns:tag>
* XML value here.
* </ns:tag>
* }</pre>
*/
public class TrimWhitespaceAdapter extends XmlAdapter<String, String> {
@@ -582,10 +582,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
String registrarId = "registrarid";
String emailBody =
action.getEmailBody(
registrarName,
certificateType,
DateTime.parse(certExpirationDateStr).toDate(),
registrarId);
registrarName, certificateType, DateTime.parse(certExpirationDateStr), registrarId);
assertThat(emailBody).contains(registrarName);
assertThat(emailBody).contains(certificateType.getDisplayName());
assertThat(emailBody).contains(certExpirationDateStr);
@@ -614,7 +611,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
IllegalArgumentException.class,
() ->
action.getEmailBody(
"good registrar", null, DateTime.parse("2021-06-15").toDate(), "registrarId"));
"good registrar", null, DateTime.parse("2021-06-15"), "registrarId"));
assertThat(thrown).hasMessageThat().contains("Certificate type cannot be null");
}
@@ -627,7 +624,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
action.getEmailBody(
"good registrar",
CertificateType.FAILOVER,
DateTime.parse("2021-06-15").toDate(),
DateTime.parse("2021-06-15"),
null));
assertThat(thrown).hasMessageThat().contains("Registrar Id cannot be null");
}
@@ -48,8 +48,14 @@ class BsaDiffCreatorTest {
@Mock GcsClient gcsClient;
@Mock DownloadSchedule schedule;
@Mock CompletedJob completedJob;
@SuppressWarnings("DoNotMockAutoValue")
@Mock
DownloadSchedule schedule;
@SuppressWarnings("DoNotMockAutoValue")
@Mock
CompletedJob completedJob;
@Mock IdnChecker idnChecker;
BsaDiffCreator diffCreator;
@@ -88,10 +88,8 @@ public class BsaLabelUtilsTest {
when(replicaTm.loadByKey(any())).thenReturn(new BsaLabel("abc", fakeClock.nowUtc()));
try {
assertThat(isLabelBlocked("abc")).isTrue();
/**
* If test fails, check and fix cache expiry in the config file. Do not increase the duration
* on the line below without proper discussion.
*/
// If test fails, check and fix cache expiry in the config file. Do not increase the duration
// on the line below without proper discussion.
fakeClock.advanceBy(standardMinutes(1).plus(millis(1)));
assertThat(isLabelBlocked("abc")).isTrue();
verify(replicaTm, times(2)).loadByKey(any());
@@ -62,7 +62,10 @@ class LabelDiffUpdatesTest {
new JpaTestExtensions.Builder().withClock(fakeClock).buildIntegrationWithCoverageExtension();
@Mock IdnChecker idnChecker;
@Mock DownloadSchedule schedule;
@SuppressWarnings("DoNotMockAutoValue")
@Mock
DownloadSchedule schedule;
Tld app;
Tld dev;
@@ -59,6 +59,7 @@ class DnsMessageTransportTest {
private DnsMessageTransport resolver;
@BeforeEach
@SuppressWarnings("AddressSelection")
void beforeEach() throws Exception {
simpleQuery =
Message.newQuery(Record.newRecord(Name.fromString("example.com."), Type.A, DClass.IN));
@@ -403,7 +403,7 @@ class CertificateCheckerTest {
// Invalid curve
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
AlgorithmParameters apParam = AlgorithmParameters.getInstance("EC");
apParam.init(new ECGenParameterSpec("secp128r1"));
apParam.init(new ECGenParameterSpec("secp521r1"));
ECParameterSpec spec = apParam.getParameterSpec(ECParameterSpec.class);
keyGen.initialize(spec, new SecureRandom());
X509Certificate certificate =
@@ -190,6 +190,8 @@ import google.registry.tmch.SmdrlCsvParser;
import google.registry.tmch.TmchData;
import google.registry.tmch.TmchTestData;
import google.registry.xml.ValidationMode;
import java.io.BufferedReader;
import java.io.StringReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@@ -2762,7 +2764,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFail_startDateSunriseRegistration_revokedSignedMark() throws Exception {
SmdrlCsvParser.parse(TmchTestData.loadFile("smd/smdrl.csv").lines().collect(toImmutableList()))
SmdrlCsvParser.parse(
// TODO: Use String.lines() once we are on Java 17.
new BufferedReader(new StringReader(TmchTestData.loadFile("smd/smdrl.csv")))
.lines()
.collect(toImmutableList()))
.save();
createTld("tld", START_DATE_SUNRISE);
clock.setTo(SMD_VALID_TIME);
@@ -2788,8 +2794,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
if (labels.isEmpty()) {
return;
}
// TODO: Use String.lines() once we are on Java 17.
SmdrlCsvParser.parse(
TmchTestData.loadFile("idn/idn_smdrl.csv").lines().collect(toImmutableList()))
new BufferedReader(new StringReader(TmchTestData.loadFile("idn/idn_smdrl.csv")))
.lines()
.collect(toImmutableList()))
.save();
createTld("tld", START_DATE_SUNRISE);
clock.setTo(SMD_VALID_TIME);
@@ -35,7 +35,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import google.registry.flows.EppException;
import google.registry.flows.FlowMetadata;
import google.registry.flows.HttpSessionMetadata;
import google.registry.flows.SessionMetadata;
import google.registry.flows.custom.DomainPricingCustomLogic;
@@ -57,7 +56,6 @@ import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession;
import google.registry.util.Clock;
import java.util.Optional;
import javax.inject.Inject;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -73,10 +71,9 @@ public class DomainPricingLogicTest {
final JpaIntegrationTestExtension jpa =
new JpaTestExtensions.Builder().buildIntegrationTestExtension();
@Inject Clock clock = new FakeClock(DateTime.parse("2023-05-13T00:00:00.000Z"));
Clock clock = new FakeClock(DateTime.parse("2023-05-13T00:00:00.000Z"));
@Mock EppInput eppInput;
SessionMetadata sessionMetadata;
@Mock FlowMetadata flowMetadata;
Tld tld;
Domain domain;
@@ -85,8 +82,7 @@ public class DomainPricingLogicTest {
createTld("example");
sessionMetadata = new HttpSessionMetadata(new FakeHttpSession());
domainPricingLogic =
new DomainPricingLogic(
new DomainPricingCustomLogic(eppInput, sessionMetadata, flowMetadata));
new DomainPricingLogic(new DomainPricingCustomLogic(eppInput, sessionMetadata, null));
tld =
persistResource(
Tld.get("example")
@@ -109,6 +109,7 @@ public class DatabaseExceptionTest {
}
@Test
@SuppressWarnings("ReturnValueIgnored")
void getMessage_cachedMessageReused() {
SQLException sqlException = mock(SQLException.class);
DatabaseException databaseException = new DatabaseException(sqlException);
@@ -14,7 +14,6 @@
package google.registry.persistence.transaction;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -25,12 +24,12 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExte
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -39,6 +38,8 @@ import org.junit.jupiter.api.extension.RegisterExtension;
*
* <p>Please refer to the class javadoc of {@link DatabaseException} for more information.
*/
@Disabled // TODO: re-enable test class after upgrading to Java 17.
// LogManager.updateConfiguration() is only supported in Java 9 and later.
public class HibernateLoggingSuppressionTest {
private static final String LOG_SUPPRESSION_TARGET =
@@ -73,6 +74,7 @@ public class HibernateLoggingSuppressionTest {
void suppressHibernateLogs() throws IOException {
try (ByteArrayInputStream additionalProperties =
new ByteArrayInputStream(LOGGING_PROPERTIES_LINE.getBytes(UTF_8))) {
/*
LogManager.getLogManager()
.updateConfiguration(
additionalProperties,
@@ -84,12 +86,14 @@ public class HibernateLoggingSuppressionTest {
checkArgument(o == null, "Cannot override old value in this test");
return n;
});
*/
}
}
void revertSuppressionOfHibernateLogs() throws IOException {
try (ByteArrayInputStream additionalProperties =
new ByteArrayInputStream(LOGGING_PROPERTIES_LINE.getBytes(UTF_8))) {
/*
LogManager.getLogManager()
.updateConfiguration(
additionalProperties,
@@ -100,6 +104,7 @@ public class HibernateLoggingSuppressionTest {
}
return null;
});
*/
}
}
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.DatabaseHelper.insertSimpleResources;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testcontainers.containers.PostgreSQLContainer.POSTGRESQL_PORT;
import com.google.common.base.Charsets;
@@ -172,7 +173,8 @@ public abstract class JpaTransactionManagerExtension
File tempSqlFile = File.createTempFile("tempSqlFile", ".sql");
tempSqlFile.deleteOnExit();
exporter.export(extraEntityClasses, tempSqlFile);
executeSql(Files.readString(tempSqlFile.toPath()));
// TODO: Use Files.readString() once we upgrade to Java 17 runtime.
executeSql(new String(Files.readAllBytes(tempSqlFile.toPath()), UTF_8));
}
assertReasonableNumDbConnections();
emf = createEntityManagerFactory(getJpaProperties());
@@ -66,6 +66,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link RdeReportAction}. */
@SuppressWarnings("DirectInvocationOnMock") // FakeUrlConnectionService mocks the getURL() method.
public class RdeReportActionTest {
private static final ByteSource REPORT_XML = RdeTestData.loadBytes("report.xml");
@@ -26,6 +26,7 @@ class ActivityReportingQueryBuilderTest {
private final YearMonth yearMonth = new YearMonth(2017, 9);
@SuppressWarnings("NonCanonicalType")
private ActivityReportingQueryBuilder createQueryBuilder(String datasetName) {
return new ActivityReportingQueryBuilder(
"domain-registry-alpha",
@@ -24,6 +24,7 @@ import com.google.common.net.MediaType;
import google.registry.request.Response;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import org.joda.time.DateTime;
@@ -92,7 +93,7 @@ public final class FakeResponse implements Response {
cookies.add(cookie);
}
public ArrayList<Cookie> getCookies() {
public List<Cookie> getCookies() {
return cookies;
}
@@ -38,7 +38,6 @@ public final class FakeServletInputStream extends ServletInputStream {
/**
* Use a {@link ByteSource} as input for the servlet. Be sure to call {@link #close} after
* your servlet runs so the resource opened via {@code bytes} gets closed.
* @throws IOException
*/
public FakeServletInputStream(ByteSource bytes) throws IOException {
this.input = bytes.openStream();
@@ -237,6 +237,7 @@ class NordnUploadActionTest {
assertThat(domain.getLordnPhase()).isEqualTo(LordnPhase.NONE);
}
@SuppressWarnings("DirectInvocationOnMock")
private void testRun(String phase, String domain1, String domain2, String csv) throws Exception {
action.phase = phase;
action.run();
@@ -248,7 +249,8 @@ class NordnUploadActionTest {
verify(httpUrlConnection).setRequestMethod("POST");
assertThat(httpUrlConnection.getURL())
.isEqualTo(new URL("http://127.0.0.1/LORDN/tld/" + phase));
assertThat(connectionOutputStream.toString(UTF_8)).contains(csv);
// TODO: use toString(StandardCharsets.UTF_8) once we upgrade to Java 17.
assertThat(connectionOutputStream.toString("UTF-8")).contains(csv);
verifyColumnCleared(domain1);
verifyColumnCleared(domain2);
cloudTasksHelper.assertTasksEnqueued(
@@ -101,6 +101,7 @@ class NordnVerifyActionTest {
}
@Test
@SuppressWarnings("DirectInvocationOnMock")
void testSuccess_sendHttpRequest_urlIsCorrect() throws Exception {
action.run();
assertThat(httpUrlConnection.getURL()).isEqualTo(new URL("http://127.0.0.1/blobio"));
@@ -282,7 +282,7 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter");
Tld registry = Tld.get("co.uk");
assertThat(registry.getTldState(new DateTime())).isEqualTo(PREDELEGATION);
assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(PREDELEGATION);
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Tld.DEFAULT_ADD_GRACE_PERIOD);
assertThat(registry.getRedemptionGracePeriodLength())
.isEqualTo(Tld.DEFAULT_REDEMPTION_GRACE_PERIOD);
@@ -73,7 +73,8 @@ final class GcpProjectConnectionTest {
ByteArrayOutputStream output = new ByteArrayOutputStream();
getStreamingContent().writeTo(output);
output.close();
return output.toString(UTF_8);
// TODO: use toString(StandardCharsets.UTF_8) once we upgrade to Java 17.
return output.toString("UTF-8");
}
}
@@ -241,22 +241,22 @@ class ShellCommandTest {
}
@Test
void testEncapsulatedOutputStream_basicFuncionality() {
void testEncapsulatedOutputStream_basicFuncionality() throws Exception {
ByteArrayOutputStream backing = new ByteArrayOutputStream();
try (PrintStream out =
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {
out.println("first line");
out.print("second line\ntrailing data");
}
assertThat(backing.toString())
assertThat(backing.toString("UTF-8"))
.isEqualTo("out: first line\nout: second line\nout: trailing data\n");
}
@Test
void testEncapsulatedOutputStream_emptyStream() {
void testEncapsulatedOutputStream_emptyStream() throws Exception {
ByteArrayOutputStream backing = new ByteArrayOutputStream();
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: ")).close();
assertThat(backing.toString()).isEqualTo("");
assertThat(backing.toString("UTF-8")).isEqualTo("");
}
@Test
@@ -275,8 +275,8 @@ class ShellCommandTest {
shellCommand.encapsulateOutput = true;
shellCommand.run();
assertThat(stderr.toString()).isEmpty();
assertThat(stdout.toString())
assertThat(stderr.toString("UTF-8")).isEmpty();
assertThat(stdout.toString("UTF-8"))
.isEqualTo(
"RUNNING \"command1\"\n"
+ "out: first line\nerr: second line\nerr: surprise!\nout: fragmented line\n"
@@ -295,8 +295,8 @@ class ShellCommandTest {
});
shellCommand.encapsulateOutput = true;
shellCommand.run();
assertThat(stderr.toString()).isEmpty();
assertThat(stdout.toString())
assertThat(stderr.toString("UTF-8")).isEmpty();
assertThat(stdout.toString("UTF-8"))
.isEqualTo(
"RUNNING \"command1\"\n"
+ "out: first line\n"
@@ -316,8 +316,8 @@ class ShellCommandTest {
"do something");
shellCommand.encapsulateOutput = true;
shellCommand.run();
assertThat(stderr.toString()).isEmpty();
assertThat(stdout.toString())
assertThat(stderr.toString("UTF-8")).isEmpty();
assertThat(stdout.toString("UTF-8"))
.isEqualTo("RUNNING \"do\" \"something\"\nout: first line\nSUCCESS\n");
}
@@ -77,6 +77,7 @@ class GenerateZoneFilesActionTest {
testGenerate("tldCustomTtl.zone");
}
@SuppressWarnings("AddressSelection")
void testGenerate(String goldenFileName) throws Exception {
DateTime now = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay();
@@ -63,7 +63,7 @@ class ListDomainsActionTest extends ListActionTestCase {
@Test
void testRun_noParameters() {
action.tlds = ImmutableSet.of("foo");
testRunSuccess(action, null, null, null);
testRunSuccess(action, Optional.empty(), Optional.empty(), Optional.empty());
}
@Test
@@ -37,11 +37,7 @@ class ListHostsActionTest extends ListActionTestCase {
@Test
void testRun_noParameters() {
testRunSuccess(
action,
null,
null,
null);
testRunSuccess(action, Optional.empty(), Optional.empty(), Optional.empty());
}
@Test
@@ -32,7 +32,7 @@ import google.registry.testing.FakeConsoleApiParams;
import google.registry.testing.FakeResponse;
import google.registry.ui.server.registrar.ConsoleApiParams;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.servlet.http.Cookie;
@@ -63,7 +63,7 @@ class ConsoleUserDataActionTest {
createAction(
Optional.of(FakeConsoleApiParams.get(Optional.of(authResult))), Action.Method.GET);
action.run();
ArrayList<Cookie> cookies = ((FakeResponse) consoleApiParams.response()).getCookies();
List<Cookie> cookies = ((FakeResponse) consoleApiParams.response()).getCookies();
assertThat(cookies.stream().map(cookie -> cookie.getName()).collect(toImmutableList()))
.containsExactly("X-CSRF-Token");
}