Re: jcifs eats InterruptedException
Michael B Allen <[email protected]> Sat, 14 Feb 2015 22:51:37 -0500
| Newsgroups | gmane.network.samba.java |
|---|---|
| Message-ID | <CAGMFw4gsGPcL=pF_4aWxt+cLjwG+RCmDm-S73g3wJGTPCMtPxA@mail.gmail.com> |
On Fri, Feb 6, 2015 at 3:23 AM, Igor Golikov <[email protected]> wrote: > Hi all, > > I found that it is impossible to interrupt thread that performs some > operations using jcifs. > > Here is an example > > java.lang.Object.wait(Object.java:-2) > java.lang.Object.wait(Object.java:503) > jcifs.UniAddress.lookupServerOrWorkgroup(UniAddress.java:176) > <----------- part A > jcifs.UniAddress.getAllByName(UniAddress.java:290) > jcifs.UniAddress.getByName(UniAddress.java:245) <----------- part B > jcifs.smb.Dfs.getTrustedDomains(Dfs.java:62) > jcifs.smb.Dfs.resolve(Dfs.java:167) > jcifs.smb.SmbFile.doConnect(SmbFile.java:902) > jcifs.smb.SmbFile.connect(SmbFile.java:954) > jcifs.smb.SmbFile.connect0(SmbFile.java:880) > jcifs.smb.SmbFile.open0(SmbFile.java:972) > jcifs.smb.SmbFile.open(SmbFile.java:1006) > jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:142) > jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:97) > jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:67) > > > Part A - replacing InterruptedException with UnknownHostException > ============================================ > ... > } catch( InterruptedException ie ) { > throw new UnknownHostException( name ); > } > ... > > > Part B - hiding UnknownHostException > ============================================ > ... > } catch (IOException ioe) { > if (log.level >= 3) > ioe.printStackTrace(log); > if (strictView && ioe instanceof SmbAuthException) { > throw (SmbAuthException)ioe; > } > } > ... > > > Why it hides InterruptedException? Hi Igor, Calling Thread.interrupt is a very dubious thing to do. I cannot recall *every* calling Thread.interrupt in all my years of writing Java code. JCIFS probably catches those because it might otherwise leave the client in a bad state. But I honestly don't recall the exact reason. That particular code is probably 10 years old. You might want to rephrase your issue and describe why you want to call Thread.interrupt in the first place. Mike -- Michael B Allen Java Active Directory Integration http://www.ioplex.com/