This is an automated email from the ASF dual-hosted git repository.
yashmayya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 0a5d4fe4d9d Fix null-safety and contract violations in HadoopPinotFS
(#18457)
0a5d4fe4d9d is described below
commit 0a5d4fe4d9dd6f3a39b3f9c8998dcf7a50899454
Author: Akanksha kedia <[email protected]>
AuthorDate: Tue May 12 05:11:56 2026 +0530
Fix null-safety and contract violations in HadoopPinotFS (#18457)
---
.../pinot/plugin/filesystem/HadoopPinotFS.java | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git
a/pinot-plugins/pinot-file-system/pinot-hdfs/src/main/java/org/apache/pinot/plugin/filesystem/HadoopPinotFS.java
b/pinot-plugins/pinot-file-system/pinot-hdfs/src/main/java/org/apache/pinot/plugin/filesystem/HadoopPinotFS.java
index 37ff660e0c0..be2aa28ec61 100644
---
a/pinot-plugins/pinot-file-system/pinot-hdfs/src/main/java/org/apache/pinot/plugin/filesystem/HadoopPinotFS.java
+++
b/pinot-plugins/pinot-file-system/pinot-hdfs/src/main/java/org/apache/pinot/plugin/filesystem/HadoopPinotFS.java
@@ -183,6 +183,9 @@ public class HadoopPinotFS extends BasePinotFS {
throws IOException {
// _hadoopFS.listFiles(path, false) will not return directories as files,
thus use listStatus(path) here.
FileStatus[] files = _hadoopFS.listStatus(path);
+ if (files == null) {
+ throw new IOException("FileSystem.listStatus() returned null for path: "
+ path);
+ }
for (FileStatus file : files) {
visitor.accept(file);
if (file.isDirectory() && recursive) {
@@ -234,23 +237,15 @@ public class HadoopPinotFS extends BasePinotFS {
}
@Override
- public boolean isDirectory(URI uri) {
- try {
- return _hadoopFS.getFileStatus(new Path(uri)).isDirectory();
- } catch (IOException e) {
- LOGGER.error("Could not get file status for {}", uri, e);
- throw new RuntimeException(e);
- }
+ public boolean isDirectory(URI uri)
+ throws IOException {
+ return _hadoopFS.getFileStatus(new Path(uri)).isDirectory();
}
@Override
- public long lastModified(URI uri) {
- try {
- return _hadoopFS.getFileStatus(new Path(uri)).getModificationTime();
- } catch (IOException e) {
- LOGGER.error("Could not get file status for {}", uri, e);
- throw new RuntimeException(e);
- }
+ public long lastModified(URI uri)
+ throws IOException {
+ return _hadoopFS.getFileStatus(new Path(uri)).getModificationTime();
}
@Override
@@ -258,8 +253,9 @@ public class HadoopPinotFS extends BasePinotFS {
throws IOException {
Path path = new Path(uri);
if (!exists(uri)) {
- FSDataOutputStream fos = _hadoopFS.create(path);
- fos.close();
+ try (FSDataOutputStream fos = _hadoopFS.create(path)) {
+ // create an empty file; stream closed by try-with-resources
+ }
} else {
_hadoopFS.setTimes(path, System.currentTimeMillis(), -1);
}
@@ -307,7 +303,9 @@ public class HadoopPinotFS extends BasePinotFS {
@Override
public void close()
throws IOException {
- _hadoopFS.close();
+ if (_hadoopFS != null) {
+ _hadoopFS.close();
+ }
super.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]