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
> [email protected]
> 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.