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

Form should use LinkedHashMap by default

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: model api
    • Labels:
      None

      Description

      Continuing from other related JIRA.
      Proposal: javax.ws.rs.core.Form may be marginally improved to have AbstractMultivaluedMap instance accepting LinkedHashMap store used by default.
      This is absolutely safe, but also makes it a bit easier to test and read the form output. For example, some specifications show how a form output may look like and it is really handy to get the order of the insertion preserved on the output, just to 'feel good' about the client producing exactly the same output.
      For a simple example, new Form().param("user", "barry").param("password", "1234") will currently produce:

      password=1234&user=barry

      as opposed to a 'typical'

      user=barry&password=1234

      etc.

      Indeed, one can do

      class MyMap extends AbstractMultivaluedMap {
         public MyMap() {
             super(new LinkedHashMap());
         }
      }
      new Form(new MyMap());
      

      but "new Form()" with the order of insertion preserved and "new Form(new MultivaluedHashMap())" for someone who somehow wants a random output is simpler option

      very minor issue but worth addressing IMHO

        Activity

        Hide
        Marek Potociar added a comment -

        Form implementation updated.

        Show
        Marek Potociar added a comment - Form implementation updated.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: