github-advanced-security[bot] commented on code in PR #19387:
URL: https://github.com/apache/druid/pull/19387#discussion_r3157542487
##########
processing/src/test/java/org/apache/druid/java/util/common/FileUtilsTest.java:
##########
@@ -241,48 +239,49 @@
null
);
- Assert.assertEquals(data.length(), result);
- Assert.assertEquals(data,
StringUtils.fromUtf8(Files.readAllBytes(dstFile.toPath())));
+ Assertions.assertEquals(data.length(), result);
+ Assertions.assertEquals(data,
StringUtils.fromUtf8(Files.readAllBytes(dstFile.toPath())));
}
@Test
public void testLinkOrCopy1() throws IOException
{
// Will be a LINK.
- final File fromFile = temporaryFolder.newFile();
- final File toDir = temporaryFolder.newFolder();
+ final File fromFile = File.createTempFile("from", null, temporaryFolder);
+ final File toDir = new File(temporaryFolder, "toDir");
+ toDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testLinkOrCopy1 ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11143)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -86,10 +87,11 @@
@Test
public void testColumnSerializedSizeExceedsMaximum() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testColumnSerializedSizeExceedsMaximum ignores exceptional return
value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11146)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -99,23 +101,26 @@
}
}
- @Test(expected = ISE.class)
+ @Test
public void testExceptionForUnClosedFiles() throws Exception
{
- File baseDir = folder.newFolder("base");
-
- try (FileSmoosher smoosher = new FileSmoosher(baseDir, 21)) {
- for (int i = 0; i < 19; ++i) {
- final SegmentFileChannel writer =
smoosher.addWithChannel(StringUtils.format("%d", i), 4);
- writer.write(ByteBuffer.wrap(Ints.toByteArray(i)));
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
+ Assertions.assertThrows(ISE.class, () -> {
+ try (FileSmoosher smoosher = new FileSmoosher(baseDir, 21)) {
+ for (int i = 0; i < 19; ++i) {
+ final SegmentFileChannel writer =
smoosher.addWithChannel(StringUtils.format("%d", i), 4);
+ writer.write(ByteBuffer.wrap(Ints.toByteArray(i)));
+ }
}
- }
+ });
}
@Test
public void testWhenFirstWriterClosedAtTheEnd() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testWhenFirstWriterClosedAtTheEnd ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11148)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -173,64 +180,66 @@
}
File[] files = baseDir.listFiles();
- Assert.assertNotNull(files);
+ Assertions.assertNotNull(files);
Arrays.sort(files);
- Assert.assertEquals(6, files.length); // 4 smoosh files and 1 meta file
+ Assertions.assertEquals(6, files.length); // 4 smoosh files and 1 meta file
for (int i = 0; i < 4; ++i) {
- Assert.assertEquals(FileSmoosher.makeChunkFile(baseDir, i), files[i]);
+ Assertions.assertEquals(FileSmoosher.makeChunkFile(baseDir, i),
files[i]);
}
- Assert.assertEquals(FileSmoosher.metaFile(baseDir), files[files.length -
1]);
+ Assertions.assertEquals(FileSmoosher.metaFile(baseDir), files[files.length
- 1]);
try (SmooshedFileMapper mapper = SmooshedFileMapper.load(baseDir)) {
for (int i = 0; i < 20; ++i) {
ByteBuffer buf = mapper.mapFile(StringUtils.format("%d", i));
- Assert.assertEquals(0, buf.position());
- Assert.assertEquals(4, buf.remaining());
- Assert.assertEquals(4, buf.capacity());
- Assert.assertEquals(i, buf.getInt());
+ Assertions.assertEquals(0, buf.position());
+ Assertions.assertEquals(4, buf.remaining());
+ Assertions.assertEquals(4, buf.capacity());
+ Assertions.assertEquals(i, buf.getInt());
}
}
}
@Test
public void testBehaviorWhenReportedSizesSmall() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
try (FileSmoosher smoosher = new FileSmoosher(baseDir, 21)) {
boolean exceptionThrown = false;
try (final SegmentFileChannel writer = smoosher.addWithChannel("1", 2)) {
writer.write(ByteBuffer.wrap(Ints.toByteArray(1)));
}
catch (ISE e) {
- Assert.assertTrue(e.getMessage().contains("Liar!!!"));
+ Assertions.assertTrue(e.getMessage().contains("Liar!!!"));
exceptionThrown = true;
}
- Assert.assertTrue(exceptionThrown);
+ Assertions.assertTrue(exceptionThrown);
File[] files = baseDir.listFiles();
- Assert.assertNotNull(files);
- Assert.assertEquals(1, files.length);
+ Assertions.assertNotNull(files);
+ Assertions.assertEquals(1, files.length);
}
}
@Test
public void testDeterministicFileUnmapping() throws IOException
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testDeterministicFileUnmapping ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11152)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -175,10 +178,12 @@
@Test
public void testSomeValuesByteBuffersBigEndian() throws IOException
{
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValuesByteBuffersBigEndian ignores exceptional return value
of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11159)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -175,10 +178,12 @@
@Test
public void testSomeValuesByteBuffersBigEndian() throws IOException
{
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
final FileSmoosher smoosher = new FileSmoosher(tmpFile);
- final File tmpFile2 = tempFolder.newFolder();
+ final File tmpFile2 = new File(tempFolder, "dir2");
+ tmpFile2.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValuesByteBuffersBigEndian ignores exceptional return value
of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11160)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -156,15 +162,16 @@
@Test
public void testBehaviorWhenReportedSizesLargeAndExceptionIgnored() throws
Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testBehaviorWhenReportedSizesLargeAndExceptionIgnored ignores
exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11150)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -43,17 +42,18 @@
*/
public class SmooshedFileMapperTest
{
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
+ @TempDir
+ public File folder;
@Test
public void testSanity() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSanity ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11144)
##########
processing/src/test/java/org/apache/druid/java/util/metrics/cgroups/CpuSetV2Test.java:
##########
@@ -33,18 +32,20 @@
public class CpuSetV2Test
{
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
private File cgroupDir;
private File procDir;
private CgroupDiscoverer discoverer;
- @Before
+ @BeforeEach
public void setUp() throws IOException
{
- cgroupDir = temporaryFolder.newFolder();
- procDir = temporaryFolder.newFolder();
+ cgroupDir = new File(temporaryFolder, "cgroup");
+ cgroupDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method setUp ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11153)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -64,7 +64,8 @@
@Test
public void testWhenFirstWriterClosedInTheMiddle() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testWhenFirstWriterClosedInTheMiddle ignores exceptional return value
of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11145)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -99,23 +101,26 @@
}
}
- @Test(expected = ISE.class)
+ @Test
public void testExceptionForUnClosedFiles() throws Exception
{
- File baseDir = folder.newFolder("base");
-
- try (FileSmoosher smoosher = new FileSmoosher(baseDir, 21)) {
- for (int i = 0; i < 19; ++i) {
- final SegmentFileChannel writer =
smoosher.addWithChannel(StringUtils.format("%d", i), 4);
- writer.write(ByteBuffer.wrap(Ints.toByteArray(i)));
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testExceptionForUnClosedFiles ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11147)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -136,7 +141,8 @@
public void testWhenWithPathyLookingFileNames() throws Exception
{
String prefix = "foo/bar/";
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testWhenWithPathyLookingFileNames ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11149)
##########
processing/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java:
##########
@@ -173,64 +180,66 @@
}
File[] files = baseDir.listFiles();
- Assert.assertNotNull(files);
+ Assertions.assertNotNull(files);
Arrays.sort(files);
- Assert.assertEquals(6, files.length); // 4 smoosh files and 1 meta file
+ Assertions.assertEquals(6, files.length); // 4 smoosh files and 1 meta file
for (int i = 0; i < 4; ++i) {
- Assert.assertEquals(FileSmoosher.makeChunkFile(baseDir, i), files[i]);
+ Assertions.assertEquals(FileSmoosher.makeChunkFile(baseDir, i),
files[i]);
}
- Assert.assertEquals(FileSmoosher.metaFile(baseDir), files[files.length -
1]);
+ Assertions.assertEquals(FileSmoosher.metaFile(baseDir), files[files.length
- 1]);
try (SmooshedFileMapper mapper = SmooshedFileMapper.load(baseDir)) {
for (int i = 0; i < 20; ++i) {
ByteBuffer buf = mapper.mapFile(StringUtils.format("%d", i));
- Assert.assertEquals(0, buf.position());
- Assert.assertEquals(4, buf.remaining());
- Assert.assertEquals(4, buf.capacity());
- Assert.assertEquals(i, buf.getInt());
+ Assertions.assertEquals(0, buf.position());
+ Assertions.assertEquals(4, buf.remaining());
+ Assertions.assertEquals(4, buf.capacity());
+ Assertions.assertEquals(i, buf.getInt());
}
}
}
@Test
public void testBehaviorWhenReportedSizesSmall() throws Exception
{
- File baseDir = folder.newFolder("base");
+ File baseDir = new File(folder, "base");
+ baseDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testBehaviorWhenReportedSizesSmall ignores exceptional return value
of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11151)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -41,17 +40,19 @@
public class CompressedVariableSizeBlobColumnTest
{
- @Rule
- public final TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
@Test
public void testSomeValues() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
final FileSmoosher smoosher = new FileSmoosher(tmpFile);
- final File tmpFile2 = tempFolder.newFolder();
+ final File tmpFile2 = new File(tempFolder, "dir2");
+ tmpFile2.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValues ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11156)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -41,17 +40,19 @@
public class CompressedVariableSizeBlobColumnTest
{
- @Rule
- public final TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
@Test
public void testSomeValues() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValues ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11155)
##########
processing/src/test/java/org/apache/druid/java/util/metrics/cgroups/CpuSetV2Test.java:
##########
@@ -33,18 +32,20 @@
public class CpuSetV2Test
{
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
private File cgroupDir;
private File procDir;
private CgroupDiscoverer discoverer;
- @Before
+ @BeforeEach
public void setUp() throws IOException
{
- cgroupDir = temporaryFolder.newFolder();
- procDir = temporaryFolder.newFolder();
+ cgroupDir = new File(temporaryFolder, "cgroup");
+ cgroupDir.mkdir();
+ procDir = new File(temporaryFolder, "proc");
+ procDir.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method setUp ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11154)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -112,10 +113,12 @@
public void testSomeValuesByteBuffers() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
final FileSmoosher smoosher = new FileSmoosher(tmpFile);
- final File tmpFile2 = tempFolder.newFolder();
+ final File tmpFile2 = new File(tempFolder, "dir2");
+ tmpFile2.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValuesByteBuffers ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11158)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -238,10 +243,12 @@
public void testLongs() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
final FileSmoosher smoosher = new FileSmoosher(tmpFile);
- final File tmpFile2 = tempFolder.newFolder();
+ final File tmpFile2 = new File(tempFolder, "dir2");
+ tmpFile2.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testLongs ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11162)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -112,10 +113,12 @@
public void testSomeValuesByteBuffers() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testSomeValuesByteBuffers ignores exceptional return value of
File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11157)
##########
processing/src/test/java/org/apache/druid/segment/data/CompressedVariableSizeBlobColumnTest.java:
##########
@@ -238,10 +243,12 @@
public void testLongs() throws IOException
{
// value sizes increase until they span at least 3 pages of compressed
buffers
- final File tmpFile = tempFolder.newFolder();
+ final File tmpFile = new File(tempFolder, "dir1");
+ tmpFile.mkdir();
Review Comment:
## CodeQL / Ignored error status of call
Method testLongs ignores exceptional return value of File.mkdir.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11161)
--
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]