Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-2884

Defining a mandatory long metadata on a content triggers an error when saving

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.2.2, 3.3
    • 3.1.1, 3.2.1
    • None
    • None

      I created a content type with a mandatory long metadata.
      Trying to save a content of this type fails, triggers an error. The stacktrace is:

      [J cannot be cast to [Ljava.lang.Object;
      
      java.lang.ClassCastException: [J cannot be cast to [Ljava.lang.Object;
          at org.ametys.runtime.util.parameter.DefaultValidator.validate(DefaultValidator.java:155)
          at org.ametys.cms.workflow.EditContentFunction._validateMetadata(EditContentFunction.java:894)
          at org.ametys.cms.workflow.EditContentFunction._bindAndValidateLongMetadata(EditContentFunction.java:642)
          at org.ametys.cms.workflow.EditContentFunction._bindAndValidateMetadata(EditContentFunction.java:388)
          at org.ametys.cms.workflow.EditContentFunction._bindAndValidateMetadataSetElement(EditContentFunction.java:251)
          at org.ametys.cms.workflow.EditContentFunction._bindAndValidateContent(EditContentFunction.java:217)
          at org.ametys.cms.workflow.EditContentFunction.execute(EditContentFunction.java:126)
          [...]
      

      It appears to be because the EditContentFunction creates a long[], and DefaultValidator only handles scalar values or Object[], and tries to cast long[] to Object[].
      The problem may present itself with double and boolean metadata (even if a mandatory boolean metadata isn't the most logical thing in the world).

            Unassigned Unassigned
            ngavalda Nicolas Gavalda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: