mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Fix some statically detected code issues
This includes: unnecessary semicolons, suppress warnings, switch statements, final/private qualifiers, Optional wrapping, conditionals, both inline and non-inline variables, ternaries, Collection putAll() calls, StringBuilders, and throws declarations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244182539
This commit is contained in:
parent
9f360587ff
commit
24bb78bd16
54 changed files with 107 additions and 158 deletions
|
@ -236,7 +236,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
|||
enum Status {
|
||||
ALREADY_DELETED,
|
||||
AFTER_THRESHOLD,
|
||||
SUCCESS;
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
public abstract Status status();
|
||||
|
|
|
@ -116,7 +116,6 @@ public class SafeBrowsingTransforms {
|
|||
* @param clientSupplier a serializable CloseableHttpClient supplier
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@SuppressWarnings("unchecked")
|
||||
EvaluateSafeBrowsingFn(
|
||||
ValueProvider<String> apiKeyProvider,
|
||||
Retrier retrier,
|
||||
|
|
|
@ -473,7 +473,7 @@ public final class RegistryConfig {
|
|||
PRODUCTION,
|
||||
|
||||
/** Pilot mode, for everything else (e.g. sandbox). */
|
||||
PILOT;
|
||||
PILOT
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.cron;
|
||||
|
||||
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import com.google.appengine.api.taskqueue.Queue;
|
||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||
|
@ -24,6 +23,7 @@ import google.registry.request.Action;
|
|||
import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.TaskQueueUtils;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import javax.inject.Inject;
|
||||
|
@ -50,11 +50,12 @@ public final class CommitLogFanoutAction implements Runnable {
|
|||
public void run() {
|
||||
Queue taskQueue = getQueue(queue);
|
||||
for (int bucketId : CommitLogBucket.getBucketIds()) {
|
||||
TaskOptions taskOptions = TaskOptions.Builder.withUrl(endpoint)
|
||||
long delay =
|
||||
jitterSeconds.map(i -> random.nextInt((int) Duration.ofSeconds(i).toMillis())).orElse(0);
|
||||
TaskOptions taskOptions =
|
||||
TaskOptions.Builder.withUrl(endpoint)
|
||||
.param(BUCKET_PARAM, Integer.toString(bucketId))
|
||||
.countdownMillis(jitterSeconds.isPresent()
|
||||
? random.nextInt((int) SECONDS.toMillis(jitterSeconds.get()))
|
||||
: 0);
|
||||
.countdownMillis(delay);
|
||||
taskQueueUtils.enqueue(taskQueue, taskOptions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,12 +113,9 @@ public class FlowDocumentation {
|
|||
/** Iterates through javadoc tags on the underlying class and calls specific parsing methods. */
|
||||
private void parseTags(ClassDoc flowDoc) {
|
||||
for (Tag tag : flowDoc.tags()) {
|
||||
switch (tag.name()) {
|
||||
case "@error":
|
||||
// Everything else is not a relevant tag.
|
||||
if ("@error".equals(tag.name())) {
|
||||
parseErrorTag(tag);
|
||||
break;
|
||||
default:
|
||||
// Not a relevant tag.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -509,7 +509,6 @@ public class DomainFlowUtils {
|
|||
* (if opening the message interval). This may cause an autorenew billing event to have an end
|
||||
* time earlier than its event time (i.e. if it's being ended before it was ever triggered).
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void updateAutorenewRecurrenceEndTime(DomainBase domain, DateTime newEndTime) {
|
||||
Optional<PollMessage.Autorenew> autorenewPollMessage =
|
||||
Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now());
|
||||
|
|
|
@ -74,8 +74,6 @@ public final class PgpHelper {
|
|||
public static PGPPublicKey lookupPublicKey(
|
||||
PGPPublicKeyRingCollection keyring, String query, KeyRequirement want) {
|
||||
try {
|
||||
// Safe by specification.
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<PGPPublicKeyRing> results =
|
||||
keyring.getKeyRings(checkNotNull(query, "query"), true, true);
|
||||
verify(results.hasNext(), "No public key found matching substring: %s", query);
|
||||
|
@ -98,7 +96,6 @@ public final class PgpHelper {
|
|||
* @throws VerifyException if either keys couldn't be found.
|
||||
* @see #lookupPublicKey
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static PGPKeyPair lookupKeyPair(
|
||||
PGPPublicKeyRingCollection publics,
|
||||
PGPSecretKeyRingCollection privates,
|
||||
|
@ -130,8 +127,6 @@ public final class PgpHelper {
|
|||
*/
|
||||
public static Optional<PGPPublicKey> lookupPublicSubkey(
|
||||
PGPPublicKeyRing ring, KeyRequirement want) {
|
||||
// Safe by specification.
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<PGPPublicKey> keys = ring.getPublicKeys();
|
||||
while (keys.hasNext()) {
|
||||
PGPPublicKey key = keys.next();
|
||||
|
|
|
@ -53,7 +53,6 @@ import google.registry.model.tmch.TmchCrl;
|
|||
public final class EntityClasses {
|
||||
|
||||
/** Set of entity classes. */
|
||||
@SuppressWarnings("unchecked") // varargs
|
||||
public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES =
|
||||
ImmutableSet.of(
|
||||
AllocationToken.class,
|
||||
|
|
|
@ -140,7 +140,7 @@ public abstract class ImmutableObject implements Cloneable {
|
|||
}
|
||||
|
||||
/** Helper function to recursively hydrate an ImmutableObject. */
|
||||
private static final Object hydrate(Object value) {
|
||||
private static Object hydrate(Object value) {
|
||||
if (value instanceof Key) {
|
||||
return hydrate(ofy().load().key((Key<?>) value).now());
|
||||
} else if (value instanceof Map) {
|
||||
|
|
|
@ -608,7 +608,6 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Modification build() {
|
||||
Modification instance = getInstance();
|
||||
checkNotNull(instance.reason);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DesignatedContact extends ImmutableObject {
|
|||
@XmlEnumValue("tech")
|
||||
TECH,
|
||||
/** The registrant type is not reflected in XML and exists only for internal use. */
|
||||
REGISTRANT;
|
||||
REGISTRANT
|
||||
}
|
||||
|
||||
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class LaunchCheckExtension extends ImmutableObject implements CommandExte
|
|||
|
||||
/** A check to see if there are matching trademarks on the specified domain names. */
|
||||
@XmlEnumValue("claims")
|
||||
CLAIMS;
|
||||
CLAIMS
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,7 +72,7 @@ public class LaunchCreateExtension extends LaunchExtension implements CommandExt
|
|||
* uses a "first-come, first-served" model.
|
||||
*/
|
||||
@XmlEnumValue("registration")
|
||||
REGISTRATION;
|
||||
REGISTRATION
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -28,7 +28,7 @@ public class RestoreCommand {
|
|||
REQUEST,
|
||||
|
||||
@XmlEnumValue("report")
|
||||
REPORT;
|
||||
REPORT
|
||||
}
|
||||
|
||||
/** The restore operation. */
|
||||
|
|
|
@ -151,14 +151,10 @@ public class EppInput extends ImmutableObject {
|
|||
|
||||
/** Get the extension based on type, or null. If there are multiple, it chooses the first. */
|
||||
public <E extends CommandExtension> Optional<E> getSingleExtension(Class<E> clazz) {
|
||||
return Optional.ofNullable(
|
||||
getCommandWrapper()
|
||||
.getExtensions()
|
||||
.stream()
|
||||
return getCommandWrapper().getExtensions().stream()
|
||||
.filter(clazz::isInstance)
|
||||
.map(clazz::cast)
|
||||
.findFirst()
|
||||
.orElse(null));
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/** A tag that goes inside of an EPP {@literal <command>}. */
|
||||
|
@ -225,7 +221,7 @@ public class EppInput extends ImmutableObject {
|
|||
REJECT,
|
||||
|
||||
@XmlEnumValue("request")
|
||||
REQUEST;
|
||||
REQUEST
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "op")
|
||||
|
@ -251,7 +247,7 @@ public class EppInput extends ImmutableObject {
|
|||
|
||||
/** Request the next poll message. */
|
||||
@XmlEnumValue("req")
|
||||
REQUEST;
|
||||
REQUEST
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -31,7 +31,7 @@ public class MarkContact extends CommonMarkContactFields {
|
|||
AGENT,
|
||||
|
||||
@XmlEnumValue("thirdParty")
|
||||
THIRD_PARTY;
|
||||
THIRD_PARTY
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -31,7 +31,7 @@ public class MarkHolder extends CommonMarkContactFields {
|
|||
ASSIGNEE,
|
||||
|
||||
@XmlEnumValue("licensee")
|
||||
LICENSEE;
|
||||
LICENSEE
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
|
|
|
@ -165,7 +165,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
* This registrar is completely disabled and cannot perform any EPP actions whatsoever, nor log
|
||||
* in to the registrar console.
|
||||
*/
|
||||
DISABLED;
|
||||
DISABLED
|
||||
}
|
||||
|
||||
/** Regex for E.164 phone number format specified by {@code contact.xsd}. */
|
||||
|
|
|
@ -32,7 +32,7 @@ public abstract class CheckApiMetric {
|
|||
|
||||
private final String displayLabel;
|
||||
|
||||
private Tier(String displayLabel) {
|
||||
Tier(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public abstract class CheckApiMetric {
|
|||
|
||||
private final String displayLabel;
|
||||
|
||||
private Availability(String displayLabel) {
|
||||
Availability(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public abstract class CheckApiMetric {
|
|||
|
||||
private final String displayLabel;
|
||||
|
||||
private Status(String displayLabel) {
|
||||
Status(String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class WebWhoisProtocolsModule {
|
|||
httpServerCodecProvider,
|
||||
httpServerExpectContinueHandlerProvider,
|
||||
webWhoisRedirectHandlerProvides);
|
||||
};
|
||||
}
|
||||
|
||||
@Provides
|
||||
@HttpsWhoisProtocol
|
||||
|
@ -101,7 +101,7 @@ public class WebWhoisProtocolsModule {
|
|||
httpServerCodecProvider,
|
||||
httpServerExpectContinueHandlerProvider,
|
||||
webWhoisRedirectHandlerProvides);
|
||||
};
|
||||
}
|
||||
|
||||
@Provides
|
||||
static HttpServerCodec provideHttpServerCodec() {
|
||||
|
|
|
@ -105,7 +105,6 @@ public class WebWhoisRedirectHandler extends SimpleChannelInboundHandler<HttpReq
|
|||
isHttps
|
||||
? new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)
|
||||
: new DefaultFullHttpResponse(HTTP_1_1, OK);
|
||||
;
|
||||
} else {
|
||||
// HTTP -> HTTPS is a 301 redirect, whereas HTTPS -> web WHOIS site is 302 redirect.
|
||||
response = new DefaultFullHttpResponse(HTTP_1_1, isHttps ? FOUND : MOVED_PERMANENTLY);
|
||||
|
|
|
@ -235,10 +235,7 @@ public abstract class RdapActionBase implements Runnable {
|
|||
if (userAuthInfo.isUserAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (registrarAccessor.getAllClientIdWithRoles().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !registrarAccessor.getAllClientIdWithRoles().isEmpty();
|
||||
}
|
||||
|
||||
DeletedItemHandling getDeletedItemHandling() {
|
||||
|
|
|
@ -54,10 +54,6 @@ public final class RydeEncoder extends FilterOutputStream {
|
|||
|
||||
private final OutputStream sigOutput;
|
||||
private final RydePgpSigningOutputStream signer;
|
||||
private final OutputStream encryptLayer;
|
||||
private final OutputStream kompressor;
|
||||
private final OutputStream fileLayer;
|
||||
private final OutputStream tarLayer;
|
||||
// We use a Closer to handle the stream .close, to make sure it's done correctly.
|
||||
private final Closer closer = Closer.create();
|
||||
private boolean isClosed = false;
|
||||
|
@ -73,10 +69,12 @@ public final class RydeEncoder extends FilterOutputStream {
|
|||
super(null);
|
||||
this.sigOutput = sigOutput;
|
||||
signer = closer.register(new RydePgpSigningOutputStream(checkNotNull(rydeOutput), signingKey));
|
||||
encryptLayer = closer.register(openEncryptor(signer, RYDE_USE_INTEGRITY_PACKET, receiverKeys));
|
||||
kompressor = closer.register(openCompressor(encryptLayer));
|
||||
fileLayer = closer.register(openPgpFileWriter(kompressor, filenamePrefix + ".tar", modified));
|
||||
tarLayer =
|
||||
OutputStream encryptLayer =
|
||||
closer.register(openEncryptor(signer, RYDE_USE_INTEGRITY_PACKET, receiverKeys));
|
||||
OutputStream kompressor = closer.register(openCompressor(encryptLayer));
|
||||
OutputStream fileLayer =
|
||||
closer.register(openPgpFileWriter(kompressor, filenamePrefix + ".tar", modified));
|
||||
OutputStream tarLayer =
|
||||
closer.register(openTarWriter(fileLayer, dataLength, filenamePrefix + ".xml", modified));
|
||||
this.out = tarLayer;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ public class RydePgpSigningOutputStream extends ImprovedOutputStream {
|
|||
* googler who was also uncertain about the precise reason why it's needed.
|
||||
*/
|
||||
private static void addUserInfoToSignature(PGPPublicKey publicKey, PGPSignatureGenerator signer) {
|
||||
@SuppressWarnings("unchecked") // safe by specification.
|
||||
Iterator<String> uidIter = publicKey.getUserIDs();
|
||||
if (uidIter.hasNext()) {
|
||||
PGPSignatureSubpacketGenerator spg = new PGPSignatureSubpacketGenerator();
|
||||
|
|
|
@ -34,7 +34,7 @@ public interface DnsCountQueryCoordinator {
|
|||
*
|
||||
* If your report query requires any additional parameters, add them here.
|
||||
*/
|
||||
public class Params {
|
||||
class Params {
|
||||
public BigqueryConnection bigquery;
|
||||
|
||||
/** The Google Cloud project id. */
|
||||
|
|
|
@ -33,8 +33,6 @@ public class DnsCountQueryCoordinatorModule {
|
|||
@Config("projectId") String projectId) {
|
||||
DnsCountQueryCoordinator.Params params =
|
||||
new DnsCountQueryCoordinator.Params(bigquery, projectId);
|
||||
DnsCountQueryCoordinator result =
|
||||
instantiate(getClassFromString(customClass, DnsCountQueryCoordinator.class), params);
|
||||
return result;
|
||||
return instantiate(getClassFromString(customClass, DnsCountQueryCoordinator.class), params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,14 +88,12 @@ public final class IcannReportingModule {
|
|||
static BigqueryConnection provideBigqueryConnection(
|
||||
BigqueryConnection.Builder bigQueryConnectionBuilder) {
|
||||
try {
|
||||
BigqueryConnection connection =
|
||||
bigQueryConnectionBuilder
|
||||
return bigQueryConnectionBuilder
|
||||
.setExecutorService(MoreExecutors.newDirectExecutorService())
|
||||
.setDatasetId(ICANN_REPORTING_DATA_SET)
|
||||
.setOverwrite(true)
|
||||
.setPollInterval(Duration.standardSeconds(1))
|
||||
.build();
|
||||
return connection;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Could not initialize BigqueryConnection!", e);
|
||||
}
|
||||
|
|
|
@ -293,11 +293,10 @@ public class AuthenticatedRegistrarAccessor {
|
|||
|
||||
// both GAE project admin and members of the gSuiteSupportGroupEmailAddress are considered
|
||||
// admins for the RegistrarConsole.
|
||||
return bypassAdminCheck
|
||||
? false
|
||||
: userAuthInfo.isUserAdmin()
|
||||
return !bypassAdminCheck
|
||||
&& (userAuthInfo.isUserAdmin()
|
||||
|| checkIsSupport(
|
||||
lazyGroupsConnection, user.getEmail(), gSuiteSupportGroupEmailAddress);
|
||||
lazyGroupsConnection, user.getEmail(), gSuiteSupportGroupEmailAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,6 @@ public final class Marksdb {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void pgpVerifySignature(byte[] data, byte[] signature, PGPPublicKey publicKey)
|
||||
throws PGPException, SignatureException {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
|
|
@ -30,7 +30,6 @@ public final class TmchData {
|
|||
private static final String BEGIN_ENCODED_SMD = "-----BEGIN ENCODED SMD-----";
|
||||
private static final String END_ENCODED_SMD = "-----END ENCODED SMD-----";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static PGPPublicKey loadPublicKey(ByteSource pgpPublicKeyFile) {
|
||||
try (InputStream input = pgpPublicKeyFile.openStream();
|
||||
InputStream decoder = PGPUtil.getDecoderStream(input)) {
|
||||
|
|
|
@ -53,13 +53,11 @@ final class BigqueryParameters {
|
|||
|
||||
/** Returns a new BigqueryConnection constructed according to the delegate's flag settings. */
|
||||
BigqueryConnection newConnection(BigqueryConnection.Builder connectionBuilder) throws Exception {
|
||||
BigqueryConnection connection =
|
||||
connectionBuilder
|
||||
return connectionBuilder
|
||||
.setExecutorService(Executors.newFixedThreadPool(bigqueryNumThreads))
|
||||
.setDatasetId(bigqueryDataset)
|
||||
.setOverwrite(bigqueryOverwrite)
|
||||
.setPollInterval(bigqueryPollInterval)
|
||||
.build();
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ package google.registry.tools;
|
|||
* <p>This exists only to allow us to test ShellCommand.
|
||||
*/
|
||||
interface CommandRunner {
|
||||
public void run(String[] args) throws Exception;
|
||||
void run(String[] args) throws Exception;
|
||||
}
|
||||
|
|
|
@ -307,8 +307,7 @@ final class RegistrarContactCommand extends MutatingCommand {
|
|||
private void unsetOtherWhoisAbuseFlags(
|
||||
ImmutableSet<RegistrarContact> contacts, @Nullable String emailAddressNotToChange) {
|
||||
for (RegistrarContact contact : contacts) {
|
||||
if (((emailAddressNotToChange == null)
|
||||
|| !contact.getEmailAddress().equals(emailAddressNotToChange))
|
||||
if (!contact.getEmailAddress().equals(emailAddressNotToChange)
|
||||
&& contact.getVisibleInDomainWhoisAsAbuse()) {
|
||||
RegistrarContact newContact =
|
||||
contact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build();
|
||||
|
|
|
@ -41,8 +41,7 @@ public abstract class ParameterConverterValidator<T>
|
|||
convert(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
ParameterException pe =
|
||||
new ParameterException(String.format("%s=%s %s", name, value, messageForInvalid));
|
||||
pe.initCause(e);
|
||||
new ParameterException(String.format("%s=%s %s", name, value, messageForInvalid), e);
|
||||
throw pe;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class ResaveAllHistoryEntriesAction implements Runnable {
|
|||
@Inject Response response;
|
||||
@Inject ResaveAllHistoryEntriesAction() {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run() {
|
||||
mrRunner
|
||||
|
|
|
@ -51,9 +51,10 @@ public final class SoyTemplateUtils {
|
|||
for (SoyFileInfo soyInfo : soyInfos) {
|
||||
builder.add(getResource(soyInfo.getClass(), soyInfo.getFileName()));
|
||||
}
|
||||
Map<String, Object> globals = new HashMap<>();
|
||||
Map<String, Object> globals;
|
||||
try {
|
||||
globals.putAll(SoyUtils.parseCompileTimeGlobals(asCharSource(SOY_GLOBALS, UTF_8)));
|
||||
globals =
|
||||
new HashMap<>(SoyUtils.parseCompileTimeGlobals(asCharSource(SOY_GLOBALS, UTF_8)));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load soy globals", e);
|
||||
}
|
||||
|
|
|
@ -351,22 +351,18 @@ public final class ConsoleRegistrarCreatorAction implements Runnable {
|
|||
return;
|
||||
}
|
||||
String environment = Ascii.toLowerCase(String.valueOf(registryEnvironment));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder
|
||||
.append(
|
||||
String body =
|
||||
String.format(
|
||||
"The following registrar was created in %s by %s:\n",
|
||||
environment, registrarAccessor.userIdForLogging()))
|
||||
.append(toEmailLine(clientId, "clientId"))
|
||||
.append(toEmailLine(name, "name"))
|
||||
.append(toEmailLine(billingAccount, "billingAccount"))
|
||||
.append(toEmailLine(ianaId, "ianaId"))
|
||||
.append(toEmailLine(referralEmail, "referralEmail"))
|
||||
.append(toEmailLine(driveId, "driveId"))
|
||||
.append(
|
||||
String.format("Gave user %s web access to the registrar\n", consoleUserEmail.get()));
|
||||
environment, registrarAccessor.userIdForLogging())
|
||||
+ toEmailLine(clientId, "clientId")
|
||||
+ toEmailLine(name, "name")
|
||||
+ toEmailLine(billingAccount, "billingAccount")
|
||||
+ toEmailLine(ianaId, "ianaId")
|
||||
+ toEmailLine(referralEmail, "referralEmail")
|
||||
+ toEmailLine(driveId, "driveId")
|
||||
+ String.format("Gave user %s web access to the registrar\n", consoleUserEmail.get());
|
||||
sendEmailUtils.sendEmail(
|
||||
String.format("Registrar %s created in %s", clientId.get(), environment),
|
||||
builder.toString());
|
||||
String.format("Registrar %s created in %s", clientId.get(), environment), body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,8 +246,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
|||
.map(RegistrarContact::toDiffableFieldMap)
|
||||
.collect(toImmutableSet());
|
||||
// Use LinkedHashMap here to preserve ordering; null values mean we can't use ImmutableMap.
|
||||
LinkedHashMap<String, Object> result = new LinkedHashMap<>();
|
||||
result.putAll(registrar.toDiffableFieldMap());
|
||||
LinkedHashMap<String, Object> result = new LinkedHashMap<>(registrar.toDiffableFieldMap());
|
||||
result.put("contacts", expandedContacts);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public final class PosixTarHeader {
|
|||
DIRECTORY,
|
||||
|
||||
/** This indicates we read a file from an archive with an unsupported type. */
|
||||
UNSUPPORTED;
|
||||
UNSUPPORTED
|
||||
}
|
||||
|
||||
public static final int HEADER_LENGTH = 512;
|
||||
|
|
|
@ -20,7 +20,6 @@ import static com.google.common.net.HttpHeaders.AUTHORIZATION;
|
|||
import static com.google.common.net.HttpHeaders.CONTENT_DISPOSITION;
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static java.lang.String.format;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.appengine.api.urlfetch.HTTPHeader;
|
||||
|
@ -73,18 +72,20 @@ public final class UrlFetchUtils {
|
|||
checkState(
|
||||
!data.contains(boundary),
|
||||
"Multipart data contains autogenerated boundary: %s", boundary);
|
||||
StringBuilder multipart = new StringBuilder();
|
||||
multipart.append(format("--%s\r\n", boundary));
|
||||
multipart.append(format("%s: form-data; name=\"%s\"; filename=\"%s\"\r\n",
|
||||
CONTENT_DISPOSITION, name, filename));
|
||||
multipart.append(format("%s: %s\r\n", CONTENT_TYPE, contentType.toString()));
|
||||
multipart.append("\r\n");
|
||||
multipart.append(data);
|
||||
multipart.append("\r\n");
|
||||
multipart.append(format("--%s--\r\n", boundary));
|
||||
byte[] payload = multipart.toString().getBytes(UTF_8);
|
||||
String multipart =
|
||||
String.format("--%s\r\n", boundary)
|
||||
+ String.format(
|
||||
"%s: form-data; name=\"%s\"; filename=\"%s\"\r\n",
|
||||
CONTENT_DISPOSITION, name, filename)
|
||||
+ String.format("%s: %s\r\n", CONTENT_TYPE, contentType)
|
||||
+ "\r\n"
|
||||
+ data
|
||||
+ "\r\n"
|
||||
+ String.format("--%s--\r\n", boundary);
|
||||
byte[] payload = multipart.getBytes(UTF_8);
|
||||
request.addHeader(
|
||||
new HTTPHeader(CONTENT_TYPE, format("multipart/form-data; boundary=\"%s\"", boundary)));
|
||||
new HTTPHeader(
|
||||
CONTENT_TYPE, String.format("multipart/form-data;" + " boundary=\"%s\"", boundary)));
|
||||
request.addHeader(new HTTPHeader(CONTENT_LENGTH, Integer.toString(payload.length)));
|
||||
request.setPayload(payload);
|
||||
}
|
||||
|
|
|
@ -425,7 +425,6 @@ public class CloudDnsWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void retryMutateZoneOnError() {
|
||||
CloudDnsWriter spyWriter = spy(writer);
|
||||
// First call - throw. Second call - do nothing.
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.documentation;
|
|||
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static google.registry.util.BuildPathUtils.getProjectRoot;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import java.io.IOException;
|
||||
|
@ -47,7 +48,7 @@ public class FlowDocumentationTest {
|
|||
Path goldenMarkdownPath =
|
||||
GOLDEN_MARKDOWN_FILEPATH;
|
||||
|
||||
String goldenMarkdown = new String(Files.readAllBytes(goldenMarkdownPath), "UTF-8");
|
||||
String goldenMarkdown = new String(Files.readAllBytes(goldenMarkdownPath), UTF_8);
|
||||
|
||||
// Don't use Truth's isEqualTo() because the output is huge and unreadable for large files.
|
||||
DocumentationGenerator generator = new DocumentationGenerator();
|
||||
|
|
|
@ -86,7 +86,7 @@ public class ExportDomainListsActionTest extends MapreduceTestCase<ExportDomainL
|
|||
eq(EXPORT_MIME_TYPE),
|
||||
eq(folderId),
|
||||
bytesExportedToDrive.capture());
|
||||
assertThat(new String(bytesExportedToDrive.getValue(), "UTF-8")).isEqualTo(domains);
|
||||
assertThat(new String(bytesExportedToDrive.getValue(), UTF_8)).isEqualTo(domains);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -60,7 +60,6 @@ import google.registry.xml.ValidationMode;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
|
@ -183,14 +182,11 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
ImmutableMap.Builder<GracePeriod, BillingEvent> builder = new ImmutableMap.Builder<>();
|
||||
for (Map.Entry<GracePeriod, ? extends BillingEvent> entry : gracePeriods.entrySet()) {
|
||||
builder.put(
|
||||
((Function<GracePeriod, GracePeriod>)
|
||||
gracePeriod ->
|
||||
GracePeriod.create(
|
||||
gracePeriod.getType(),
|
||||
gracePeriod.getExpirationTime(),
|
||||
gracePeriod.getClientId(),
|
||||
null))
|
||||
.apply(entry.getKey()),
|
||||
entry.getKey().getType(),
|
||||
entry.getKey().getExpirationTime(),
|
||||
entry.getKey().getClientId(),
|
||||
null),
|
||||
stripBillingEventId(entry.getValue()));
|
||||
}
|
||||
return builder.build();
|
||||
|
|
|
@ -383,7 +383,6 @@ public class BouncyCastleTest {
|
|||
* Googler who was also uncertain about the precise reason why it's needed.
|
||||
*/
|
||||
private void addUserInfoToSignature(PGPPublicKey publicKey, PGPSignatureGenerator signer) {
|
||||
@SuppressWarnings("unchecked") // Safe by specification.
|
||||
Iterator<String> uidIter = publicKey.getUserIDs();
|
||||
if (uidIter.hasNext()) {
|
||||
PGPSignatureSubpacketGenerator spg = new PGPSignatureSubpacketGenerator();
|
||||
|
|
|
@ -76,7 +76,6 @@ import google.registry.testing.sftp.SftpServerRule;
|
|||
import google.registry.util.Retrier;
|
||||
import google.registry.util.TaskQueueUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -353,7 +352,7 @@ public class RdeUploadActionTest {
|
|||
+ "upload; last upload attempt was at 2010-10-16T22:23:00.000Z (97 minutes ago)");
|
||||
}
|
||||
|
||||
private String slurp(InputStream is) throws FileNotFoundException, IOException {
|
||||
private String slurp(InputStream is) throws IOException {
|
||||
return CharStreams.toString(new InputStreamReader(is, UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import google.registry.testing.GpgSystemCommandRule;
|
|||
import google.registry.testing.ShardableTestCase;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -208,7 +207,7 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
assertThat(slurp(xmlFile)).isEqualTo(content.get());
|
||||
}
|
||||
|
||||
private String slurp(File file) throws FileNotFoundException, IOException {
|
||||
private String slurp(File file) throws IOException {
|
||||
return CharStreams.toString(new InputStreamReader(new FileInputStream(file), UTF_8));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,6 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class PublishInvoicesActionTest {
|
||||
|
||||
private Dataflow dataflow;
|
||||
private Projects projects;
|
||||
private Jobs jobs;
|
||||
private Get get;
|
||||
private BillingEmailUtils emailUtils;
|
||||
|
||||
|
@ -60,9 +57,9 @@ public class PublishInvoicesActionTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
dataflow = mock(Dataflow.class);
|
||||
projects = mock(Projects.class);
|
||||
jobs = mock(Jobs.class);
|
||||
Dataflow dataflow = mock(Dataflow.class);
|
||||
Projects projects = mock(Projects.class);
|
||||
Jobs jobs = mock(Jobs.class);
|
||||
get = mock(Get.class);
|
||||
when(dataflow.projects()).thenReturn(projects);
|
||||
when(projects.jobs()).thenReturn(jobs);
|
||||
|
|
|
@ -82,8 +82,7 @@ public class TestCacheRule extends ExternalResource {
|
|||
}
|
||||
|
||||
public TestCacheRule build() {
|
||||
TestCacheRule rule = new TestCacheRule(ImmutableList.copyOf(cacheHandlerMap.values()));
|
||||
return rule;
|
||||
return new TestCacheRule(ImmutableList.copyOf(cacheHandlerMap.values()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,6 @@ public class NordnUploadActionTest {
|
|||
assertThat(action.loadAllTasks(queue, "tld")).containsExactly(task);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void test_loadAllTasks_retryLogic_allFailures() {
|
||||
Queue queue = mock(Queue.class);
|
||||
|
|
|
@ -235,7 +235,6 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
|||
verifyZeroInteractions(connection);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testFailure_groupCreationFails() throws Exception {
|
||||
when(connection.sendPostRequest(
|
||||
|
|
|
@ -24,7 +24,6 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.tools.LevelDbFileBuilder.Property;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -41,7 +40,7 @@ public class LevelDbFileBuilderTest {
|
|||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
|
||||
@Test
|
||||
public void testSingleRecordWrites() throws FileNotFoundException, IOException {
|
||||
public void testSingleRecordWrites() throws IOException {
|
||||
File subdir = tempFs.newFolder("folder");
|
||||
File logFile = new File(subdir, "testfile");
|
||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||
|
@ -64,7 +63,7 @@ public class LevelDbFileBuilderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleRecordWrites() throws FileNotFoundException, IOException {
|
||||
public void testMultipleRecordWrites() throws IOException {
|
||||
File subdir = tempFs.newFolder("folder");
|
||||
File logFile = new File(subdir, "testfile");
|
||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||
|
|
|
@ -77,8 +77,7 @@ public class ConsoleUiActionTest {
|
|||
action.userService = UserServiceFactory.getUserService();
|
||||
action.xsrfTokenManager = new XsrfTokenManager(new FakeClock(), action.userService);
|
||||
action.paramClientId = Optional.empty();
|
||||
AuthResult authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
|
||||
action.authResult = authResult;
|
||||
action.authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
|
||||
action.environment = RegistryEnvironment.UNITTEST;
|
||||
|
||||
action.registrarAccessor =
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.util;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
@ -264,8 +265,8 @@ public class CidrAddressBlockTest extends TestCase {
|
|||
assertEquals(b0, b1);
|
||||
assertEquals(b0, new CidrAddressBlock(b0.toString()));
|
||||
assertEquals(b0.hashCode(), b1.hashCode());
|
||||
assertFalse(b0.equals(b2));
|
||||
assertFalse(b0.equals(b3));
|
||||
assertNotEquals(b0, b2);
|
||||
assertNotEquals(b0, b3);
|
||||
}
|
||||
|
||||
public void testIterate() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue