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

Michael B Allen ioplex at gmail.com
Wed Jan 25 13:18:16 MST 2012


Hi Vincent,

SmbFile shares it's InputStream. Use SmbFileInputStream instead. Then
close() will really close the file.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/

PS: Note that you should not use credentials in the URL for anything
other than trivial testing. The NtlmPasswordAuthentication object
should be used to manage credentials.

On Wed, Jan 25, 2012 at 11:41 AM, Vincent Partington
<vpartington at xebialabs.com> wrote:
> 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.
>


More information about the jCIFS mailing list