Search code examples
javajava-iosambasmbjava.nio.file

What would I get using Java File.delete() with UNC path if the server response time out


I have a rather theoritical question for you.

What would happen if one calls java.io.File#delete() using a UNC path i.e. new File("\192.168.10.10\MyShare\myFile.txt").delete() and the underlying SMB_COM_DELETE request reaches the SMB server but the SMB_COM_DELETE_RESPONSE does not reach the caller back for some reason (network failure, firewall or whatever)? I would expect the java call to time out after few seconds but... do you know how many? Do you know if one would get an exception of some kind? Is this configurable? What if I use Files.delete(), would that make any difference?

I couldn't find anything in the java.io.File javadoc for UNC notation other than that it's supported.

I would be very glad if anyone could answer this

Thanks!


Solution

  • I think the answer is 20-60 seconds, depending on your software, and version of Windows.

    I don't think java or the JVM is in charge of doing what you're asking, but rather in the implementation of the JVM, the deletion of this file would be delegated to an OS level library which would do all of the SMB stuff. So in this case, your question about timeout isn't about the java library in question, but probably about whatever library implements the SMB protocol.

    And the answer to that question is "it depends on which SMB library we're talking about". The link above provides some general timeout parameters for various combinations of Windows, but they look to me to be all over the map. So I think a safe range based on that data is 20 - 60 seconds.