Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Java NIO.2 APIs we launched in JDK 7: https://blogs.oracle.com/javamagazine/post/path-files-input-output. Currently multiple places of Kafka code base use File handling provided by old Java IO which can be replaced with newer (& better) NIO.2 APIs.
The disadvantages of using the legacy File.io Java methods are described by the following blog: https://docs.oracle.com/javase/tutorial/essential/io/legacy.html. To summarize the disadvanatges from this article:
Prior to the Java SE 7 release, the java.io.File class was the mechanism used for file I/O, but it had several drawbacks.
- Many methods didn't throw exceptions when they failed, so it was impossible to obtain a useful error message. For example, if a file deletion failed, the program would receive a "delete fail" but wouldn't know if it was because the file didn't exist, the user didn't have permissions, or there was some other problem.
- The rename method didn't work consistently across platforms.
- There was no real support for symbolic links.
- More support for metadata was desired, such as file permissions, file owner, and other security attributes.
- Accessing file metadata was inefficient.
- Many of the File methods didn't scale. Requesting a large directory listing over a server could result in a hang. Large directories could also cause memory resource problems, resulting in a denial of service.
- It was not possible to write reliable code that could recursively walk a file tree and respond appropriately if there were circular symbolic links.
This Jira will consist of multiple smaller changes where we would replace one Java method per change from the Kafka code base.