From e788f7641131324258a6a95ef47837d13b5f7895 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 21 Dec 2011 20:54:06 -0500 Subject: [PATCH 1/2] [issue 461] Replacing a static builder() call with an explicit Builder() creation to prevent and "ambiguous method" compilation error on OpenJDK, Java 7 and others. The compiler can't figure out which static builder() method is the correct one :-( --- .../jclouds/rest/internal/RestAnnotationProcessor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 63baf2dea7..b2bbeb085c 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -423,7 +423,15 @@ public class RestAnnotationProcessor { requestBuilder = GeneratedHttpRequest.Builder. from(r); endpoint = r.getEndpoint(); } else { - requestBuilder = GeneratedHttpRequest. builder(); + /* + * Can't use GeneratedHttpRequest.builder() because the T is too + * general for the compiler to be able to distinguish between + * GeneratedHttpRequest.builder() and HttpMessage.builder() - the + * latter is available because GHR inherits from HM. + * + * See http://code.google.com/p/jclouds/issues/detail?id=461 + */ + requestBuilder = new GeneratedHttpRequest.Builder(); requestBuilder.method(getHttpMethodOrConstantOrThrowException(method)); } From 7cc67a675e7e7d2c9d9337c7f6cf36cda9a85380 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 21 Dec 2011 21:14:03 -0500 Subject: [PATCH 2/2] [issue 461] Fixed compilation failures in tests. Same cause as e788f76411 --- .../jclouds/rest/binders/BindMapToStringPayloadTest.java | 6 ++++-- .../rest/internal/RestAnnotationProcessorTest.java | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java index ae64498c48..c09803d9d2 100644 --- a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java +++ b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java @@ -54,7 +54,8 @@ public class BindMapToStringPayloadTest { @Test public void testCorrect() throws SecurityException, NoSuchMethodException { Method testPayload = TestPayload.class.getMethod("testPayload", String.class); - GeneratedHttpRequest request = GeneratedHttpRequest. builder() + // can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461 + GeneratedHttpRequest request = new GeneratedHttpRequest.Builder() .declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList. of("robot")) .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); @@ -68,7 +69,8 @@ public class BindMapToStringPayloadTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException { Method noPayload = TestPayload.class.getMethod("noPayload", String.class); - GeneratedHttpRequest request = GeneratedHttpRequest. builder() + // can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461 + GeneratedHttpRequest request = new GeneratedHttpRequest.Builder() .declaring(TestPayload.class).javaMethod(noPayload).args(ImmutableList. of("robot")) .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); binder().bindToRequest(request, ImmutableMap.of("fooble", "robot")); 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 0728545c11..6acea0b7a6 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -1816,7 +1816,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void oneTransformerWithContext() throws SecurityException, NoSuchMethodException { RestAnnotationProcessor processor = factory(TestTransformers.class); Method method = TestTransformers.class.getMethod("oneTransformerWithContext"); - GeneratedHttpRequest request = GeneratedHttpRequest. builder().method("GET") + // can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461 + GeneratedHttpRequest request = new GeneratedHttpRequest.Builder().method("GET") .endpoint(URI.create("http://localhost")).declaring(TestTransformers.class).javaMethod(method) .args(new Object[] {}).build(); Function transformer = processor.createResponseParser(method, request); @@ -2348,7 +2349,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testCreateJAXBResponseParserWithAnnotation() throws SecurityException, NoSuchMethodException { RestAnnotationProcessor processor = factory(TestJAXBResponseParser.class); Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAnnotation"); - GeneratedHttpRequest request = GeneratedHttpRequest. builder() + // can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461 + GeneratedHttpRequest request = new GeneratedHttpRequest.Builder() .method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class) .javaMethod(method).args(new Object[] {}).build(); Function transformer = processor.createResponseParser(method, request); @@ -2359,7 +2361,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testCreateJAXBResponseParserWithAcceptHeader() throws SecurityException, NoSuchMethodException { RestAnnotationProcessor processor = factory(TestJAXBResponseParser.class); Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAcceptHeader"); - GeneratedHttpRequest request = GeneratedHttpRequest. builder() + // can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461 + GeneratedHttpRequest request = new GeneratedHttpRequest.Builder() .method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class) .javaMethod(method).args(new Object[] {}).build(); Function transformer = processor.createResponseParser(method, request);