jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-499

Rare NPE in Sun14ReflectionProvider

  • Log In
  • Views
    • XML
    • Word
    • Printable

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) { Constructor javaLangObjectConstructor = Object.class.getDeclaredConstructor(new Class[0]); mungedConstructor = reflectionFactory.newConstructorForSerialization(type, javaLangObjectConstructor); ref = new WeakReference(mungedConstructor); constructorCache.put(type, ref); }
return mungedConstructor;
}

Thank you for your attention.

Issue Links

duplicates

Bug - A problem which impairs or prevents the functions of the product. XSTR-497 getMungedConstructor in Sun14ReflectionProvider is unsafe

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Joerg Schaible added a comment - 22/Jun/08 10:34 AM

Already reported and fixed.

Show
Joerg Schaible added a comment - 22/Jun/08 10:34 AM Already reported and fixed.

People

  • Assignee:
    Joerg Schaible
    Reporter:
    Serge Brisson
Vote (0)
Watch (1)

Dates

  • Created:
    21/Jun/08 10:47 AM
    Updated:
    22/Jun/08 10:34 AM
    Resolved:
    22/Jun/08 10:34 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.