Are you running this on a multiprocessor machine? Just because this works 99.99% of the time, it sounds like the kind of multi-threading error I heard so much about at JavaOne last week.
Try marking the variable that holds the reference to your IFSFile object "volatile". Marking it so changes the JVM memory model contract. Most of the as400.access package does it's work on worker threads. Your thread blocks while the worker thread does its thing. When the worker thread returns, it releases your thread from the block. If the worker thread is setting the value of the reference, it might not actually be in the memory your thread is using at the time your thread accesses it. This is due to memory caching at each of the processors involved in the two threads.
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of David Gibbs
Sent: Tuesday, October 11, 2011 10:16 AM
To: Java Programming on and around the IBM i
Subject: Re: Null pointer on IFSFile delete?
On 10/11/2011 9:48 AM, Joe Pluta wrote:
David, I have no idea. I think this is the line that's failing:
ds = (ClientAccessDataStream) fd_.server_.sendAndReceive(req);
This would imply that either fd_ or fd_.server_ is null. fd_ cannot
be null or it would have failed earlier in the delete() method. In
fact, the delete() method calls fd_.connect(), which is supposed to
set the server_ value.
So the only way I can see this happening is if you somehow lost the
connection for your file and were unable to re-establish it. Are you
doing this delete immediately upon creating the IFS File object?
yeah, that's pretty much what was identified last time.
John E, the jt400 development lead, suggested updating the most current version of jt400.jar ... which I did. But the error manifested again. Unfortunately it's completely sporadic. The code in question will work fine for weeks and then fail for no apparent reason.
Against my better judgment, I've added a catch for npe when the delete is performed. I'd rather leave a file behind in the ifs than abort the process.
IBM i on Power - For when you can't afford to be out of business
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l
As an Amazon Associate we earn from qualifying purchases.