From 993cd08bbc9fb91e3aa7833728485124af3fb9f4 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 13 Dec 2011 11:45:49 -0800 Subject: [PATCH] reversed pull 239 as it broke the build --- .../BindS3ObjectMetadataToRequest.java | 2 +- .../internal/RestAnnotationProcessor.java | 13 +----- .../internal/RestAnnotationProcessorTest.java | 42 ------------------- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java b/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java index 4c96859d4a..2fea524d11 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java +++ b/apis/s3/src/main/java/org/jclouds/s3/binders/BindS3ObjectMetadataToRequest.java @@ -46,7 +46,7 @@ public class BindS3ObjectMetadataToRequest implements Binder { @Override public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof S3Object, "this binder is only valid for S3Object!"); + checkArgument(checkNotNull(input, "input") instanceof S3Object, "this binder is only valid for S3Object!, not %s", input); checkNotNull(request, "request"); S3Object s3Object = S3Object.class.cast(input); diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index c337c5ce0b..1fc970da04 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -944,7 +944,6 @@ public class RestAnnotationProcessor { public GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request) throws NegativeArraySizeException, ExecutionException { - Cache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(request.getJavaMethod()); OUTER: for (Entry> entry : concat(// filterValues(methodToIndexOfParamToBinderParamAnnotation.get(request.getJavaMethod()).asMap(), notEmpty) .entrySet(), // @@ -979,17 +978,7 @@ public class RestAnnotationProcessor { } } if (input != null) { - // Allow the input parameter to be parsed by the ParamParser before binding - Set extractors = indexToParamExtractor.get(entry.getKey()); - Object parsedValue = null; - if (extractors != null && extractors.size() > 0) { - ParamParser extractor = (ParamParser) extractors.iterator().next(); - parsedValue = injector.getInstance(extractor.value()).apply(input); - } else { - parsedValue = input; - } - - request = binder.bindToRequest(request, parsedValue); + request = binder.bindToRequest(request, input); } if (shouldBreak) break OUTER; diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index d7dfe69252..3fef693a26 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -2537,48 +2537,6 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { assertEquals(domain.getElem(), "Hello World"); } - public static class AppendTextParser implements Function { - @Override - public String apply(Object input) - { - return input.toString() + "PARSED"; - } - } - - public interface TestBindWithParamParser { - @GET - @Path("/foo") - public ListenableFuture bindWithoutParsing( - @BinderParam(BindToStringPayload.class) String param); - - @GET - @Path("/bar") - public ListenableFuture bindAfterParsing( - @BinderParam(BindToStringPayload.class) @ParamParser(AppendTextParser.class) String param); - } - - @Test - public void testBindWithoutParamParser() throws SecurityException, NoSuchMethodException, IOException { - RestAnnotationProcessor processor = factory(TestBindWithParamParser.class); - Method method = TestBindWithParamParser.class.getMethod("bindWithoutParsing", String.class); - GeneratedHttpRequest request = processor.createRequest(method, "test"); - - assertRequestLineEquals(request, "GET http://localhost:9999/foo HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "test", "application/unknown", false); - } - - @Test - public void testBindWithParamParser() throws SecurityException, NoSuchMethodException, IOException { - RestAnnotationProcessor processor = factory(TestBindWithParamParser.class); - Method method = TestBindWithParamParser.class.getMethod("bindAfterParsing", String.class); - GeneratedHttpRequest request = processor.createRequest(method, "test"); - - assertRequestLineEquals(request, "GET http://localhost:9999/bar HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, "testPARSED", "application/unknown", false); - } - @Test(expectedExceptions = NullPointerException.class) public void testAddHostNullWithHost() throws Exception{ assertNull(RestAnnotationProcessor.addHostIfMissing(null,null));