mirror of
https://github.com/google/nomulus
synced 2026-08-18 13:16:20 +00:00
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:
@@ -292,18 +292,17 @@ public class CidrAddressBlock implements Iterable<InetAddress>, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the standard {@code String} representation of the IP portion
|
||||
* of this CIDR block (a.b.c.d, or a:b:c::d)
|
||||
* Returns the standard {@code String} representation of the IP portion of this CIDR block
|
||||
* (a.b.c.d, or a:b:c::d)
|
||||
*
|
||||
* <p>NOTE: This is not reliable for comparison operations. It is
|
||||
* more reliable to normalize strings into {@link InetAddress}s and
|
||||
* then compare.
|
||||
* <p>NOTE: This is not reliable for comparison operations. It is more reliable to normalize
|
||||
* strings into {@link InetAddress}s and then compare.
|
||||
*
|
||||
* <p>Consider:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code "10.11.12.0"} is equivalent to {@code "10.11.12.000"}
|
||||
* <li>{@code "2001:db8::"} is equivalent to
|
||||
* {@code "2001:0DB8:0000:0000:0000:0000:0000:0000"}
|
||||
* <li>{@code "10.11.12.0"} is equivalent to {@code "10.11.12.000"}
|
||||
* <li>{@code "2001:db8::"} is equivalent to {@code "2001:0DB8:0000:0000:0000:0000:0000:0000"}
|
||||
* </ul>
|
||||
*/
|
||||
public String getIp() {
|
||||
|
||||
@@ -172,6 +172,7 @@ public final class PosixTarHeader {
|
||||
}
|
||||
|
||||
/** Returns the modified time as a UTC {@link DateTime} object. */
|
||||
@SuppressWarnings("JodaDateTimeConstants")
|
||||
public DateTime getMtime() {
|
||||
return new DateTime(Long.parseLong(extractField(136, 12).trim(), 8) * MILLIS_PER_SECOND, UTC);
|
||||
}
|
||||
@@ -332,7 +333,7 @@ public final class PosixTarHeader {
|
||||
setMode(DEFAULT_MODE);
|
||||
setUid(DEFAULT_UID);
|
||||
setGid(DEFAULT_GID);
|
||||
setMtime(new DateTime(UTC));
|
||||
setMtime(DateTime.now(UTC));
|
||||
setType(DEFAULT_TYPE);
|
||||
setMagic();
|
||||
setVersion();
|
||||
@@ -417,6 +418,7 @@ public final class PosixTarHeader {
|
||||
* epoch in UTC time. Because {@link DateTime} has millisecond precision, it gets rounded down
|
||||
* (floor) to the second.
|
||||
*/
|
||||
@SuppressWarnings("JodaDateTimeConstants")
|
||||
public Builder setMtime(DateTime mtime) {
|
||||
checkNotNull(mtime, "mtime");
|
||||
setField("mtime", 136, 12, String.format("%011o", mtime.getMillis() / MILLIS_PER_SECOND));
|
||||
|
||||
@@ -159,7 +159,7 @@ public class Retrier implements Serializable {
|
||||
failureReporter.beforeRetry(e, failures, attempts);
|
||||
try {
|
||||
// Wait 100ms on the first attempt, doubling on each subsequent attempt.
|
||||
sleeper.sleep(Duration.millis(pow(2, failures) * 100));
|
||||
sleeper.sleep(Duration.millis(pow(2, failures) * 100L));
|
||||
} catch (InterruptedException e2) {
|
||||
// Since we're not rethrowing InterruptedException, set the interrupt state on the thread
|
||||
// so the next blocking operation will know to abort the thread.
|
||||
|
||||
@@ -66,14 +66,13 @@ public class SendEmailService {
|
||||
if (!ALLOWED_ENVS.contains(
|
||||
Ascii.toUpperCase(System.getProperty("google.registry.environment", "UNITTEST")))) {
|
||||
logger.atInfo().log(
|
||||
String.format(
|
||||
"Email with subject %s would have been sent to recipients %s",
|
||||
emailMessage.subject().substring(0, Math.min(emailMessage.subject().length(), 15)),
|
||||
String.join(
|
||||
" , ",
|
||||
emailMessage.recipients().stream()
|
||||
.map(ia -> ia.toString())
|
||||
.collect(toImmutableSet()))));
|
||||
"Email with subject %s would have been sent to recipients %s",
|
||||
emailMessage.subject().substring(0, Math.min(emailMessage.subject().length(), 15)),
|
||||
String.join(
|
||||
" , ",
|
||||
emailMessage.recipients().stream()
|
||||
.map(ia -> ia.toString())
|
||||
.collect(toImmutableSet())));
|
||||
} else {
|
||||
retrier.callWithRetry(
|
||||
() -> {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Tainted;
|
||||
import org.joda.time.DateTimeComparator;
|
||||
|
||||
/** X.509 Public Key Infrastructure (PKI) helper functions. */
|
||||
public final class X509Utils {
|
||||
@@ -169,12 +170,15 @@ public final class X509Utils {
|
||||
public static void verifyCrl(
|
||||
X509Certificate rootCert, @Nullable X509CRL oldCrl, @Tainted X509CRL newCrl, Date now)
|
||||
throws GeneralSecurityException {
|
||||
if (oldCrl != null && newCrl.getThisUpdate().before(oldCrl.getThisUpdate())) {
|
||||
throw new CRLException(String.format(
|
||||
"New CRL is more out of date than our current CRL. %s < %s\n%s",
|
||||
newCrl.getThisUpdate(), oldCrl.getThisUpdate(), newCrl));
|
||||
if (oldCrl != null
|
||||
&& DateTimeComparator.getInstance().compare(newCrl.getThisUpdate(), oldCrl.getThisUpdate())
|
||||
< 0) {
|
||||
throw new CRLException(
|
||||
String.format(
|
||||
"New CRL is more out of date than our current CRL. %s < %s\n%s",
|
||||
newCrl.getThisUpdate(), oldCrl.getThisUpdate(), newCrl));
|
||||
}
|
||||
if (newCrl.getNextUpdate().before(now)) {
|
||||
if (DateTimeComparator.getInstance().compare(newCrl.getNextUpdate(), now) < 0) {
|
||||
throw new CRLException("CRL has expired.\n" + newCrl);
|
||||
}
|
||||
newCrl.verify(rootCert.getPublicKey());
|
||||
|
||||
@@ -86,7 +86,8 @@ public final class YamlUtils {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Map<String, Object> mergeMaps(
|
||||
Map<String, Object> defaultMap, Map<String, Object> customMap) {
|
||||
for (String key : defaultMap.keySet()) {
|
||||
for (Map.Entry<String, Object> e : defaultMap.entrySet()) {
|
||||
String key = e.getKey();
|
||||
if (!customMap.containsKey(key)) {
|
||||
continue;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ public final class YamlUtils {
|
||||
} else {
|
||||
newValue = customMap.get(key);
|
||||
}
|
||||
defaultMap.put(key, newValue);
|
||||
e.setValue(newValue);
|
||||
}
|
||||
return defaultMap;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ final class PasswordUtilsTest {
|
||||
byte[] salt = SALT_SUPPLIER.get();
|
||||
String password = "mySuperSecurePassword";
|
||||
String hashedPassword = hashPassword(password, salt);
|
||||
assertThat(verifyPassword(password + "a", hashedPassword, base64().encode(salt)).isEmpty())
|
||||
.isTrue();
|
||||
assertThat(verifyPassword(password + "a", hashedPassword, base64().encode(salt)).isPresent())
|
||||
.isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,10 @@ class TeeOutputStreamTest {
|
||||
outputB.write("b".getBytes(UTF_8));
|
||||
outputC.write("c".getBytes(UTF_8));
|
||||
// Check the results.
|
||||
assertThat(outputA.toString()).isEqualTo("hello world!a");
|
||||
assertThat(outputB.toString()).isEqualTo("hello world!b");
|
||||
assertThat(outputC.toString()).isEqualTo("hello world!c");
|
||||
// TODO: Use toString(StandardCharsets.UTF_8) once we can use Java 17.
|
||||
assertThat(outputA.toString("UTF-8")).isEqualTo("hello world!a");
|
||||
assertThat(outputB.toString("UTF-8")).isEqualTo("hello world!b");
|
||||
assertThat(outputC.toString("UTF-8")).isEqualTo("hello world!c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user