Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
None
-
None
-
None
-
Used a standalone to connect to Mainframes z/os system, later the code will be moved to unix box as part of web-project
Description
private OutputStream __storeFileStream(int command, String remote)
throws IOException
{
Socket socket;
if((socket = openDataConnection(command, remote)) == null)
return null;
OutputStream output = socket.getOutputStream();
if(__fileType == 0)
return new SocketOutputStream(socket, output);
}
This method in FTPClient.java is called by the method storeFileStream(String str). At line number 6 in the above mentioned method, it returns null when unable to open DataConnection which could be because of concurrent file access issues. In such cases instead of returning null, this method should throw an IOException like:
Socket socket;
if((socket = openDataConnection(command, remote)) == null) throw new IOException;
As of now in my code i have used a null check to avoid this. However i could not understand why an outputstream creation method will return a null reference and not throw an IOException. It was hard to believe that I was getting null pointer exception while getting an output stream reference.