github-advanced-security[bot] commented on code in PR #15236:
URL: https://github.com/apache/druid/pull/15236#discussion_r1369299160
##########
processing/src/test/java/org/apache/druid/java/util/common/FileUtilsTest.java:
##########
@@ -208,17 +212,13 @@
final File tmpDir = temporaryFolder.newFolder();
final File testDirectory = new File(tmpDir, "test");
tmpDir.setWritable(false);
- try {
- final IOException e = Assert.assertThrows(IOException.class, () ->
FileUtils.mkdirp(testDirectory));
+ final IOException e = Assert.assertThrows(IOException.class, () ->
FileUtils.mkdirp(testDirectory));
- MatcherAssert.assertThat(
- e,
-
ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Cannot create
directory"))
- );
- }
- finally {
- tmpDir.setWritable(true);
- }
+ MatcherAssert.assertThat(
+ e,
+ ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString("Cannot
create directory"))
+ );
+ tmpDir.setWritable(true);
Review Comment:
## Ignored error status of call
Method testMkdirpCannotCreateInNonWritableDirectory ignores exceptional
return value of File.setWritable.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5926)
##########
processing/src/test/java/org/apache/druid/java/util/common/FileUtilsTest.java:
##########
@@ -159,23 +165,19 @@
public void testCreateTempDirUnwritableBase() throws IOException
{
final File baseDir = FileUtils.createTempDir();
+ final String oldJavaTmpDir = System.getProperty("java.io.tmpdir");
try {
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("java.io.tmpdir (" + baseDir + ") is not
writable");
-
- final String oldJavaTmpDir = System.getProperty("java.io.tmpdir");
- try {
- System.setProperty("java.io.tmpdir", baseDir.getPath());
- baseDir.setWritable(false);
- FileUtils.createTempDir();
- }
- finally {
- System.setProperty("java.io.tmpdir", oldJavaTmpDir);
- }
+
+ System.setProperty("java.io.tmpdir", baseDir.getPath());
+ baseDir.setWritable(false);
Review Comment:
## Ignored error status of call
Method testCreateTempDirUnwritableBase ignores exceptional return value of
File.setWritable.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5923)
--
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]