Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5273

Allow forward-compatibility by ignoring unexpected enumeration values

    Details

      Description

      AXIS2-4859 has been patched adding the -Eiu option to ignore unexpected elements. However, to truly be forward-compatible, generated code should also ignore unexpected enumeration values.
      Here's the snippet necessary for the adb code generation. I opted to return null when an unexpected enumeration is found, as opposed to skip it:

      ADBBeanTemplate-bean.xsl line 2135:

                          // handle unexpected enumeration values properly
                          <xsl:if test="$ignoreunexpected">
                              log.warn("Unexpected value " + value + " for enumeration <xsl:value-of select="$name"/>");
                              return enumeration;
                          </xsl:if>
                          <xsl:if test="not($ignoreunexpected)">
                              if ((enumeration == null) &amp;&amp; !((value == null) || (value.equals("")))) {
                                  throw new java.lang.IllegalArgumentException();
                              }
                              return enumeration;
                          </xsl:if>
      
      1. patch.txt
        1 kB
        Cleber Zarate
      2. favoriteCharacters_client_afterPatch.zip
        15 kB
        Cleber Zarate
      3. favoriteCharacters_client_beforePatch.zip
        14 kB
        Cleber Zarate
      4. favoriteCharacters_service_new_enumeration_value.zip
        112 kB
        Cleber Zarate
      5. favoriteCharacters_service_original_enumeration_values.zip
        131 kB
        Cleber Zarate

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          Integrated in Axis2 #1314 (See https://builds.apache.org/job/Axis2/1314/)
          Applied patch for AXIS2-5273. (Revision 1304272)

          Result = SUCCESS
          sagara :
          Files :

          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
          Show
          hudson Hudson added a comment - Integrated in Axis2 #1314 (See https://builds.apache.org/job/Axis2/1314/ ) Applied patch for AXIS2-5273 . (Revision 1304272) Result = SUCCESS sagara : Files : /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
          Hide
          sagara Sagara Gunathunga added a comment -

          Patch available on r1304272.

          Show
          sagara Sagara Gunathunga added a comment - Patch available on r1304272.
          Hide
          cleber.zarate Cleber Zarate added a comment -

          file favoriteCharacters_service_original_enumeration_values.zip contains a simple service that exposes a method that returns an enumeration with 4 values.
          favoriteCharacters_service_new_enumeration_value.zip is a newer version of the previous service, which happens to add a new value in the enumeration (now 5 values total).
          File favoriteCharacters_client_beforePatch.zip contains a client project generated against the original service WSDL (containing 4 values). When pointed to the new service, an IllegalArgumentException is thrown.
          File favoriteCharacters_client_afterPatch.zip contains the same client project generated against the original service WSDL (4 values), however because of the patch, it won't throw any exceptions when pointing to the new service.
          The binding will return null when it encounters the unexpected new enumeration value.

          Show
          cleber.zarate Cleber Zarate added a comment - file favoriteCharacters_service_original_enumeration_values.zip contains a simple service that exposes a method that returns an enumeration with 4 values. favoriteCharacters_service_new_enumeration_value.zip is a newer version of the previous service, which happens to add a new value in the enumeration (now 5 values total). File favoriteCharacters_client_beforePatch.zip contains a client project generated against the original service WSDL (containing 4 values). When pointed to the new service, an IllegalArgumentException is thrown. File favoriteCharacters_client_afterPatch.zip contains the same client project generated against the original service WSDL (4 values), however because of the patch, it won't throw any exceptions when pointing to the new service. The binding will return null when it encounters the unexpected new enumeration value.
          Hide
          sagara Sagara Gunathunga added a comment -

          Can you attach a test case or a sample service (source code) you used to test this patch ?

          Show
          sagara Sagara Gunathunga added a comment - Can you attach a test case or a sample service (source code) you used to test this patch ?
          Hide
          cleber.zarate Cleber Zarate added a comment -

          Patch for ignoring unexpected enumeration values

          Show
          cleber.zarate Cleber Zarate added a comment - Patch for ignoring unexpected enumeration values

            People

            • Assignee:
              Unassigned
              Reporter:
              cleber.zarate Cleber Zarate
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development