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

ResponseBuilderImpl.links() removes previously added Link-Headers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.9.Final
    • 3.0.8.Final
    • jaxrs
    • None
    • 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" ));

      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

              patriot1burke@gmail.com Bill Burke (Inactive)
              jafrank_jira Jakob Frank (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: