Tapestry 5
  1. Tapestry 5
  2. TAP5-609

Upgrade to 5.1 broke a Loop that iterated over a two-dimensional double array

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.1.0.2
    • Fix Version/s: None
    • Component/s: tapestry-core

      Description

      I have a component which uses two nested loop to input a two dimensional array of Doubles. It works in Tapestry 5.0.18. In Tapestry 5.1.0.2 snapshot, when I submit the form containing the above component, I get the following error message.

      Could not find a coercion from type java.lang.String to type [Ljava.lang.Double;. Available coercions: Double --> Float, Float --> Double, Long --> Boolean, Long --> Byte, Long --> Double, Long --> Integer, Long --> Short, Number --> Long, Object --> Object[], Object --> String, Object --> java.util.List, Object[] --> java.util.List, String --> Boolean, String --> Double, String --> Long, String --> java.io.File, String --> java.math.BigDecimal, String --> java.math.BigInteger, String --> java.text.DateFormat, String --> java.util.regex.Pattern, String --> org.apache.tapestry5.Renderable, String --> org.apache.tapestry5.SelectModel, String --> org.apache.tapestry5.corelib.data.BlankOption, String --> org.apache.tapestry5.corelib.data.GridPagerPosition, String --> org.apache.tapestry5.corelib.data.InsertPosition, String --> org.apache.tapestry5.ioc.Resource, String --> org.apache.tapestry5.ioc.util.TimeInterval, boolean[] --> java.util.List, byte[] --> java.util.List, char[] --> java.util.List, double[] --> java.util.List, float[] --> java.util.List, int[] --> java.util.List, java.math.BigDecimal -

      1. org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:244)
      2. org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.access$000(TypeCoercerImpl.java:29)
      3. org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.getCoercion(TypeCoercerImpl.java:88)
      4. org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:61)
      5. org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:133)
      6. $TypeCoercer_1204ea4852e.coerce($TypeCoercer_1204ea4852e.java)
      7. org.apache.tapestry5.internal.services.TypeCoercedValueEncoderFactory$1.toValue(TypeCoercedValueEncoderFactory.java:45)
      8. org.apache.tapestry5.corelib.components.Loop.restoreStateFromStoredClientValue(Loop.java:423)
      9. org.apache.tapestry5.corelib.components.Loop.access$500(Loop.java:41)
      10. org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:162)
      11. org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:151)
      12. org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:477)
      13. org.apache.tapestry5.corelib.components.Form._$advised$onAction(Form.java:375)
      14. org.apache.tapestry5.corelib.components.Form$onAction$invocation_1204ea4f004.invokeAdvisedMethod(Form$onAction$invocation_1204ea4f004.java)
      15. org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:71)
      16. org.apache.tapestry5.ioc.internal.services.LoggingAdvice.advise(LoggingAdvice.java:37)
      17. org.apache.tapestry5.internal.transform.LogWorker$1.advise(LogWorker.java:54)
      18. org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:80)
      19. org.apache.tapestry5.corelib.components.Form.onAction(Form.java)
      1. myapp.jar
        58 kB
        Shing Hing Man

        Activity

        Hide
        Shing Hing Man added a comment -

        Attached a Tapestry Eclipse project that produces the error.

        Show
        Shing Hing Man added a comment - Attached a Tapestry Eclipse project that produces the error.
        Hide
        Shing Hing Man added a comment -

        I have worked out the cause of the error.

        In my Loop component, the source parameter is set to Double[][] and the parameter encoder is not set.

        In 5.0.18 Loop.java, when the encoder parameter is null (not provided),
        it will store each element (of type Double[] in our case) of the source.

        In 5.1.0.2 Loop.java, when the encoder parameter is not provided, it will try to find a ValueEncoder for
        Double[].
        As there is no ValueEncoder in the framework that handles Double[], an exception is thrown.

        A fix is to provide a custom ValueEncoder to my Loop component to handle Double[].

        In general, as it is, if there is no built-in ValueEncoder for the type of elements in the collection
        specified in the source parameter, an exception on not finding a ValueEncoder will be thrown.
        Is this a bug or feature ?

        Show
        Shing Hing Man added a comment - I have worked out the cause of the error. In my Loop component, the source parameter is set to Double[][] and the parameter encoder is not set. In 5.0.18 Loop.java, when the encoder parameter is null (not provided), it will store each element (of type Double[] in our case) of the source. In 5.1.0.2 Loop.java, when the encoder parameter is not provided, it will try to find a ValueEncoder for Double[]. As there is no ValueEncoder in the framework that handles Double[], an exception is thrown. A fix is to provide a custom ValueEncoder to my Loop component to handle Double[]. In general, as it is, if there is no built-in ValueEncoder for the type of elements in the collection specified in the source parameter, an exception on not finding a ValueEncoder will be thrown. Is this a bug or feature ?
        Hide
        Howard M. Lewis Ship added a comment -

        Tapestry chose the default Object ValueEncoder, which uses TypeCoercer to coerce the object to a String, resutling in one of those very odd array strings "[[LDouble;" or something. It then was unable to convert that String back into a Double[][] when the form was submitted.

        Another fix would be to contribute a TypeCoercer for String -> Double[][] and Double[][] -> String.

        Show
        Howard M. Lewis Ship added a comment - Tapestry chose the default Object ValueEncoder, which uses TypeCoercer to coerce the object to a String, resutling in one of those very odd array strings "[[LDouble;" or something. It then was unable to convert that String back into a Double[][] when the form was submitted. Another fix would be to contribute a TypeCoercer for String -> Double[][] and Double[][] -> String.
        Hide
        Jochen Kemnade added a comment -

        This issue has been last updated about 1.5 years ago, has no assignee, affects an old version of Tapestry that is not actively developed anymore, and is therefore prone to be bulk-closed in the near future.

        If the issue still persists with the most recent development preview of Tapestry (5.4-beta-6, which is available from Maven Central), please update it as soon as possible. In the case of a feature request, please discuss it with the Tapestry developer community on the dev@tapestry.apache.org mailing list first.

        Show
        Jochen Kemnade added a comment - This issue has been last updated about 1.5 years ago, has no assignee, affects an old version of Tapestry that is not actively developed anymore, and is therefore prone to be bulk-closed in the near future. If the issue still persists with the most recent development preview of Tapestry (5.4-beta-6, which is available from Maven Central), please update it as soon as possible. In the case of a feature request, please discuss it with the Tapestry developer community on the dev@tapestry.apache.org mailing list first.

          People

          • Assignee:
            Unassigned
            Reporter:
            Shing Hing Man
          • Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development