I have a problem with a scheduled Java agent leaving files open, and am wondering if there’s any way to drop the file handles with code in another agent.
At the start of a run, the agent opens two file streams, like this:
inFS=new FileInputStream(filepath1);
outFS=new FileOutputStream(filepath2,false);
(Note that filepath1 and filepath2 were previously set to the full paths of files which already exist on the server.)
Then, if it terminates normally, the files are closed with these lines:
inFS.close();
outFS.close();
Trouble is, with the current server setup, the agent sometimes runs for too long and gets killed by the agent manager. This results in the files being left open, so no other processes can access them. The next time the agent runs, it dies with the exception “File is in use by another program” when attempting to open the first file.
Each time this happens, I can get someone with server admin access to fix the problem by restarting the amgr task, but this usually means waiting a while until an administrator is available.
Does anyone know of any code I can run (Java or LotusScript) to fix the problem without restarting amgr?