You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2020/03/13 12:50:25 UTC

[juneau] branch master updated: Rename RestCall.execute to RestCall.complete to avoid confusion.

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 70f58f2  Rename RestCall.execute to RestCall.complete to avoid confusion.
70f58f2 is described below

commit 70f58f2e36e08996e9b3eafe81ff81cf763bb728
Author: JamesBognar <ja...@apache.org>
AuthorDate: Fri Mar 13 08:50:08 2020 -0400

    Rename RestCall.execute to RestCall.complete to avoid confusion.
---
 .../org/apache/juneau/rest/client2/RestClient.java | 27 +++++++++-------------
 .../apache/juneau/rest/client2/RestRequest.java    | 14 +++++------
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
index e5462d2..16f0f3b 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
@@ -179,12 +179,12 @@ import org.apache.http.client.CookieStore;
  * 	<li class='jc'>{@link RestRequest}
  * 	<ul>
  * 		<li class='jm'>{@link RestRequest#run() run()}
- * 		<li class='jm'>{@link RestRequest#execute() execute()}
+ * 		<li class='jm'>{@link RestRequest#complete() complete()}
  * 	</ul>
  * </ul>
  *
  * <p class='w900'>
- * The distinction between the two methods is that {@link RestRequest#execute() execute()} automatically consumes the response body and
+ * The distinction between the two methods is that {@link RestRequest#complete() complete()} automatically consumes the response body and
  * {@link RestRequest#run() run()} does not.  Note that you must consume response bodies in order for HTTP connections to be freed up
  * for reuse!  The {@link InputStream InputStreams} returned by the {@link RestResponseBody} object are auto-closing once
  * they are exhausted, so it is often not necessary to explicitly close them.
@@ -196,15 +196,10 @@ import org.apache.http.client.CookieStore;
  * 	<jc>// Consuming the response, so use run().</jc>
  * 	String body = client.get(<jsf>URL</jsf>).run().getBody().asString();
  *
- * 	<jc>// Only interested in response status code, so use execute().</jc>
- *   <jk>int</jk> status = client.get(<jsf>URL</jsf>).execute().getStatusCode();
+ * 	<jc>// Only interested in response status code, so use complete().</jc>
+ *   <jk>int</jk> status = client.get(<jsf>URL</jsf>).complete().getStatusCode();
  * </p>
  *
- * <ul class='notes'>
- * 	<li>Don't confuse the behavior on the {@link RestRequest#execute()} method with the various execute methods defined on
- * 		the {@link RestClient} class.
- * </ul>
- *
  *
  * <h4 class='topic'>POJO Marshalling</h4>
  *
@@ -540,7 +535,7 @@ import org.apache.http.client.CookieStore;
  * <h4 class='topic'>Response Status</h4>
  *
  * <p class='w900'>
- * After execution using {@link RestRequest#run()} or {@link RestRequest#execute()}, the following methods can be used
+ * After execution using {@link RestRequest#run()} or {@link RestRequest#complete()}, the following methods can be used
  * to get the response status:
  *
  * <ul class='javatree'>
@@ -563,17 +558,17 @@ import org.apache.http.client.CookieStore;
  * <h5 class='figure'>Example:</h5>
  * <p class='bcode w800'>
  * 	<jc>// Only interested in status code.</jc>
- * 	<jk>int</jk> statusCode = c.get(<jsf>URL</jsf>).execute().getStatusCode();
+ * 	<jk>int</jk> statusCode = c.get(<jsf>URL</jsf>).complete().getStatusCode();
  *
  *   <jc>// Interested in multiple values.</jc>
  * 	Mutable&lt;Integer&gt; statusCode;
  * 	Mutable&lt;String&gt; reasonPhrase;
- * 	c.get(<jsf>URL</jsf>).execute().getStatusCode(statusCode).getReasonPhrase(reasonPhrase);
+ * 	c.get(<jsf>URL</jsf>).complete().getStatusCode(statusCode).getReasonPhrase(reasonPhrase);
  * 	System.<jsf>err</jsf>.println(<js>"statusCode="</js>+statusCode.get()+<js>", reasonPhrase="</js>+reasonPhrase.get());
  * </p>
  *
  * <ul class='notes'>
- * 	<li>If you are only interested in the response status and not the response body, be sure to use {@link RestRequest#execute()} instead
+ * 	<li>If you are only interested in the response status and not the response body, be sure to use {@link RestRequest#complete()} instead
  * 		of {@link RestRequest#run()} to make sure the response body gets automatically cleaned up.  Otherwise you must
  * 		consume the response yourself.
  * </ul>
@@ -618,7 +613,7 @@ import org.apache.http.client.CookieStore;
  * <h5 class='figure'>Example:</h5>
  * <p class='bcode w800'>
  * 	<jc>// See if response contains Location header.</jc>
- * 	<jk>boolean</jk> hasLocationHeader = c.get(<jsf>URL</jsf>).execute().getHeader(<js>"Location"</js>).exists();
+ * 	<jk>boolean</jk> hasLocationHeader = c.get(<jsf>URL</jsf>).complete().getHeader(<js>"Location"</js>).exists();
  * </p>
  *
  * <p class='w900'>
@@ -2621,11 +2616,11 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
 
 							RemoteMethodReturn rmr = rmm.getReturns();
 							if (rmr.getReturnValue() == RemoteReturn.NONE) {
-								rc.execute();
+								rc.complete();
 								return null;
 							} else if (rmr.getReturnValue() == RemoteReturn.STATUS) {
 								rc.ignoreErrors();
-								int returnCode = rc.execute().getStatusCode();
+								int returnCode = rc.complete().getStatusCode();
 								Class<?> rt = method.getReturnType();
 								if (rt == Integer.class || rt == int.class)
 									return returnCode;
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
index a68adca..c6fa0d3 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
@@ -2159,7 +2159,7 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
 	 * 	<li>Calling this method multiple times will return the same original response object.
 	 * 	<li>You must close the returned object if you do not consume the response or execute a method that consumes
 	 * 		the response.
-	 * 	<li>If you are only interested in the response code, use the {@link #execute()} method which will automatically
+	 * 	<li>If you are only interested in the response code, use the {@link #complete()} method which will automatically
 	 * 		consume the response so that you don't need to call {@link InputStream#close()} on the response body.
 	 * </ul>
 	 *
@@ -2299,22 +2299,22 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
 	 * <p class='bcode w800'>
 	 *  <jc>// Get the response code.
 	 *  // No need to call close() on the RestResponse object.</jc>
-	 *  <jk>int</jk> rc = client.get(<jsf>URL</jsf>).execute().getResponseCode();
+	 *  <jk>int</jk> rc = client.get(<jsf>URL</jsf>).complete().getResponseCode();
 	 * </p>
 	 *
 	 * @return The response object.
 	 * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt.
 	 */
-	public RestResponse execute() throws RestCallException {
+	public RestResponse complete() throws RestCallException {
 		return run().consume();
 	}
 
 	/**
-	 * Same as {@link #execute()} but allows you to run the call asynchronously.
+	 * Same as {@link #complete()} but allows you to run the call asynchronously.
 	 *
 	 * <h5 class='section'>Example:</h5>
 	 * <p class='bcode w800'>
-	 * 	Future&lt;RestResponse&gt; f = client.get(<jsf>URL</jsf>).executeFuture();
+	 * 	Future&lt;RestResponse&gt; f = client.get(<jsf>URL</jsf>).completeFuture();
 	 * 	<jc>// Do some other stuff</jc>
 	 * 	<jk>int</jk> rc = f.get().getResponseStatus();
 	 * </p>
@@ -2328,12 +2328,12 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
 	 * @return The HTTP status code.
 	 * @throws RestCallException If the executor service was not defined.
 	 */
-	public Future<RestResponse> executeFuture() throws RestCallException {
+	public Future<RestResponse> completeFuture() throws RestCallException {
 		return client.getExecutorService(true).submit(
 			new Callable<RestResponse>() {
 				@Override /* Callable */
 				public RestResponse call() throws Exception {
-					return execute();
+					return complete();
 				}
 			}
 		);