[jcifs] [solved] Having problem with simply connecting with
release 1.2.9
Michael B Allen
mba2000 at ioplex.com
Mon Apr 24 19:36:51 GMT 2006
On Mon, 24 Apr 2006 15:04:20 -0400
Michael B Allen <mba2000 at ioplex.com> wrote:
> > smbout = new PrintStream(new SmbFileOutputStream(file, true));
> > smbout.println("This is a test - " + new java.util.Date().toString());
> > smbout.close();
> >
> > But with release 1.2.9, I get:
> >
> > java.lang.NullPointerException
> > at jcifs.smb.SmbComSessionSetupAndX.writeParameterWordsWireFormat(SmbComSessionSetupAndX.java:58)
I found the bug. In jcifs/smb/SmbFileOutputStream.java add a catch and
rethrow for an SmbAuthException as shown in the corrected code here:
123 SmbFileOutputStream( SmbFile file, boolean append, int openFlags ) throws SmbException, MalformedURLExc eption, UnknownHostException {
124 this.file = file;
125 this.append = append;
126 this.openFlags = openFlags;
127 if( append ) {
128 try {
129 fp = file.length();
130 } catch( SmbAuthException sae ) {
131 throw sae;
132 } catch( SmbException se ) {
133 fp = 0L;
134 }
The problem was that if the authentication failed (e.g. incorrect
password) and the file.length() call triggered authentication, the
first authentication would be silently ignored causing an inappropriate
second attempt.
I'll add this to The List but for now either fix jcifs yourself, use the
correct credentials, or add a file.length() before the SmbFileOutputStream
constructor so that the auth is performed in advance thereby not catching
and ignoring any failure.
Thanks for the report,
Mike
More information about the jcifs
mailing list