[jcifs] FIle being kept upon until +/- 20 seconds after I close its InputStream

Vincent Partington vpartington at xebialabs.com
Wed Jan 25 09:41:56 MST 2012


Hi there,

When I run the program below, the file I am reading is being kept upon +/- 20 seconds after the close() method has been invoked. This means that it cannot be accessed by other files, e.g. executables I run on that Windows box.

public void shouldReadFile() throws IOException {

SmbFile file = new SmbFile("smb://Administrator:secret@win-s2008r2/C$/windows/temp/overthere-20120125T170658757.tmp/large.dat");

byte[] largeFileContentsRead = new byte[1 * 1024 * 1024];

InputStream in = file.getInputStream();

try {

ByteStreams.readFully(in, largeFileContentsRead);

} finally {

in.close();

}

System.out.println("Done!");

}

For about twenty seconds after close() is called, the following can be seen on the target machine:
PS C:\Users\Administrator\desktop> .\handle.exe large

Handle v3.46
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com

System             pid: 4      type: File          31A4: C:\Windows\Temp\overthere-20120125T170658757.tmp\large.dat

Also netstat is reporting that there is still a connection:
C:\Windows\Temp>netstat

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    172.16.172.179:445     TIMMY:51613            ESTABLISHED


I have been able to track this down to the transport thread that is still working on that connection until it receives a socket timeout and closes itself "hard". But I have no idea what is causing that timeout. Does anybody have any what is going on? This happens with Jcifs 1.3.3 and 1.3.17.

BTW, when I write to a file this does not happen!

Thanks in advance! Regards, Vincent.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20120125/559d2a56/attachment.html>


More information about the jCIFS mailing list