mirror of
https://github.com/google/nomulus
synced 2026-04-25 18:51:40 +00:00
Re-enable Java 17 features (#2333)
This commit is contained in:
@@ -22,7 +22,6 @@ import static google.registry.flows.FlowUtils.unmarshalEpp;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.flows.FlowModule.EppExceptionInProviderException;
|
||||
@@ -45,7 +44,7 @@ import org.json.simple.JSONValue;
|
||||
public final class EppController {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final String LOG_SEPARATOR = Strings.repeat("=", 40);
|
||||
private static final String LOG_SEPARATOR = "=".repeat(40);
|
||||
|
||||
@Inject FlowComponent.Builder flowComponentBuilder;
|
||||
@Inject EppMetric.Builder eppMetricBuilder;
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.flows;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.xml.XmlTransformer.prettyPrint;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.flows.FlowModule.DryRun;
|
||||
import google.registry.flows.FlowModule.InputXml;
|
||||
@@ -36,7 +35,7 @@ import javax.inject.Provider;
|
||||
/** Run a flow, either transactionally or not, with logging and retrying as needed. */
|
||||
public class FlowRunner {
|
||||
|
||||
private static final String COMMAND_LOG_FORMAT = "EPP Command" + Strings.repeat("\n\t%s", 8);
|
||||
private static final String COMMAND_LOG_FORMAT = "EPP Command" + "\n\t%s".repeat(8);
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ import google.registry.xml.ValidationMode;
|
||||
import google.registry.xml.XmlException;
|
||||
import google.registry.xml.XmlFragmentMarshaller;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
@@ -51,7 +51,7 @@ import org.joda.time.DateTime;
|
||||
public final class RdeMarshaller implements Serializable {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final long serialVersionUID = 202890386611768455L;
|
||||
@Serial private static final long serialVersionUID = 202890386611768455L;
|
||||
|
||||
private final ValidationMode validationMode;
|
||||
private transient XmlFragmentMarshaller memoizedMarshaller;
|
||||
@@ -85,13 +85,12 @@ public final class RdeMarshaller implements Serializable {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
XjcXmlTransformer.marshal(deposit, os, UTF_8, validationMode);
|
||||
// TODO: Call StandardCharset.UTF_8 instead once we are one Java 17 runtime.
|
||||
String rdeDocument = os.toString("UTF-8");
|
||||
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) {
|
||||
} catch (XmlException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.net.MediaType;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -133,6 +132,6 @@ public final class UrlConnectionUtils {
|
||||
random.nextBytes(rand);
|
||||
// Boundary strings can be up to 70 characters long, so use 30 hyphens plus 32 random digits.
|
||||
// See https://tools.ietf.org/html/rfc2046#section-5.1.1
|
||||
return Strings.repeat("-", 30) + base64().encode(rand);
|
||||
return "-".repeat(30) + base64().encode(rand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.tools;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Strings;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ForeignKeyUtils;
|
||||
import google.registry.model.contact.Contact;
|
||||
@@ -46,10 +45,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);
|
||||
return String.format("%s:\n%s\n%s", header, "-".repeat(header.length() + 1), body);
|
||||
}
|
||||
|
||||
/** Prompts for yes/no input using promptText, defaulting to no. */
|
||||
|
||||
@@ -19,7 +19,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.common.Cursor;
|
||||
import google.registry.model.common.Cursor.CursorType;
|
||||
@@ -64,7 +63,7 @@ final class ListCursorsCommand implements Command {
|
||||
tm().transact(() -> tm().loadByKeysIfPresent(cursorKeys.values()));
|
||||
if (!cursorKeys.isEmpty()) {
|
||||
String header = String.format(OUTPUT_FMT, "TLD", "Cursor Time", "Last Update Time");
|
||||
System.out.printf("%s\n%s\n", header, Strings.repeat("-", header.length()));
|
||||
System.out.printf("%s\n%s\n", header, "-".repeat(header.length()));
|
||||
cursorKeys.entrySet().stream()
|
||||
.map(e -> renderLine(e.getKey(), Optional.ofNullable(cursors.get(e.getValue()))))
|
||||
.sorted()
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
@@ -94,14 +93,14 @@ final class VerifyOteCommand implements CommandWithConnection {
|
||||
ImmutableMap.of(
|
||||
"summarize", Boolean.toString(summarize),
|
||||
"registrars", new ArrayList<>(registrars)));
|
||||
System.out.println(Strings.repeat("-", 80));
|
||||
System.out.println("-".repeat(80));
|
||||
for (Entry<String, Object> registrar : response.entrySet()) {
|
||||
System.out.printf(
|
||||
summarize ? "%-20s - %s\n" : "\n=========== %s OT&E status ============\n%s\n",
|
||||
registrar.getKey(),
|
||||
registrar.getValue());
|
||||
}
|
||||
System.out.println(Strings.repeat("-", 80));
|
||||
System.out.println("-".repeat(80));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -239,8 +239,7 @@ public abstract class ListObjectsAction<T extends ImmutableObject> implements Ru
|
||||
lines.add(rowFormatter.apply(headerRow));
|
||||
|
||||
// Add a row of separator lines (column names mapping to '-' * column width).
|
||||
Map<String, String> separatorRow =
|
||||
Maps.transformValues(columnWidths, width -> Strings.repeat("-", width));
|
||||
Map<String, String> separatorRow = Maps.transformValues(columnWidths, "-"::repeat);
|
||||
lines.add(rowFormatter.apply(separatorRow));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user