The get-method used in the collection element seems to be used inappropriately 
during unmarshalling.
----------------------------------------------------------------------------------------------------

         Key: JIBX-122
         URL: http://jira.codehaus.org/browse/JIBX-122
     Project: JiBX
        Type: Bug

  Components: core  
    Versions: JiBX 1.1    
    Reporter: E.F.
     Fix For: JiBX 1.1


I've defined a mapping in my binding like this:

  <mapping name="Application" class="Application">
    <collection name="MandatoryComponents" create-type="java.util.ArrayList" 
item-type="ComponentInstance" get-method="getMandatoryComponentInstances" 
set-method="addMandatoryComponentInstances"/>
  </mapping>

I noticed in the bytecode enhanced Application class, the generated 
unmarshalling method becomes:

public final Application JiBX_application_unmarshal_1_1(UnmarshallingContext 
arg1)
        throws JiBXException
    {
        arg1.pushTrackedObject(this);
        this;
        arg1.parsePastStartTag(null, "MandatoryComponents");
        Collection collection;
        
addMandatoryComponentInstances(JiBX_MungeAdapter.JiBX_application_unmarshal_1_0((collection
 = getMandatoryComponentInstances()) != null ? collection : 
JiBX_MungeAdapter.JiBX_application_newinstance_1_0(arg1), arg1));
        arg1.parsePastCurrentEndTag(null, "MandatoryComponents");
        arg1.popObject();
        return this;
    }

It turns out that the my method getMandatoryComponentInstances(), I am 
returning an unmodifiable Collection.  I do not return null if the collection 
is empty.  When I run my unmarshalling testcase, I will get an 
UnsupportedOperationException because you cannot add to the collection my 
method returns.

It seems to me it would be wrong to assume my get-method will return something 
you can add to.  Furthermore, why is the get-method being used for 
unmarshalling?  I already specified a create-type="java.util.ArrayList", so why 
not just instantiate one of those?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to