I only want to tolerate 451 if it occurs at FTPClient:3836, but not if it occurs elsewhere, e.g. at FTPClient:3790. So catching the FTPException won't really solve my problem.
I've managed to build edtFTPj. I edited it so that I can introduce an own, overridden FTPClient in FileTransferClient. However, subclassing and overriding FTPClient won't work, because the dir()-method accesses private members ("cancelTransfer" and "lister") and methods ("closeDataSocket()") that are not available to my subclassed FTPClient.
Even if if it were possible (e.g. by adding getters to FTPClient), the solution with subclassing and overriding has several drawbacks:
1. The solution duplicates a lot of code (dir() is about 90 line long!). Upgrading edtFTPj in future becomes error-prone, because we need to verify that the duplicated code in our FTPClient still matches the code in the new edtFTPj's FTPClient.
2. FTPClient.dir() is private, so it's necessary to overide all callers of dir() aswell (dir(String, boolean), dirDetails(String,DirectoryListCallback)) to call the overridden version of dir().
3. Every other user of edtFTPj potentially has the same problem slumbering when reading large directories with an aborting DirectoryListCallback.
Dealing with 451 in FTPClient directly would be a much simpler, sustainable solution.