<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hi there,</div>
<div><br>
</div>
<div>When I run the program below, the file I am reading is being kept upon +/- 20 seconds after the
<span style="font-family: Courier; ">close()</span> method has been invoked. This means that it cannot be accessed by other files, e.g. executables I run on that Windows box.</div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #921167">public</span>
<span style="color: #921167">void</span> shouldReadFile() <span style="color: #921167">
throws</span> IOException {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4726f9"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>SmbFile file =
</span><span style="color: #921167">new</span><span style="color: #000000"> SmbFile(</span>"smb://Administrator:secret@win-s2008r2/C$/windows/temp/overthere-20120125T170658757.tmp/large.dat"<span style="color: #000000">);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #921167">byte</span>[] largeFileContentsRead =
<span style="color: #921167">new</span> <span style="color: #921167">byte</span>[1 * 1024 * 1024];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>InputStream in = file.getInputStream();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #921167">try</span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>ByteStreams.readFully(in, largeFileContentsRead);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #921167"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>}
</span>finally<span style="color: #000000"> {</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>in.close();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>System.<span style="color: #211cc7">out</span>.println(<span style="color: #4726f9">"Done!"</span>);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"></span>}</p>
<div><br>
</div>
<div>For about twenty seconds after <span style="font-family: Courier; ">close()</span> is called, the following can be seen on the target machine:</div>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px;">
<div><span style="font-family: Courier; ">PS C:\Users\Administrator\desktop> .\handle.exe large</span></div>
<div><span style="font-family: Courier; "><br>
</span></div>
<div><span style="font-family: Courier; ">Handle v3.46</span></div>
<div><span style="font-family: Courier; ">Copyright (C) 1997-2011 Mark Russinovich</span></div>
<div><span style="font-family: Courier; ">Sysinternals - www.sysinternals.com</span></div>
<div><span style="font-family: Courier; "><br>
</span></div>
<div><span style="font-family: Courier; ">System             pid: 4      type: File          31A4: C:\Windows\Temp\overthere-20120125T170658757.tmp\large.dat</span><span style="font-family: Courier; "> </span></div>
</blockquote>
<div> </div>
<div>Also <span style="font-family: Courier; ">netstat</span> is reporting that there is still a connection:</div>
<div>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px;">
<div><span style="font-family: Courier; ">C:\Windows\Temp>netstat</span></div>
<div><span style="font-family: Courier; "><br>
</span></div>
<div><span style="font-family: Courier; ">Active Connections</span></div>
<div><span style="font-family: Courier; "><br>
</span></div>
<div><span style="font-family: Courier; ">  Proto  Local Address          Foreign Address        State</span></div>
<div><span style="font-family: Courier; ">  TCP    172.16.172.179:445     TIMMY:51613            ESTABLISHED</span></div>
</blockquote>
</div>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px;">
<div><br>
</div>
</blockquote>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>BTW, when I <i>write</i> to a file this does <i>not</i> happen!</div>
<div><br>
</div>
<div>Thanks in advance! Regards, Vincent.</div>
<div><br>
</div>
</body>
</html>