Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1549,9 +1549,9 @@ class BeamModulePlugin implements Plugin<Project> {
"InvalidInlineTag",
"InvalidLink",
"InvalidParam",
"InvalidThrows",
"InvalidParam",
"JavaTimeDefaultTimeZone",
"JavaTimeDefaultTimeZone",
"JavaUtilDate",
"JodaConstructors",
"MalformedInlineTag",
"MixedMutabilityReturnType",
Expand All @@ -1561,7 +1561,7 @@ class BeamModulePlugin implements Plugin<Project> {
"Slf4jSignOnlyFormat",
"StaticAssignmentInConstructor",
"ThreadPriorityCheck",
"TimeUnitConversionChecker",
"ThreadPriorityCheck",
"UndefinedEquals",
"UnescapedEntity",
"UnnecessaryLambda",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public String getJsonBeamSchema() {
*
* @param filePath path to file in GCS
* @return contents of the file as a string
* @throws IOException thrown if not able to read file
*/
public static String getGcsFileAsString(String filePath) {
MatchResult result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
Expand Down Expand Up @@ -128,7 +129,9 @@ private WindowedWordCountITOptions defaultOptions() throws Exception {
.resolve(
String.format(
"WindowedWordCountIT.%s-%tFT%<tH:%<tM:%<tS.%<tL+%s",
testName.getMethodName(), new Date(), ThreadLocalRandom.current().nextInt()),
testName.getMethodName(),
LocalDateTime.now(ZoneId.of("UTC")),
ThreadLocalRandom.current().nextInt()),
StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static org.apache.beam.sdk.testing.FileChecksumMatcher.fileContentsHaveChecksum;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.apache.beam.examples.WordCount.WordCountOptions;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.ResolveOptions.StandardResolveOptions;
Expand Down Expand Up @@ -61,7 +62,8 @@ public void testE2EWordCount() throws Exception {
options.setOutput(
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("WordCountIT-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"WordCountIT-%tF-%<tH-%<tM-%<tS-%<tL", LocalDateTime.now(ZoneId.of("UTC"))),
StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static org.apache.beam.sdk.testing.FileChecksumMatcher.fileContentsHaveChecksum;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.regex.Pattern;
import org.apache.beam.examples.complete.TfIdf.Options;
import org.apache.beam.sdk.io.FileSystems;
Expand Down Expand Up @@ -62,7 +63,8 @@ public void testE2ETfIdf() throws Exception {
options.setOutput(
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("TfIdfIT-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"TfIdfIT-%tF-%<tH-%<tM-%<tS-%<tL", LocalDateTime.now(ZoneId.of("UTC"))),
StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static org.apache.beam.sdk.testing.FileChecksumMatcher.fileContentsHaveChecksum;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.ResolveOptions.StandardResolveOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
Expand Down Expand Up @@ -58,7 +59,9 @@ public void testE2ETopWikiPages() throws Exception {
options.setOutput(
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("topwikisessions-it-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"topwikisessions-it-%tF-%<tH-%<tM-%<tS-%<tL",
LocalDateTime.now(ZoneId.of("UTC"))),
StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static org.apache.beam.sdk.testing.FileChecksumMatcher.fileContentsHaveChecksum;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.regex.Pattern;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.ResolveOptions;
Expand Down Expand Up @@ -73,7 +74,8 @@ public void testE2EDistinctExample() throws Exception {
options.setOutput(
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("DistinctExample-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"DistinctExample-%tF-%<tH-%<tM-%<tS-%<tL", LocalDateTime.now(ZoneId.of("UTC"))),
ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", ResolveOptions.StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static org.apache.beam.sdk.testing.FileChecksumMatcher.fileContentsHaveChecksum;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.regex.Pattern;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.ResolveOptions;
Expand Down Expand Up @@ -55,7 +56,8 @@ public void testE2EJoinExamples() throws Exception {
options.setOutput(
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("JoinExamples-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"JoinExamples-%tF-%<tH-%<tM-%<tS-%<tL", LocalDateTime.now(ZoneId.of("UTC"))),
ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("output", ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY)
.resolve("results", ResolveOptions.StandardResolveOptions.RESOLVE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public DoFn.ProcessContinuation processElement(
return DoFn.ProcessContinuation.stop();
}
if (status != null) {
Instant currentInstant = Instant.ofEpochMilli(status.getCreatedAt().getTime());
Instant currentInstant =
Instant.ofEpochMilli(status.getCreatedAt().toInstant().toEpochMilli());
watermarkEstimator.setWatermark(currentInstant);
out.outputWithTimestamp(status.getText(), currentInstant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ReadFromTwitterDoFnTest {
LinkedBlockingQueue<Status> queue2 = new LinkedBlockingQueue<>();

@Before
@SuppressWarnings("JavaUtilDate")
public void setUp() throws JsonProcessingException {
MockitoAnnotations.initMocks(this);
when(status1.getText()).thenReturn("Breaking News1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -74,7 +73,8 @@ public LaunchInfo launch(String project, String region, LaunchConfig options) th

String jobId =
"direct-"
+ new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss").format(new Date())
+ new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss")
.format(java.time.Instant.now().toEpochMilli())
+ "-"
+ System.currentTimeMillis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.apache.beam.runners.core.metrics;

import java.util.Date;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
Expand Down Expand Up @@ -47,7 +46,8 @@ public String generateLogMessage(
StringBuilder logMessage = new StringBuilder();
logMessage.append(header);
logMessage.append(deltaContainer.getCumulativeString(allowedMetricUrns));
logMessage.append(String.format("(last reported at %s)%n", new Date(lastReported)));
logMessage.append(
String.format("(last reported at %s)%n", java.time.Instant.ofEpochMilli(lastReported)));

lastMetricsSnapshot = nextMetricsSnapshot;
return logMessage.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.Executors;
import org.apache.beam.model.jobmanagement.v1.JobApi;
Expand Down Expand Up @@ -144,7 +145,9 @@ private void runTest(boolean portable) throws Exception {
ResourceId outputDir =
FileSystems.matchNewResource(tempFolder.getRoot().getAbsolutePath(), true)
.resolve(
String.format("requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL",
LocalDateTime.now(ZoneId.of("UTC"))),
ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY);
String singleOutputPrefix =
outputDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.Executors;
import org.apache.beam.model.jobmanagement.v1.JobApi;
Expand Down Expand Up @@ -142,7 +143,9 @@ private void runTest(boolean portable) throws Exception {
ResourceId outputDir =
FileSystems.matchNewResource(tempFolder.getRoot().getAbsolutePath(), true)
.resolve(
String.format("requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL",
LocalDateTime.now(ZoneId.of("UTC"))),
ResolveOptions.StandardResolveOptions.RESOLVE_DIRECTORY);
String singleOutputPrefix =
outputDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public FileOutputStreamFactory(String filepath) {
}

@Override
@SuppressWarnings("JavaUtilDate")
public OutputStream get() {
try {
String filename = filepath + "." + formatter.format(new Date()) + ".log";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
@RunWith(Parameterized.class)
// TODO(https://github.com/apache/beam/issues/21230): Remove when new version of errorprone is
// released (2.11.0)
@SuppressWarnings({"unused", "deprecation"})
@SuppressWarnings({"unused", "deprecation", "TimeUnitConversionChecker"})
public class StreamingDataflowWorkerTest {

private static final Logger LOG = LoggerFactory.getLogger(StreamingDataflowWorkerTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ public void close() throws Exception {
* @param stagingService an ArtifactStagingService stub which will request artifacts
* @param stagingToken the staging token of the job whose artifacts will be retrieved
* @throws InterruptedException
* @throws IOException
*/
public static void offer(
ArtifactRetrievalService retrievalService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ static TransformUpgrader of(ExpansionServiceClientFactory clientFactory) {
* @param urnsToOverride URNs of the transforms to be overridden.
* @param options options for determining the transform service to use.
* @return pipelines with transforms upgraded using the Transform Service.
* @throws Exception
*/
public RunnerApi.Pipeline upgradeTransformsViaTransformService(
RunnerApi.Pipeline pipeline, List<String> urnsToOverride, PipelineOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.UUID;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.MatchResult;
Expand Down Expand Up @@ -125,7 +126,9 @@ public void testParDoRequiresStableInput() {
ResourceId outputDir =
FileSystems.matchNewResource(options.getTempRoot(), true)
.resolve(
String.format("requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
String.format(
"requires-stable-input-%tF-%<tH-%<tM-%<tS-%<tL",
LocalDateTime.now(ZoneId.of("UTC"))),
StandardResolveOptions.RESOLVE_DIRECTORY);
String singleOutputPrefix =
outputDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.beam.sdk.Pipeline;
Expand Down Expand Up @@ -132,7 +133,7 @@ public boolean matches(Object o) {

@Override
public void describeTo(Description description) {
description.appendText(String.format("%tL", new Date()));
description.appendText(String.format("%tL", LocalDateTime.now(ZoneId.of("UTC"))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.beam.sdk.extensions.gcp.options.GcsOptions;
import org.apache.beam.sdk.extensions.gcp.util.GcsUtil.CreateOptions;
Expand Down Expand Up @@ -72,7 +73,8 @@ public void testRewriteMultiPart() throws IOException {
String dstFilename =
gcsOptions.getGcpTempLocation()
+ String.format(
"/GcsUtilIT-%tF-%<tH-%<tM-%<tS-%<tL.testRewriteMultiPart.copy", new Date());
"/GcsUtilIT-%tF-%<tH-%<tM-%<tS-%<tL.testRewriteMultiPart.copy",
LocalDateTime.now(ZoneId.of("UTC")));
gcsUtil.delegate.maxBytesRewrittenPerCall = 50L * 1024 * 1024;
gcsUtil.delegate.numRewriteTokensUsed = new AtomicInteger();

Expand Down Expand Up @@ -108,7 +110,8 @@ public void testWriteAndReadGcsWithGrpc() throws IOException {

// Write a test file in a bucket with gRPC enabled.
String tempLocationWithGrpc = options.getTempRoot() + "/temp";
String filename = String.format(outputPattern, tempLocationWithGrpc, new Date());
String filename =
String.format(outputPattern, tempLocationWithGrpc, LocalDateTime.now(ZoneId.of("UTC")));
writeGcsTextFile(gcsUtil, filename, testContent);

// Read the test file back and verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private Future<List<List<String>>> runQueryInBackground(String[] args) {
});
}

@SuppressWarnings("JavaUtilDate")
private long convertTimestampToMillis(String timestamp) throws ParseException {
return dateFormat.parse(timestamp).getTime();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
import com.google.api.services.bigquery.model.TableSchema;
import com.google.cloud.bigquery.storage.v1.DataFormat;
import java.nio.ByteBuffer;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -102,7 +103,9 @@ public class BigQueryHllSketchCompatibilityIT {
TestPipeline.testingPipelineOptions().as(ApplicationNameOptions.class);
APP_NAME = options.getAppName();
PROJECT_ID = options.as(GcpOptions.class).getProject();
DATASET_ID = String.format("zetasketch_%tY_%<tm_%<td_%<tH_%<tM_%<tS_%<tL", new Date());
DATASET_ID =
String.format(
"zetasketch_%tY_%<tm_%<td_%<tH_%<tM_%<tS_%<tL", LocalDateTime.now(ZoneId.of("UTC")));
BIGQUERY_CLIENT = BigqueryClient.getClient(APP_NAME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void copy(AzfsResourceId sourcePath, AzfsResourceId destinationPath) throws IOEx

@VisibleForTesting
/** Generate an SAS Token if the user did not provide one through pipeline options */
@SuppressWarnings("JavaUtilDate")
String generateSasToken() throws IOException {
if (!Strings.isNullOrEmpty(options.getSasToken())) {
return options.getSasToken();
Expand Down
Loading
Loading