Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1106

ResponseBuilderImpl.links() removes previously added Link-Headers

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.8.Final
    • Fix Version/s: 3.0.9.Final
    • Component/s: jaxrs
    • Labels:
      None
    • Steps to Reproduce:
      Hide
            Response r1 = Response.ok()
                    .link("Link1", "rel1")
                    .links(
                            Link.fromUri("Link2").rel("rel2").build(),
                            Link.fromUri("Link3").rel("rel3").build()
                    )
                    .link("Link4", "rel4").build();
      
            Assert.assertNotNull("Link-Header 'Link1' missing", r1.getLink("rel1"));
            Assert.assertNotNull("Link-Header 'Link2' missing", r1.getLink("rel2"));
            Assert.assertNotNull("Link-Header 'Link3' missing", r1.getLink("rel3"));
            Assert.assertNotNull("Link-Header 'Link4' missing", r1.getLink("rel4"));
      
      
      Show
      Response r1 = Response.ok() .link( "Link1" , "rel1" ) .links( Link.fromUri( "Link2" ).rel( "rel2" ).build(), Link.fromUri( "Link3" ).rel( "rel3" ).build() ) .link( "Link4" , "rel4" ).build(); Assert.assertNotNull( "Link-Header 'Link1' missing" , r1.getLink( "rel1" )); Assert.assertNotNull( "Link-Header 'Link2' missing" , r1.getLink( "rel2" )); Assert.assertNotNull( "Link-Header 'Link3' missing" , r1.getLink( "rel3" )); Assert.assertNotNull( "Link-Header 'Link4' missing" , r1.getLink( "rel4" ));

      Description

      org.jboss.resteasy.specimpl.ResponseBuilderImpl#links is removing all previous Link-headers.

      According to the java-doc in the Interface (javax.ws.rs.core.Response.ResponseBuilder#links) the method should add provided Link headers. Resetting the Link headers should only happen if null is passed:

              /**
               * Add one or more link headers.
               *
               * @param links links to be added to the message as headers, a {@code null}
               *              value will remove any existing Link headers.
               * @return the updated response builder.
               * @since 2.0
               */
              public abstract ResponseBuilder links(Link... links);
      

      The current implementation does not allow mixing ResponseBuilder#link and ResponseBuilder#links

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bill.burke Bill Burke
                Reporter:
                jafrank Jakob Frank
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: