mirror of
https://github.com/google/nomulus
synced 2026-08-20 22:26:12 +00:00
Bring codebase up to more recent Java standards (#2422)
This includes using the new switch format (though IntelliJ does not yet understand patterns including default so those aren't used), multiline strings, replacing some unnecessary type declarations with <>, converting some classes to records, replacing some Guava predicates with native Java code, and some other miscellaneous Code Inspection fixes.
This commit is contained in:
+10
-8
@@ -158,14 +158,16 @@ public class SslServerInitializer<C extends Channel> extends ChannelInitializer<
|
||||
((RSAPublicKey) clientPublicKey).getModulus().bitLength();
|
||||
}
|
||||
logger.atInfo().log(
|
||||
"--SSL Information--\n"
|
||||
+ "Client Certificate Hash: %s\n"
|
||||
+ "SSL Protocol: %s\n"
|
||||
+ "Cipher Suite: %s\n"
|
||||
+ "Not Before: %s\n"
|
||||
+ "Not After: %s\n"
|
||||
+ "Client Certificate Type: %s\n"
|
||||
+ "Client Certificate Length: %s\n",
|
||||
"""
|
||||
--SSL Information--
|
||||
Client Certificate Hash: %s
|
||||
SSL Protocol: %s
|
||||
Cipher Suite: %s
|
||||
Not Before: %s
|
||||
Not After: %s
|
||||
Client Certificate Type: %s
|
||||
Client Certificate Length: %s
|
||||
""",
|
||||
getCertificateHash(clientCertificate),
|
||||
sslSession.getProtocol(),
|
||||
sslSession.getCipherSuite(),
|
||||
|
||||
+12
-20
@@ -131,16 +131,12 @@ public final class CertificateSupplierModule {
|
||||
@PemFile Lazy<Supplier<PrivateKey>> pemPrivateKeySupplier,
|
||||
@P12File Lazy<Supplier<PrivateKey>> p12PrivateKeySupplier,
|
||||
@SelfSigned Lazy<Supplier<PrivateKey>> selfSignedPrivateKeySupplier) {
|
||||
switch (mode) {
|
||||
case PEM_FILE:
|
||||
return pemPrivateKeySupplier.get();
|
||||
case P12_FILE:
|
||||
return p12PrivateKeySupplier.get();
|
||||
case SELF_SIGNED:
|
||||
return selfSignedPrivateKeySupplier.get();
|
||||
default:
|
||||
throw new RuntimeException("Certificate provider mode exhausted.");
|
||||
}
|
||||
return switch (mode) {
|
||||
case PEM_FILE -> pemPrivateKeySupplier.get();
|
||||
case P12_FILE -> p12PrivateKeySupplier.get();
|
||||
case SELF_SIGNED -> selfSignedPrivateKeySupplier.get();
|
||||
default -> throw new RuntimeException("Certificate provider mode exhausted.");
|
||||
};
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@@ -150,16 +146,12 @@ public final class CertificateSupplierModule {
|
||||
@PemFile Lazy<Supplier<ImmutableList<X509Certificate>>> pemCertificatesSupplier,
|
||||
@P12File Lazy<Supplier<ImmutableList<X509Certificate>>> p12CertificatesSupplier,
|
||||
@SelfSigned Lazy<Supplier<ImmutableList<X509Certificate>>> selfSignedCertificatesSupplier) {
|
||||
switch (mode) {
|
||||
case PEM_FILE:
|
||||
return pemCertificatesSupplier.get();
|
||||
case P12_FILE:
|
||||
return p12CertificatesSupplier.get();
|
||||
case SELF_SIGNED:
|
||||
return selfSignedCertificatesSupplier.get();
|
||||
default:
|
||||
throw new RuntimeException("Certificate provider mode exhausted.");
|
||||
}
|
||||
return switch (mode) {
|
||||
case PEM_FILE -> pemCertificatesSupplier.get();
|
||||
case P12_FILE -> p12CertificatesSupplier.get();
|
||||
case SELF_SIGNED -> selfSignedCertificatesSupplier.get();
|
||||
default -> throw new RuntimeException("Certificate provider mode exhausted.");
|
||||
};
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
||||
@@ -75,7 +75,7 @@ public final class NettyExtension implements AfterEachCallback {
|
||||
checkState(echoHandler == null, "Can't call setUpServer twice");
|
||||
echoHandler = new EchoHandler();
|
||||
ChannelInitializer<LocalChannel> serverInitializer =
|
||||
new ChannelInitializer<LocalChannel>() {
|
||||
new ChannelInitializer<>() {
|
||||
@Override
|
||||
protected void initChannel(LocalChannel ch) {
|
||||
// Add the given handler
|
||||
@@ -99,7 +99,7 @@ public final class NettyExtension implements AfterEachCallback {
|
||||
checkState(dumpHandler == null, "Can't call setUpClient twice");
|
||||
dumpHandler = new DumpHandler();
|
||||
ChannelInitializer<LocalChannel> clientInitializer =
|
||||
new ChannelInitializer<LocalChannel>() {
|
||||
new ChannelInitializer<>() {
|
||||
@Override
|
||||
protected void initChannel(LocalChannel ch) {
|
||||
// Add the given handler
|
||||
|
||||
Reference in New Issue
Block a user