You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by moslm <mo...@lastminute.de> on 2010/04/16 15:12:27 UTC
NPE in FileUtils.removeDir(FileUtils.java:126) on shutdown
I'm using CXF 2.2.5, running on Java 1.6 and Tomcat 6.18.
When the Tomcat server is stopped, we get always the following
NullPointerException:
INFO: Stopping Coyote HTTP/1.1 on http-8080
Exception in thread "Thread-14" java.lang.NullPointerException
at org.apache.cxf.helpers.FileUtils.removeDir(FileUtils.java:126)
at org.apache.cxf.helpers.FileUtils$1.run(FileUtils.java:75)
I did a little debugging:
During the first usage of CXF the FileUtils.getDefaultTempDir() is called.
It resolves the tmp-dir correctly. At the end the
"private static File defaultTempDir" is set to the right directory.
Then the method schedules the removal of the tmp-dir like this:
Thread hook = new Thread() {
@Override
public void run() {
removeDir(defaultTempDir);
}
};
Runtime.getRuntime().addShutdownHook(hook);
So far, so good. When stopping Tomcat (== stopping the JVM) the hook is
"fired".
The removeDir(defaultTempDir) is called. But "defaultTempDir" is 'null' and
in consequence
the NPE is thrown.
Any idea why the static defaultTempDir is lost when the ShutdownHooks are
fired? A Bug?
Thanks
Mos
--
View this message in context: http://old.nabble.com/NPE-in-FileUtils.removeDir%28FileUtils.java%3A126%29-on-shutdown-tp28266687p28266687.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: NPE in FileUtils.removeDir(FileUtils.java:126) on shutdown
Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 20 April 2010 9:40:51 am moslm wrote:
> Hi Daniel,
>
> thanks for the fix. Just verified it with the SNAPSHOT version and yes it
> works.
>
> Any schedule when 2.2.8 will be released?
Probably mid May or so. Maybe earlier. Depends on if we get patches and
such for a bunch of the other issues. :-)
I'd also like to get a new wss4j release in, but that requires some extra
coordination.
Dan
>
> Cheers
> Mos
>
> dkulp wrote:
> > On Friday 16 April 2010 9:12:27 am moslm wrote:
> >> I'm using CXF 2.2.5, running on Java 1.6 and Tomcat 6.18.
> >>
> >> When the Tomcat server is stopped, we get always the following
> >> NullPointerException:
> >>
> >> INFO: Stopping Coyote HTTP/1.1 on http-8080
> >> Exception in thread "Thread-14" java.lang.NullPointerException
> >>
> >> at org.apache.cxf.helpers.FileUtils.removeDir(FileUtils.java:126)
> >> at org.apache.cxf.helpers.FileUtils$1.run(FileUtils.java:75)
> >>
> >> I did a little debugging:
> >>
> >> During the first usage of CXF the FileUtils.getDefaultTempDir() is
> >> called.
> >> It resolves the tmp-dir correctly. At the end the
> >> "private static File defaultTempDir" is set to the right directory.
> >>
> >> Then the method schedules the removal of the tmp-dir like this:
> >> Thread hook = new Thread() {
> >>
> >> @Override
> >> public void run() {
> >>
> >> removeDir(defaultTempDir);
> >>
> >> }
> >>
> >> };
> >> Runtime.getRuntime().addShutdownHook(hook);
> >>
> >> So far, so good. When stopping Tomcat (== stopping the JVM) the hook is
> >> "fired".
> >> The removeDir(defaultTempDir) is called. But "defaultTempDir" is 'null'
> >> and
> >> in consequence
> >> the NPE is thrown.
> >>
> >> Any idea why the static defaultTempDir is lost when the ShutdownHooks
> >> are fired? A Bug?
> >
> > Hmm.. very strange. Maybe part of the classloader is GC'd before the
> > hook
> >
> > is set? Fairly easy to fix I think:
> > final File f2 = f;
> > Thread hook = new Thread() {
> >
> > @Override
> > public void run() {
> >
> > removeDir(f2);
> >
> > }
> >
> > };
> >
> > to make it not use the static and instead use an instance field for the
> > hook.
> > I'll commit that.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: NPE in FileUtils.removeDir(FileUtils.java:126) on shutdown
Posted by moslm <mo...@lastminute.de>.
Hi Daniel,
thanks for the fix. Just verified it with the SNAPSHOT version and yes it
works.
Any schedule when 2.2.8 will be released?
Cheers
Mos
dkulp wrote:
>
>
> On Friday 16 April 2010 9:12:27 am moslm wrote:
>> I'm using CXF 2.2.5, running on Java 1.6 and Tomcat 6.18.
>>
>> When the Tomcat server is stopped, we get always the following
>> NullPointerException:
>>
>> INFO: Stopping Coyote HTTP/1.1 on http-8080
>> Exception in thread "Thread-14" java.lang.NullPointerException
>> at org.apache.cxf.helpers.FileUtils.removeDir(FileUtils.java:126)
>> at org.apache.cxf.helpers.FileUtils$1.run(FileUtils.java:75)
>>
>>
>> I did a little debugging:
>>
>> During the first usage of CXF the FileUtils.getDefaultTempDir() is
>> called.
>> It resolves the tmp-dir correctly. At the end the
>> "private static File defaultTempDir" is set to the right directory.
>> Then the method schedules the removal of the tmp-dir like this:
>> Thread hook = new Thread() {
>> @Override
>> public void run() {
>> removeDir(defaultTempDir);
>> }
>> };
>> Runtime.getRuntime().addShutdownHook(hook);
>>
>>
>> So far, so good. When stopping Tomcat (== stopping the JVM) the hook is
>> "fired".
>> The removeDir(defaultTempDir) is called. But "defaultTempDir" is 'null'
>> and
>> in consequence
>> the NPE is thrown.
>>
>> Any idea why the static defaultTempDir is lost when the ShutdownHooks are
>> fired? A Bug?
>
> Hmm.. very strange. Maybe part of the classloader is GC'd before the
> hook
> is set? Fairly easy to fix I think:
>
> final File f2 = f;
> Thread hook = new Thread() {
> @Override
> public void run() {
> removeDir(f2);
> }
> };
> to make it not use the static and instead use an instance field for the
> hook.
> I'll commit that.
>
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
>
--
View this message in context: http://old.nabble.com/NPE-in-FileUtils.removeDir%28FileUtils.java%3A126%29-on-shutdown-tp28266687p28287858.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: NPE in FileUtils.removeDir(FileUtils.java:126) on shutdown
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 16 April 2010 9:12:27 am moslm wrote:
> I'm using CXF 2.2.5, running on Java 1.6 and Tomcat 6.18.
>
> When the Tomcat server is stopped, we get always the following
> NullPointerException:
>
> INFO: Stopping Coyote HTTP/1.1 on http-8080
> Exception in thread "Thread-14" java.lang.NullPointerException
> at org.apache.cxf.helpers.FileUtils.removeDir(FileUtils.java:126)
> at org.apache.cxf.helpers.FileUtils$1.run(FileUtils.java:75)
>
>
> I did a little debugging:
>
> During the first usage of CXF the FileUtils.getDefaultTempDir() is called.
> It resolves the tmp-dir correctly. At the end the
> "private static File defaultTempDir" is set to the right directory.
> Then the method schedules the removal of the tmp-dir like this:
> Thread hook = new Thread() {
> @Override
> public void run() {
> removeDir(defaultTempDir);
> }
> };
> Runtime.getRuntime().addShutdownHook(hook);
>
>
> So far, so good. When stopping Tomcat (== stopping the JVM) the hook is
> "fired".
> The removeDir(defaultTempDir) is called. But "defaultTempDir" is 'null' and
> in consequence
> the NPE is thrown.
>
> Any idea why the static defaultTempDir is lost when the ShutdownHooks are
> fired? A Bug?
Hmm.. very strange. Maybe part of the classloader is GC'd before the hook
is set? Fairly easy to fix I think:
final File f2 = f;
Thread hook = new Thread() {
@Override
public void run() {
removeDir(f2);
}
};
to make it not use the static and instead use an instance field for the hook.
I'll commit that.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: NPE in FileUtils.removeDir(FileUtils.java:126) on shutdown
Posted by moslm <mo...@lastminute.de>.
Just investigated further:
The NPE only occurs if the org.apache.cxf.interceptor.LoggingInInterceptor
is used.
I did override the class to get a clue what functionality in this class has
a side-effect
on the FileUtils.removeDir() function called during shutdown of the JVM.
The line 131 in LoggingInterceptor.java calls:
IOUtils.copy(is, bos);
If I remove this line the error described below is fixed?
I have no idea why the IOUtils.copy ... has any side-effect with
the FileUtils.removeDir on shutdown.
Any expert out there? Any ideas? Do other people use the
LoggingInInterceptor?
moslm wrote:
>
> I'm using CXF 2.2.5, running on Java 1.6 and Tomcat 6.18.
>
> When the Tomcat server is stopped, we get always the following
> NullPointerException:
>
> INFO: Stopping Coyote HTTP/1.1 on http-8080
> Exception in thread "Thread-14" java.lang.NullPointerException
> at org.apache.cxf.helpers.FileUtils.removeDir(FileUtils.java:126)
> at org.apache.cxf.helpers.FileUtils$1.run(FileUtils.java:75)
>
>
> I did a little debugging:
>
> During the first usage of CXF the FileUtils.getDefaultTempDir() is called.
> It resolves the tmp-dir correctly. At the end the
> "private static File defaultTempDir" is set to the right directory.
> Then the method schedules the removal of the tmp-dir like this:
> Thread hook = new Thread() {
> @Override
> public void run() {
> removeDir(defaultTempDir);
> }
> };
> Runtime.getRuntime().addShutdownHook(hook);
>
>
> So far, so good. When stopping Tomcat (== stopping the JVM) the hook is
> "fired".
> The removeDir(defaultTempDir) is called. But "defaultTempDir" is 'null'
> and in consequence
> the NPE is thrown.
>
> Any idea why the static defaultTempDir is lost when the ShutdownHooks are
> fired? A Bug?
>
> Thanks
> Mos
>
>
>
--
View this message in context: http://old.nabble.com/NPE-in-FileUtils.removeDir%28FileUtils.java%3A126%29-on-shutdown-tp28266687p28267761.html
Sent from the cxf-user mailing list archive at Nabble.com.