#93 Null pointer on MappingProcessor at Line 282

closed
None
5
2007-05-21
2007-05-11
Ryan Rich
No

On occassion I am getting a null pointer exception from the MappingProcessor class in dozer. For now I have modified line 281 to add an extra null check:

if (parentClassMap != null && superListOfFieldNames != null) {

to avoid the exception, but haven't had time to step through the code to see if this is a valid thing to do.

Partial Stack trace:

java.lang.NullPointerException
at net.sf.dozer.util.mapping.MappingProcessor.mapField(MappingProcessor.java:282)
at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:255)
at net.sf.dozer.util.mapping.MappingProcessor.processSuperTypeMapping(MappingProcessor.java:1095)
at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:245)
at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:185)
at net.sf.dozer.util.mapping.MappingProcessor.map(MappingProcessor.java:159)
at net.sf.dozer.util.mapping.DozerBeanMapper.map(DozerBeanMapper.java:103)

Discussion

  • Ryan Rich

    Ryan Rich - 2007-05-11

    Logged In: YES
    user_id=819455
    Originator: YES

    I see this behavior in Dozer 3.3 and 3.3.1

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-11
    • assigned_to: nobody --> fgarsombke
     
  • Franz Garsombke

    Franz Garsombke - 2007-05-11

    Logged In: YES
    user_id=550744
    Originator: NO

    Can you attach a mapping and unit test that produces this? We need a unit test so we can apply this fix.

    Thanks for your help!

    Franz

     
  • pluimpje

    pluimpje - 2007-05-14

    Logged In: YES
    user_id=1792692
    Originator: NO

    I have encountered the same problem. after some research I found that it came from the following problem:

    lines 244 - 246 of MappingProcessor
    superListOfFieldNames = new ArrayList();
    parentFieldNames = processSuperTypeMapping(superClasses, sourceObj, destObj, sourceClass, parentFieldMap);
    superListOfFieldNames = null;

    In case I have the following class structure.
    C extends B
    B extends A

    Z extends Y
    Y extends X

    when I want to convert Z to C (or the other way around) the lines 244 - 246 are called ones for the extends between C and B, and in the recursion a second time for the extends between B and A.
    when the dozer has done with B/A it sets the global variable to null, and continues with the extends between C and B. and at this point it encounters the error mentioned above.

    I hope this explenation is clear enough.

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-14

    Logged In: YES
    user_id=550744
    Originator: NO

    That should be enough to go on. This will be fixed for the next release.

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-14
    • summary: Null pointer --> Null pointer on MappingProcessor at Line 282
     
  • pluimpje

    pluimpje - 2007-05-15

    Logged In: YES
    user_id=1792692
    Originator: NO

    I patched it like this to be able to continue (in MappingProcessor)

    line 84
    private Stack superListOfFieldNamesStack = new Stack();

    +- line 244
    if(superListOfFieldNames!=null){
    //save for futher use (because overwritten if recursed
    superListOfFieldNamesStack.push(superListOfFieldNames);
    }
    superListOfFieldNames = new ArrayList();
    parentFieldNames = processSuperTypeMapping(superClasses, sourceObj, destObj, sourceClass, parentFieldMap);
    superListOfFieldNames = null;
    if(!superListOfFieldNamesStack.isEmpty()){
    superListOfFieldNames = (List)superListOfFieldNamesStack.pop();
    }

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-16

    Logged In: YES
    user_id=550744
    Originator: NO

    fixed in 3.x branch

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-16
    • status: open --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2007-05-21
    • status: pending --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks