Skip to content
Merged
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
1 change: 1 addition & 0 deletions codestyle/druid-forbidden-apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ com.google.common.collect.Sets#newLinkedHashSet() @ Create java.util.LinkedHashS
com.google.common.collect.Sets#newTreeSet() @ Create java.util.TreeSet directly
com.google.common.collect.Sets#newTreeSet(java.util.Comparator) @ Create java.util.TreeSet directly
com.google.common.io.Files#createTempDir() @ Use org.apache.druid.java.util.common.FileUtils.createTempDir()
com.google.common.io.Files#write(java.lang.CharSequence, java.io.File, java.nio.charset.Charset) @ Use com.google.common.io.Files.asCharSink(to, charset).write(from) instead.
java.io.File#mkdirs() @ Use org.apache.druid.java.util.common.FileUtils.mkdirp instead
java.io.File#toURL() @ Use java.io.File#toURI() and java.net.URI#toURL() instead
java.lang.String#matches(java.lang.String) @ Use startsWith(), endsWith(), contains(), or compile and cache a Pattern explicitly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void testGetSplitsUsingDefaultSupplier() throws Exception
{
// Use the builtin supplier, reading from the local filesystem, rather than testFormatter.
final File tmpFile = temporaryFolder.newFile("something:with:colons");
Files.write("dummy", tmpFile, StandardCharsets.UTF_8);
Files.asCharSink(tmpFile, StandardCharsets.UTF_8).write("dummy");

final ImmutableList<WindowedDataSegment> mySegments = ImmutableList.of(
WindowedDataSegment.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testSimple() throws Exception
try {
final File logDir = new File(tmpDir, "druid/logs");
final File logFile = new File(tmpDir, "log");
Files.write("blah", logFile, StandardCharsets.UTF_8);
Files.asCharSink(logFile, StandardCharsets.UTF_8).write("blah");
final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir));
taskLogs.pushTaskLog("foo", logFile);

Expand All @@ -85,7 +85,7 @@ public void testSimpleReport() throws Exception
final String taskId = "myTask";
final TestTaskReport testReport = new TestTaskReport(taskId);
final String testReportString = mapper.writeValueAsString(TaskReport.buildTaskReports(testReport));
Files.write(testReportString, reportFile, StandardCharsets.UTF_8);
Files.asCharSink(reportFile, StandardCharsets.UTF_8).write(testReportString);

final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir));
taskLogs.pushTaskReports("foo", reportFile);
Expand All @@ -107,7 +107,7 @@ public void testSimpleStatus() throws Exception
final String taskId = "myTask";
final TaskStatus taskStatus = TaskStatus.success(taskId);
final String taskStatusString = mapper.writeValueAsString(taskStatus);
Files.write(taskStatusString, statusFile, StandardCharsets.UTF_8);
Files.asCharSink(statusFile, StandardCharsets.UTF_8).write(taskStatusString);

final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir));
taskLogs.pushTaskStatus(taskId, statusFile);
Expand All @@ -124,7 +124,7 @@ public void testPushTaskLogDirCreationFails() throws Exception
final File tmpDir = temporaryFolder.newFolder();
final File logDir = new File(tmpDir, "druid/logs");
final File logFile = new File(tmpDir, "log");
Files.write("blah", logFile, StandardCharsets.UTF_8);
Files.asCharSink(logFile, StandardCharsets.UTF_8).write("blah");

if (!tmpDir.setWritable(false)) {
throw new RuntimeException("failed to make tmp dir read-only");
Expand All @@ -145,7 +145,7 @@ public void testKill() throws Exception
final File logFile = new File(tmpDir, "log");
final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir));

Files.write("log1content", logFile, StandardCharsets.UTF_8);
Files.asCharSink(logFile, StandardCharsets.UTF_8).write("log1content");
taskLogs.pushTaskLog("log1", logFile);
Assert.assertEquals("log1content", readLog(taskLogs, "log1", 0));

Expand All @@ -156,7 +156,7 @@ public void testKill() throws Exception
long time = (System.currentTimeMillis() / 1000) * 1000;
Assert.assertTrue(new File(logDir, "log1.log").lastModified() < time);

Files.write("log2content", logFile, StandardCharsets.UTF_8);
Files.asCharSink(logFile, StandardCharsets.UTF_8).write("log2content");
taskLogs.pushTaskLog("log2", logFile);
Assert.assertEquals("log2content", readLog(taskLogs, "log2", 0));
Assert.assertTrue(new File(logDir, "log2.log").lastModified() >= time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void testLogRemove() throws Exception
String logString = dateTime + "\t" + HOST + "\t" + "logString";

File oldLogFile = new File(logDir, "2000-01-01.log");
com.google.common.io.Files.write("testOldLogContent", oldLogFile, StandardCharsets.UTF_8);
com.google.common.io.Files.asCharSink(oldLogFile, StandardCharsets.UTF_8).write("testOldLogContent");
oldLogFile.setLastModified(new Date(0).getTime());
FileRequestLogger fileRequestLogger = new FileRequestLogger(
objectMapper,
Expand Down