Re: NullPointerException at listFiles

Michael B Allen <[email protected]>
Newsgroups gmane.network.samba.java
Message-ID <CAGMFw4isLTJ4QLOCVMj5VUWBsfJBkXVWthCQSm4TED_tW+bcBw@mail.gmail.com>
2012/1/28  <[email protected]>:
> Hi All,
>
> I recursively use SmbFile#listFiles method to access all folder and files.
> At first, the method correctly works.
> However I have the NullPointerException in about 10 minutes.
>
> This problem may be network environment.
> But if you have any ideas to modify this problem by setting up JCIFS property,
> teach me how to use the way.
>
> <environment>
> JCIFS : 1.3.16
> Network access : using DFS
>
> <stacktrace>
> java.util.NullPointerException
> at jcifs.smb.Dfs.resolve(Dfs.java:169)
> at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:671)
> at jcifs.smb.SmbFile.send(SmbFile.java:773)
> at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1986)
> at jcifs.smb.SmbFile.doEnum(SmbFile.java:1738)
> at jcifs.smb.SmbFile.listFiles(SmbFile.java:1715)
> at jcifs.smb.SmbFile.listFiles(SmbFile.java:1704)

Hi Dora,

Does this help?

  http://jcifs.samba.org/jcifs-1.3.18b.jar

This looks like a logic error where the transport disconnects but
SmbFile is trying to reach down and touch something that is null
(tconHostName). Probably due to some other unrelated communications
error or more likely the transport just timed out. The above package
adds a check to help SmbFile know when the transport is disconnected
(so that it will re-open it appropriately). I was not able to
replicate this particular issue so please let us know if it actually
makes a difference.

Note that when crawling files, it's a good idea to do a
breadth-first-search with one file list that should be kept as small
as possible. If you do a typical depth-first-search you will end up
with multiple lists of potentially old paths. This is bound to result
in strange behavior and poor performance as you query a path and then
come back to it 10 minutes later only to find it is gone or the
transport to the server has been closed. Code should never throw an
NPE but a stale file list could be part of the problem you're seeing.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.