jersey
  1. jersey
  2. JERSEY-1257

Invocation.Builder#headers(MultivaluedMap) is broken :)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-m06
    • Fix Version/s: 2.0-m06, 2.0
    • Component/s: None
    • Labels:
      None

      Description

      Javadoc says:

      Replaces all existing headers with the newly supplied headers.

      However, the headers set by:

      		Invocation.Builder builder = createBuilderForMethod("headerstostring");
      		MultivaluedMap<String, Object> map = new MultivaluedHashMap<String, Object>();
      		map.add("a-header", "b-header");
      		String response = builder
      				.header("unexpected-header", "unexpected-header").headers(map)
      				.buildGet().invoke(String.class);
      

      and obtained by @HttpHeaders on a resource method
      are:

      unexpected-header:unexpected-header;user-agent:Java/1.6.0_25;host:localhost:6080;accept:text/html, image/gif, image/jpeg, ; q=.2, */; q=.2;connection:keep-alive;

      Moreover,
      the javadoc says:

      headers - new headers to be set, if null all existing headers will be removed.

      However,

      		String response = builder
      				.header("unexpected-header", "unexpected-header")
      				.headers((MultivaluedMap<String, Object>) null).buildGet()
      				.invoke(String.class);
      

      throws a nullpointer exception.

      ERROR: java.lang.NullPointerException
      at org.glassfish.jersey.message.internal.OutboundMessageContext.replaceAll(OutboundMessageContext.java:239)
      at org.glassfish.jersey.client.JerseyClientRequestContext.replaceHeaders(JerseyClientRequestContext.java:249)
      at org.glassfish.jersey.client.JerseyInvocation$Builder.headers(JerseyInvocation.java:203)

        Activity

        Hide
        Martin Matula added a comment -

        Fixed in trunk.

        Show
        Martin Matula added a comment - Fixed in trunk.

          People

          • Assignee:
            Martin Matula
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: