axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Mole (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2C-753) Program crashes if optional elements are not provided
Date Thu, 08 Nov 2007 23:44:50 GMT

    [ https://issues.apache.org/jira/browse/AXIS2C-753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541179
] 

Michael Mole commented on AXIS2C-753:
-------------------------------------

I looked at CADBBeanTemplateSource.xsl and it seems that this checking is only done for array
elements.  This should generate code similar to the "setter" methods.

So in the context of the above complexType, the serialize method should look like this:

if ( _Foo->foo-element != NULL ) {

        start_input_str = "<ns2:foo-element";                    
        start_input_str_len = axutil_strlen(start_input_str);
        end_input_str = "</ns2:foo-element>";
        end_input_str_len = axutil_strlen(end_input_str);
                     
        axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                            
        adb_foo-element_serialize(_Foo->foo-element,
                                                   env, current_node, AXIS2_FALSE);
                            
        axutil_stream_write(stream, env, end_input_str, end_input_str_len);
}

Also, if minOccurs is not specified, perhaps it should return an error if _Foo->foo-element
is NULL.

> Program crashes if optional elements are not provided
> -----------------------------------------------------
>
>                 Key: AXIS2C-753
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-753
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: 1.1.0
>            Reporter: Michael Mole
>            Priority: Critical
>
> I am using the code generation tool from approx. 11/1/2007 Axis2/Java nightly snapshot.
 I am using it to generate C databindings
> My generated adb databinding code is writing elements in the serialize method even when
minOccurs="0".  I think if anything has a minOccurs="0", the generated serialize should check
if the element has been provided by surrounding the code block with an "if ( foo-element !-
NULL )".  Otherwise, the program will crash if the optional element has not been provided.

> I have a datatype defined as follows:
>   <complexType name="Foo">
>     <sequence>
>       <element name="foo-element" type="foo_type"
>           minOccurs="0">
>       </element>
>     </sequence>
>   </complexType>
> In my serialize method I'm seeing something like this:
>                         start_input_str = "<ns2:foo-element";
>                             
>                         start_input_str_len = axutil_strlen(start_input_str);
>                         end_input_str = "</ns2:foo-element>";
>                         end_input_str_len = axutil_strlen(end_input_str);
>                      
>                             axutil_stream_write(stream, env, start_input_str, start_input_str_len);
>                             
>                             adb_foo-element_serialize(_Foo->foo-element, 
>                                                                                  env,
current_node,
> 					AXIS2_FALSE
>                                     );
>                             
>                             axutil_stream_write(stream, env, end_input_str, end_input_str_len);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Mime
View raw message