Details
- 
        Type: Bug Bug
- 
        Status: Closed Closed
- 
            Priority: Major Major
- 
            Resolution: Duplicate
- 
            Affects Version/s: 1.3
- 
            Fix Version/s: 1.x Maintenance
- 
            Component/s: Converters
- 
            Labels:None
- 
                        JDK version and platform:Sun 1.5.0_11 for Windows
Description
In a long running high volume application, we have had an occurence of a NPE at
com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider.newInstance(Sun14ReflectionProvider.java:74).
After looking at the source, at tiny window has been found in the 'getMungedConstructor'
method involving the use of WeakReference and bad luck with the timing of the
garbage collector.
A suggested fix for this method follows:
    private Constructor getMungedConstructor(Class type) throws NoSuchMethodException {
        WeakReference ref = (WeakReference)constructorCache.get(type);
        Constructor mungedConstructor = ref != null? ref.get(): null;
        if (mungedConstructor == null) 
        return mungedConstructor;
    }
Thank you for your attention.
Issue Links
- duplicates
- 
             XSTR-497
        getMungedConstructor in Sun14ReflectionProvider is unsafe XSTR-497
        getMungedConstructor in Sun14ReflectionProvider is unsafe
-         


Already reported and fixed.