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

Build method of org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder always return the same instance.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.1.0.CR1
    • 3.0.13.Final, 3.0.14.Final, 3.0.15.Final, 3.0.16.Final
    • jaxrs
    • Hide
      public class InvocationBuilderTest {
      
      	public static void main(String[] args) {
      		Client client = ClientBuilder.newClient();
      		try {
      			WebTarget webTarget = client.target("http://www.google.fr");
      			Builder invocationBuilder = webTarget.request();
      			Invocation getInvocation = invocationBuilder.build("GET");
      			// Request http://www.google.fr with GET method
      			getInvocation.invoke(String.class);
      			// invocationBuilder is supposed to build a new
      			// javax.ws.rs.client.Invocation instance but it does not.
      			invocationBuilder.build("POST");
      			// The previously built getInvocation has become a postInvocation
      			// regardless of the fact that there was no assignation to
      			// getInvocation variable on previous line. Error 405 (Method Not
      			// Allowed)
      			getInvocation.invoke(String.class);
      		} finally {
      			client.close();
      		}
      	}
      
      }
      
      Show
      public class InvocationBuilderTest { public static void main( String [] args) { Client client = ClientBuilder.newClient(); try { WebTarget webTarget = client.target( "http: //www.google.fr" ); Builder invocationBuilder = webTarget.request(); Invocation getInvocation = invocationBuilder.build( "GET" ); // Request http://www.google.fr with GET method getInvocation.invoke( String .class); // invocationBuilder is supposed to build a new // javax.ws.rs.client.Invocation instance but it does not. invocationBuilder.build( "POST" ); // The previously built getInvocation has become a postInvocation // regardless of the fact that there was no assignation to // getInvocation variable on previous line. Error 405 (Method Not // Allowed) getInvocation.invoke( String .class); } finally { client.close(); } } }

      Implemenation of "javax.ws.rs.client.Invocation.Builder" does not seems to strictly follow the builder pattern. It actually does not build a fresh instance on each build method call.

              rsigal@redhat.com Ronald Sigal
              nicones Nicolas NESMON (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: