jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-378

MultipartHashMap should use LinkedHashMap by default in order to get predictable Form output

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Works as designed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: model api
    • Labels:
      None

      Description

      I've tried to replace CXF-specific Form extension with 2.0 Form, in itself it was easy enough, but the form output lists parameters in the order which typically does not match the order of the insertion.
      This is not a problem technically, but more often than not, it is nice to have an order of the insertion preserved.

      One option is to have MultivaluedHashMap use LinkedHashMap; another - may be add MultivaluedHashMap constructor accepting a map which will hold MultivaluedMap values, and get Form using this constructor

        Activity

        Hide
        Marek Potociar added a comment -

        There is an AbstractMultivaluedMap that takes in the underlying Map store instance and there is a Form constructor that takes in the MultivaluedMap store. So you should be able to achieve what you want using these 2 concepts.

        Show
        Marek Potociar added a comment - There is an AbstractMultivaluedMap that takes in the underlying Map store instance and there is a Form constructor that takes in the MultivaluedMap store. So you should be able to achieve what you want using these 2 concepts.
        Hide
        beryozkin_sergey added a comment -

        OK, I can see that works.

        It is not quite easy though for users to go this path. Fine when Form is used internally, but not ideal when a user populates the form.

        Would you still consider updating Form to use AbstractMultivaluedMap instantiation accepting LinkedHashMap store, by default, and users who somehow prefer it otherwise can always do new Form(MultivaluedHashMap()) ?

        If you think this can be reasonable then I'll open a more specific JIRA

        Show
        beryozkin_sergey added a comment - OK, I can see that works. It is not quite easy though for users to go this path. Fine when Form is used internally, but not ideal when a user populates the form. Would you still consider updating Form to use AbstractMultivaluedMap instantiation accepting LinkedHashMap store, by default, and users who somehow prefer it otherwise can always do new Form(MultivaluedHashMap()) ? If you think this can be reasonable then I'll open a more specific JIRA

          People

          • Assignee:
            Marek Potociar
            Reporter:
            beryozkin_sergey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: