github-advanced-security[bot] commented on code in PR #19920:
URL: https://github.com/apache/druid/pull/19920#discussion_r3740039833


##########
indexing-service/src/test/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogsTest.java:
##########
@@ -121,50 +109,57 @@
   @Test
   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.asCharSink(logFile, StandardCharsets.UTF_8).write("blah");
+    final File tmpDir = temporaryFolder;
+    try {
+      final File logDir = new File(tmpDir, "druid/logs");
+      final File logFile = new File(tmpDir, "log");
+      Files.asCharSink(logFile, StandardCharsets.UTF_8).write("blah");
 
-    if (!tmpDir.setWritable(false)) {
-      throw new RuntimeException("failed to make tmp dir read-only");
-    }
+      if (!tmpDir.setWritable(false)) {
+        throw new RuntimeException("failed to make tmp dir read-only");
+      }
 
-    final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir));
+      final TaskLogs taskLogs = new FileTaskLogs(new 
FileTaskLogsConfig(logDir));
 
-    expectedException.expect(IOException.class);
-    expectedException.expectMessage("Cannot create directory");
-    taskLogs.pushTaskLog("foo", logFile);
+      final IOException exception = Assertions.assertThrows(
+          IOException.class,
+          () -> taskLogs.pushTaskLog("foo", logFile)
+      );
+      Assertions.assertTrue(exception.getMessage().contains("Cannot create 
directory"));
+    }
+    finally {
+      tmpDir.setWritable(true);

Review Comment:
   ## CodeQL / Ignored error status of call
   
   Method testPushTaskLogDirCreationFails ignores exceptional return value of 
File.setWritable.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11744)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to