Browse Source

Changed Future<Void> to Future<?>

Changed return values of Future<Void> to Future<?> in AsyncRestTemplate
and AsyncRestOperations.
pull/342/merge
Arjen Poutsma 12 years ago
parent
commit
e33324b700
  1. 18
      spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java
  2. 12
      spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java
  3. 4
      spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java

18
spring-web/src/main/java/org/springframework/web/client/AsyncRestOperations.java

@ -192,57 +192,63 @@ public interface AsyncRestOperations {
/** /**
* Create or update a resource by PUTting the given object to the URI. * Create or update a resource by PUTting the given object to the URI.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
* @param request the Object to be PUT, may be {@code null} * @param request the Object to be PUT, may be {@code null}
* @param uriVariables the variables to expand the template * @param uriVariables the variables to expand the template
* @see HttpEntity * @see HttpEntity
*/ */
Future<Void> put(String url, HttpEntity<?> request, Object... uriVariables) Future<?> put(String url, HttpEntity<?> request, Object... uriVariables)
throws RestClientException; throws RestClientException;
/** /**
* Creates a new resource by PUTting the given object to URI template. * Creates a new resource by PUTting the given object to URI template.
* <p>URI Template variables are expanded using the given map. * <p>URI Template variables are expanded using the given map.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
* @param request the Object to be PUT, may be {@code null} * @param request the Object to be PUT, may be {@code null}
* @param uriVariables the variables to expand the template * @param uriVariables the variables to expand the template
* @see HttpEntity * @see HttpEntity
*/ */
Future<Void> put(String url, HttpEntity<?> request, Map<String, ?> uriVariables) Future<?> put(String url, HttpEntity<?> request, Map<String, ?> uriVariables)
throws RestClientException; throws RestClientException;
/** /**
* Creates a new resource by PUTting the given object to URL. * Creates a new resource by PUTting the given object to URL.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
* @param request the Object to be PUT, may be {@code null} * @param request the Object to be PUT, may be {@code null}
* @see HttpEntity * @see HttpEntity
*/ */
Future<Void> put(URI url, HttpEntity<?> request) throws RestClientException; Future<?> put(URI url, HttpEntity<?> request) throws RestClientException;
// DELETE // DELETE
/** /**
* Asynchronously delete the resources at the specified URI. * Asynchronously delete the resources at the specified URI.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
* @param uriVariables the variables to expand in the template * @param uriVariables the variables to expand in the template
*/ */
Future<Void> delete(String url, Object... uriVariables) throws RestClientException; Future<?> delete(String url, Object... uriVariables) throws RestClientException;
/** /**
* Asynchronously delete the resources at the specified URI. * Asynchronously delete the resources at the specified URI.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
* @param uriVariables the variables to expand in the template * @param uriVariables the variables to expand in the template
*/ */
Future<Void> delete(String url, Map<String, ?> uriVariables) throws RestClientException; Future<?> delete(String url, Map<String, ?> uriVariables) throws RestClientException;
/** /**
* Asynchronously delete the resources at the specified URI. * Asynchronously delete the resources at the specified URI.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The Future will return a {@code null} result upon completion.
* @param url the URL * @param url the URL
*/ */
Future<Void> delete(URI url) throws RestClientException; Future<?> delete(URI url) throws RestClientException;
// OPTIONS // OPTIONS

12
spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java

@ -304,21 +304,21 @@ public class AsyncRestTemplate extends AsyncHttpAccessor implements AsyncRestOpe
// PUT // PUT
@Override @Override
public Future<Void> put(String url, HttpEntity<?> request, Object... uriVariables) public Future<?> put(String url, HttpEntity<?> request, Object... uriVariables)
throws RestClientException { throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request); AsyncRequestCallback requestCallback = httpEntityCallback(request);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables); return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
} }
@Override @Override
public Future<Void> put(String url, HttpEntity<?> request, public Future<?> put(String url, HttpEntity<?> request,
Map<String, ?> uriVariables) throws RestClientException { Map<String, ?> uriVariables) throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request); AsyncRequestCallback requestCallback = httpEntityCallback(request);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables); return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
} }
@Override @Override
public Future<Void> put(URI url, HttpEntity<?> request) throws RestClientException { public Future<?> put(URI url, HttpEntity<?> request) throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request); AsyncRequestCallback requestCallback = httpEntityCallback(request);
return execute(url, HttpMethod.PUT, requestCallback, null); return execute(url, HttpMethod.PUT, requestCallback, null);
} }
@ -326,19 +326,19 @@ public class AsyncRestTemplate extends AsyncHttpAccessor implements AsyncRestOpe
// DELETE // DELETE
@Override @Override
public Future<Void> delete(String url, Object... urlVariables) public Future<?> delete(String url, Object... urlVariables)
throws RestClientException { throws RestClientException {
return execute(url, HttpMethod.DELETE, null, null, urlVariables); return execute(url, HttpMethod.DELETE, null, null, urlVariables);
} }
@Override @Override
public Future<Void> delete(String url, Map<String, ?> urlVariables) public Future<?> delete(String url, Map<String, ?> urlVariables)
throws RestClientException { throws RestClientException {
return execute(url, HttpMethod.DELETE, null, null, urlVariables); return execute(url, HttpMethod.DELETE, null, null, urlVariables);
} }
@Override @Override
public Future<Void> delete(URI url) throws RestClientException { public Future<?> delete(URI url) throws RestClientException {
return execute(url, HttpMethod.DELETE, null, null); return execute(url, HttpMethod.DELETE, null, null);
} }

4
spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java

@ -149,7 +149,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
public void put() public void put()
throws URISyntaxException, ExecutionException, InterruptedException { throws URISyntaxException, ExecutionException, InterruptedException {
HttpEntity<String> requestEntity = new HttpEntity<>(helloWorld); HttpEntity<String> requestEntity = new HttpEntity<>(helloWorld);
Future<Void> Future<?>
responseEntityFuture = template.put(baseUrl + "/{method}", requestEntity, responseEntityFuture = template.put(baseUrl + "/{method}", requestEntity,
"put"); "put");
responseEntityFuture.get(); responseEntityFuture.get();
@ -158,7 +158,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
@Test @Test
public void delete() public void delete()
throws URISyntaxException, ExecutionException, InterruptedException { throws URISyntaxException, ExecutionException, InterruptedException {
Future<Void> deletedFuture = template.delete(new URI(baseUrl + "/delete")); Future<?> deletedFuture = template.delete(new URI(baseUrl + "/delete"));
deletedFuture.get(); deletedFuture.get();
} }

Loading…
Cancel
Save