[jcifs] UnknownHostException doesn't throw UnknownHostException

Michael B. Allen miallen at eskimo.com
Sun Oct 27 15:50:15 EST 2002

On Sun, 27 Oct 2002 00:34:22 -0400
Matthew Tippett <matthew.tippett at sympatico.ca> wrote:

> >>Currently SmbFile is documented (and does) (deep within the bowels of 
> >>getHostByName()) throw UnknownHostException.
> >>
> >>The API however doesn't have the throw as part of of the constructor 
> >>definition.
> > 
> > 
> > With   0.7.0b5  SmbFile  constructors  do  not  throw  UnknownHostException
> > (however  there  is  a very small possibilty it might go back in before the
> > betas  are  done  depending  on  how  outstanding URL handling concerns are
> > resolved). 
> Exception in thread "main" java.net.UnknownHostException: 
> ..__MSBROWSE__.<01>
> 	at jcifs.netbios.NbtAddress.doNameQuery(NbtAddress.java:328)
> 	at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:430)
> 	at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:411)
> 	at jcifs.smb.SmbFile.<init>(SmbFile.java:416)
> 	at jcifs.smb.SmbFile.<init>(SmbFile.java:352)
> 	at CIFSCrawler.main(CIFSCrawler.java:39)
> Since UnknownHostException is a checked exception, how do you suggest 
> handling the above condition when there is no LMB on the subnet I am 
> scanning?

You're comparing old code to new API documentation. You should be seeing:

[miallen at nano jcifs]$ java -Djcifs.properties=../miallen.prp List smb://
Exception in thread "main" jcifs.smb.SmbException: Unknown host: ..__MSBROWSE__.<01>
        at jcifs.smb.SmbFile.connect0(SmbFile.java:469)
        at jcifs.smb.SmbFile.list(SmbFile.java:1034)
        at List.main(List.java:31)

> I can do catch-all style exceptions, but I would prefer to catch it 
> explicitely, which I can't because it isn't in the throws.
> Matt

A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 

More information about the jcifs mailing list