From 99d778c1cacbdbaa448d077ce50d4bf99efaf414 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 9 Dec 2012 10:33:56 -0800 Subject: [PATCH] cleaned up unnecessary wrapping of ExecutionException --- .../rest/config/CreateClientForCaller.java | 4 +- .../internal/RestAnnotationProcessor.java | 383 +++++++++--------- 2 files changed, 192 insertions(+), 195 deletions(-) diff --git a/core/src/main/java/org/jclouds/rest/config/CreateClientForCaller.java b/core/src/main/java/org/jclouds/rest/config/CreateClientForCaller.java index 2a7a9abde3..42a8a58d30 100644 --- a/core/src/main/java/org/jclouds/rest/config/CreateClientForCaller.java +++ b/core/src/main/java/org/jclouds/rest/config/CreateClientForCaller.java @@ -64,11 +64,11 @@ public class CreateClientForCaller extends CacheLoader } @Override - public Object load(ClassMethodArgs from) throws ExecutionException { + public Object load(ClassMethodArgs from) { Class syncClass = Optionals2.returnTypeOrTypeOfOptional(from.getMethod()); Class asyncClass = sync2Async.get(syncClass); checkState(asyncClass != null, "configuration error, sync class " + syncClass + " not mapped to an async class"); - Object asyncClient = asyncMap.get(from); + Object asyncClient = asyncMap.getUnchecked(from); checkState(asyncClient != null, "configuration error, sync client for " + from + " not found"); Function> optionalConverter = injector.getInstance(Key.get(new TypeLiteral>>() { })); 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 76b96a6193..b01de5d59e 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -50,7 +50,6 @@ import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; -import java.util.concurrent.ExecutionException; import javax.annotation.Resource; import javax.inject.Provider; @@ -144,7 +143,6 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; -import com.google.common.base.Throwables; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -323,7 +321,7 @@ public class RestAnnotationProcessor { @Inject public RestAnnotationProcessor(Injector injector, LoadingCache, Boolean> seedAnnotationCache, Cache delegationMap, @ApiVersion String apiVersion, @BuildVersion String buildVersion, ParseSax.Factory parserFactory, - HttpUtils utils, ContentMetadataCodec contentMetadataCodec, TypeLiteral typeLiteral) throws ExecutionException { + HttpUtils utils, ContentMetadataCodec contentMetadataCodec, TypeLiteral typeLiteral) { this.declaring = (Class) typeLiteral.getRawType(); this.injector = injector; this.parserFactory = parserFactory; @@ -331,7 +329,7 @@ public class RestAnnotationProcessor { this.contentMetadataCodec = contentMetadataCodec; this.uriBuilderProvider = injector.getProvider(UriBuilder.class); this.seedAnnotationCache = seedAnnotationCache; - seedAnnotationCache.get(declaring); + seedAnnotationCache.getUnchecked(declaring); this.delegationMap = delegationMap; if (declaring.isAnnotationPresent(SkipEncoding.class)) { skips = declaring.getAnnotation(SkipEncoding.class).value(); @@ -385,170 +383,161 @@ public class RestAnnotationProcessor { private URI callerEndpoint; public void setCaller(ClassMethodArgs caller) { - try { - seedAnnotationCache.get(caller.getMethod().getDeclaringClass()); - } catch (ExecutionException e) { - Throwables.propagate(e); - } + seedAnnotationCache.getUnchecked(caller.getMethod().getDeclaringClass()); this.caller = caller; try { UriBuilder builder = uriBuilderProvider.get().uri(getEndpointFor(caller.getMethod(), caller.getArgs(), injector)); Multimap tokenValues = addPathAndGetTokens(caller.getMethod().getDeclaringClass(), caller.getMethod(), caller.getArgs(), builder); callerEndpoint = builder.buildFromEncodedMap(Maps2.convertUnsafe(tokenValues)); } catch (IllegalStateException e) { - } catch (ExecutionException e) { - Throwables.propagate(e); + // no endpoint annotation } } public GeneratedHttpRequest createRequest(Method method, Object... args) { + inputParamValidator.validateMethodParametersOrThrow(method, args); + ClassMethodArgs cma = logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args) + : null; + + URI endpoint = callerEndpoint; try { - inputParamValidator.validateMethodParametersOrThrow(method, args); - ClassMethodArgs cma = logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args) - : null; - - URI endpoint = callerEndpoint; - try { - if (endpoint == null) { - endpoint = getEndpointFor(method, args, injector); - logger.trace("using endpoint %s for %s", endpoint, cma); - } else { - logger.trace("using endpoint %s from caller %s for %s", caller, endpoint, cma); - } - } catch (IllegalStateException e) { - logger.trace("looking up default endpoint for %s", cma); - endpoint = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); - logger.trace("using default endpoint %s for %s", endpoint, cma); - } - GeneratedHttpRequest.Builder requestBuilder; - HttpRequest r = RestAnnotationProcessor.findHttpRequestInArgs(args); - if (r != null) { - requestBuilder = GeneratedHttpRequest.builder().fromHttpRequest(r); - endpoint = r.getEndpoint(); - } else { - requestBuilder = GeneratedHttpRequest.builder(); - requestBuilder.method(getHttpMethodOrConstantOrThrowException(method)); - } - if (endpoint == null) { - throw new NoSuchElementException(String.format("no endpoint found for %s", - new ClassMethodArgs(method.getDeclaringClass(), method, args))); - } - - requestBuilder.declaring(declaring) - .javaMethod(method) - .args(args) - .caller(caller) - .skips(skips) - .filters(getFiltersIfAnnotated(method)); - - UriBuilder builder = uriBuilderProvider.get().uri(endpoint); - - Multimap tokenValues = LinkedHashMultimap.create(); - - tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion); - tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion); - - tokenValues.putAll(addPathAndGetTokens(declaring, method, args, builder)); - - Multimap formParams = addFormParams(tokenValues.entries(), method, args); - Multimap queryParams = addQueryParams(tokenValues.entries(), method, args); - Multimap matrixParams = addMatrixParams(tokenValues.entries(), method, args); - Multimap headers = buildHeaders(tokenValues.entries(), method, args); - if (r != null) - headers.putAll(r.getHeaders()); - - if (shouldAddHostHeader(method)) { - StringBuilder hostHeader = new StringBuilder(endpoint.getHost()); - if (endpoint.getPort() != -1) - hostHeader.append(":").append(endpoint.getPort()); - headers.put(HOST, hostHeader.toString()); - } - - Payload payload = null; - for(HttpRequestOptions options : findOptionsIn(method, args)) { - injector.injectMembers(options);// TODO test case - for (Entry header : options.buildRequestHeaders().entries()) { - headers.put(header.getKey(), Strings2.replaceTokens(header.getValue(), tokenValues.entries())); - } - for (Entry matrix : options.buildMatrixParameters().entries()) { - matrixParams.put(matrix.getKey(), Strings2.replaceTokens(matrix.getValue(), tokenValues.entries())); - } - for (Entry query : options.buildQueryParameters().entries()) { - queryParams.put(query.getKey(), Strings2.replaceTokens(query.getValue(), tokenValues.entries())); - } - for (Entry form : options.buildFormParameters().entries()) { - formParams.put(form.getKey(), Strings2.replaceTokens(form.getValue(), tokenValues.entries())); - } - - String pathSuffix = options.buildPathSuffix(); - if (pathSuffix != null) { - builder.path(pathSuffix); - } - String stringPayload = options.buildStringPayload(); - if (stringPayload != null) - payload = Payloads.newStringPayload(stringPayload); - } - - if (matrixParams.size() > 0) { - for (String key : matrixParams.keySet()) - builder.matrixParam(key, Lists.newArrayList(matrixParams.get(key)).toArray()); - } - - if (queryParams.size() > 0) { - builder.replaceQuery(Queries.makeQueryLine(queryParams, null, skips)); - } - - requestBuilder.headers(filterOutContentHeaders(headers)); - - try { - requestBuilder.endpoint(builder.buildFromEncodedMap(Maps2.convertUnsafe(tokenValues))); - } catch (IllegalArgumentException e) { - throw new IllegalStateException(e); - } catch (UriBuilderException e) { - throw new IllegalStateException(e); - } - - if (payload == null) - payload = findPayloadInArgs(args); - List parts = getParts(method, args, concat(tokenValues.entries(), formParams.entries())); - if (parts.size() > 0) { - if (formParams.size() > 0) { - parts = newLinkedList(concat(transform(formParams.entries(), ENTRY_TO_PART), parts)); - } - payload = new MultipartForm(BOUNDARY, parts); - } else if (formParams.size() > 0) { - payload = Payloads.newUrlEncodedFormPayload(formParams, skips); - } else if (headers.containsKey(CONTENT_TYPE)) { - if (payload == null) - payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType(Iterables.get(headers.get(CONTENT_TYPE), 0)); - } - if (payload != null) { - requestBuilder.payload(payload); - } - GeneratedHttpRequest request = requestBuilder.build(); - - org.jclouds.rest.MapBinder mapBinder = getMapPayloadBinderOrNull(method, args); - if (mapBinder != null) { - Map mapParams = buildPostParams(method, args); - if (method.isAnnotationPresent(PayloadParams.class)) { - PayloadParams params = method.getAnnotation(PayloadParams.class); - addMapPayload(mapParams, params, headers.entries()); - } - request = mapBinder.bindToRequest(request, mapParams); + endpoint = getEndpointFor(method, args, injector); + logger.trace("using endpoint %s for %s", endpoint, cma); } else { - request = decorateRequest(request); + logger.trace("using endpoint %s from caller %s for %s", caller, endpoint, cma); + } + } catch (IllegalStateException e) { + logger.trace("looking up default endpoint for %s", cma); + endpoint = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get(); + logger.trace("using default endpoint %s for %s", endpoint, cma); + } + GeneratedHttpRequest.Builder requestBuilder; + HttpRequest r = RestAnnotationProcessor.findHttpRequestInArgs(args); + if (r != null) { + requestBuilder = GeneratedHttpRequest.builder().fromHttpRequest(r); + endpoint = r.getEndpoint(); + } else { + requestBuilder = GeneratedHttpRequest.builder(); + requestBuilder.method(getHttpMethodOrConstantOrThrowException(method)); + } + + if (endpoint == null) { + throw new NoSuchElementException(String.format("no endpoint found for %s", + new ClassMethodArgs(method.getDeclaringClass(), method, args))); + } + + requestBuilder.declaring(declaring) + .javaMethod(method) + .args(args) + .caller(caller) + .skips(skips) + .filters(getFiltersIfAnnotated(method)); + + UriBuilder builder = uriBuilderProvider.get().uri(endpoint); + + Multimap tokenValues = LinkedHashMultimap.create(); + + tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion); + tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion); + + tokenValues.putAll(addPathAndGetTokens(declaring, method, args, builder)); + + Multimap formParams = addFormParams(tokenValues.entries(), method, args); + Multimap queryParams = addQueryParams(tokenValues.entries(), method, args); + Multimap matrixParams = addMatrixParams(tokenValues.entries(), method, args); + Multimap headers = buildHeaders(tokenValues.entries(), method, args); + if (r != null) + headers.putAll(r.getHeaders()); + + if (shouldAddHostHeader(method)) { + StringBuilder hostHeader = new StringBuilder(endpoint.getHost()); + if (endpoint.getPort() != -1) + hostHeader.append(":").append(endpoint.getPort()); + headers.put(HOST, hostHeader.toString()); + } + + Payload payload = null; + for(HttpRequestOptions options : findOptionsIn(method, args)) { + injector.injectMembers(options);// TODO test case + for (Entry header : options.buildRequestHeaders().entries()) { + headers.put(header.getKey(), Strings2.replaceTokens(header.getValue(), tokenValues.entries())); + } + for (Entry matrix : options.buildMatrixParameters().entries()) { + matrixParams.put(matrix.getKey(), Strings2.replaceTokens(matrix.getValue(), tokenValues.entries())); + } + for (Entry query : options.buildQueryParameters().entries()) { + queryParams.put(query.getKey(), Strings2.replaceTokens(query.getValue(), tokenValues.entries())); + } + for (Entry form : options.buildFormParameters().entries()) { + formParams.put(form.getKey(), Strings2.replaceTokens(form.getValue(), tokenValues.entries())); } - if (request.getPayload() != null) { - contentMetadataCodec.fromHeaders(request.getPayload().getContentMetadata(), headers); + String pathSuffix = options.buildPathSuffix(); + if (pathSuffix != null) { + builder.path(pathSuffix); } - utils.checkRequestHasRequiredProperties(request); - return request; - } catch (ExecutionException e) { - throw Throwables.propagate(e); + String stringPayload = options.buildStringPayload(); + if (stringPayload != null) + payload = Payloads.newStringPayload(stringPayload); } + + if (matrixParams.size() > 0) { + for (String key : matrixParams.keySet()) + builder.matrixParam(key, Lists.newArrayList(matrixParams.get(key)).toArray()); + } + + if (queryParams.size() > 0) { + builder.replaceQuery(Queries.makeQueryLine(queryParams, null, skips)); + } + + requestBuilder.headers(filterOutContentHeaders(headers)); + + try { + requestBuilder.endpoint(builder.buildFromEncodedMap(Maps2.convertUnsafe(tokenValues))); + } catch (IllegalArgumentException e) { + throw new IllegalStateException(e); + } catch (UriBuilderException e) { + throw new IllegalStateException(e); + } + + if (payload == null) + payload = findPayloadInArgs(args); + List parts = getParts(method, args, concat(tokenValues.entries(), formParams.entries())); + if (parts.size() > 0) { + if (formParams.size() > 0) { + parts = newLinkedList(concat(transform(formParams.entries(), ENTRY_TO_PART), parts)); + } + payload = new MultipartForm(BOUNDARY, parts); + } else if (formParams.size() > 0) { + payload = Payloads.newUrlEncodedFormPayload(formParams, skips); + } else if (headers.containsKey(CONTENT_TYPE)) { + if (payload == null) + payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType(Iterables.get(headers.get(CONTENT_TYPE), 0)); + } + if (payload != null) { + requestBuilder.payload(payload); + } + GeneratedHttpRequest request = requestBuilder.build(); + + org.jclouds.rest.MapBinder mapBinder = getMapPayloadBinderOrNull(method, args); + if (mapBinder != null) { + Map mapParams = buildPostParams(method, args); + if (method.isAnnotationPresent(PayloadParams.class)) { + PayloadParams params = method.getAnnotation(PayloadParams.class); + addMapPayload(mapParams, params, headers.entries()); + } + request = mapBinder.bindToRequest(request, mapParams); + } else { + request = decorateRequest(request); + } + + if (request.getPayload() != null) { + contentMetadataCodec.fromHeaders(request.getPayload().getContentMetadata(), headers); + } + utils.checkRequestHasRequiredProperties(request); + return request; } public static Multimap filterOutContentHeaders(Multimap headers) { @@ -562,7 +551,7 @@ public class RestAnnotationProcessor { public static final String BOUNDARY = "--JCLOUDS--"; - private Multimap addPathAndGetTokens(Class clazz, Method method, Object[] args, UriBuilder builder) throws ExecutionException { + private Multimap addPathAndGetTokens(Class clazz, Method method, Object[] args, UriBuilder builder) { if (clazz.isAnnotationPresent(Path.class)) builder.path(clazz); if (method.isAnnotationPresent(Path.class)) @@ -582,7 +571,7 @@ public class RestAnnotationProcessor { } private Multimap addMatrixParams(Collection> tokenValues, Method method, - Object... args) throws ExecutionException { + Object... args) { Multimap matrixMap = LinkedListMultimap.create(); if (declaring.isAnnotationPresent(MatrixParams.class)) { MatrixParams matrix = declaring.getAnnotation(MatrixParams.class); @@ -601,7 +590,7 @@ public class RestAnnotationProcessor { } private Multimap addFormParams(Collection> tokenValues, Method method, - Object... args) throws ExecutionException { + Object... args) { Multimap formMap = LinkedListMultimap.create(); if (declaring.isAnnotationPresent(FormParams.class)) { FormParams form = declaring.getAnnotation(FormParams.class); @@ -620,7 +609,7 @@ public class RestAnnotationProcessor { } private Multimap addQueryParams(Collection> tokenValues, Method method, - Object... args) throws ExecutionException { + Object... args) { Multimap queryMap = LinkedListMultimap.create(); if (declaring.isAnnotationPresent(QueryParams.class)) { QueryParams query = declaring.getAnnotation(QueryParams.class); @@ -711,7 +700,7 @@ public class RestAnnotationProcessor { //TODO: change to LoadingCache> and move this logic to the CacheLoader. @VisibleForTesting public static URI getEndpointInParametersOrNull(Method method, final Object[] args, Injector injector) - throws ExecutionException { + { Map> map = indexWithAtLeastOneAnnotation(method, methodToIndexOfParamToEndpointParamAnnotations); if (map.size() >= 1 && args.length > 0) { @@ -756,7 +745,7 @@ public class RestAnnotationProcessor { }; // TODO: change to LoadingCache and move this logic to the CacheLoader. - public static URI getEndpointFor(Method method, Object[] args, Injector injector) throws ExecutionException { + public static URI getEndpointFor(Method method, Object[] args, Injector injector) { URI endpoint = getEndpointInParametersOrNull(method, args, injector); if (endpoint == null) { Endpoint annotation; @@ -950,13 +939,13 @@ public class RestAnnotationProcessor { } }; - public GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request) throws NegativeArraySizeException, - ExecutionException { - OUTER: for (Entry> entry : concat(// - filterValues(methodToIndexOfParamToBinderParamAnnotation.get(request.getJavaMethod()).asMap(), notEmpty) - .entrySet(), // - filterValues(methodToIndexOfParamToWrapWithAnnotation.get(request.getJavaMethod()).asMap(), notEmpty) - .entrySet())) { + public GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request) throws NegativeArraySizeException { + Iterable>> binderOrWrapWith = concat( + filterValues(methodToIndexOfParamToBinderParamAnnotation.getUnchecked(request.getJavaMethod()).asMap(), + notEmpty).entrySet(), + filterValues(methodToIndexOfParamToWrapWithAnnotation.getUnchecked(request.getJavaMethod()).asMap(), + notEmpty).entrySet()); + OUTER: for (Entry> entry : binderOrWrapWith) { boolean shouldBreak = false; Annotation annotation = Iterables.get(entry.getValue(), 0); Binder binder; @@ -1018,7 +1007,7 @@ public class RestAnnotationProcessor { } public static Map> indexWithOnlyOneAnnotation(Method method, String description, - LoadingCache>> toRefine) throws ExecutionException { + LoadingCache>> toRefine) { Map> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine); if (indexToPayloadAnnotation.size() > 1) { throw new IllegalStateException(String.format( @@ -1029,8 +1018,8 @@ public class RestAnnotationProcessor { } private static Map> indexWithAtLeastOneAnnotation(Method method, - LoadingCache>> toRefine) throws ExecutionException { - Map> indexToPayloadAnnotation = filterValues(toRefine.get(method).asMap(), + LoadingCache>> toRefine) { + Map> indexToPayloadAnnotation = filterValues(toRefine.getUnchecked(method).asMap(), new Predicate>() { public boolean apply(Set input) { return input.size() == 1; @@ -1040,9 +1029,9 @@ public class RestAnnotationProcessor { } //TODO: change to LoadingCache findOptionsIn(Method method, Object... args) throws ExecutionException { + private Set findOptionsIn(Method method, Object... args) { ImmutableSet.Builder result = ImmutableSet.builder(); - for (int index : methodToIndexesOfOptions.get(method)) { + for (int index : methodToIndexesOfOptions.getUnchecked(method)) { if (args.length >= index + 1) {// accommodate varargs if (args[index] instanceof Object[]) { for (Object option : (Object[]) args[index]) { @@ -1063,10 +1052,11 @@ public class RestAnnotationProcessor { } public Multimap buildHeaders(Collection> tokenValues, Method method, - final Object... args) throws ExecutionException { + final Object... args) { Multimap headers = LinkedHashMultimap.create(); addHeaderIfAnnotationPresentOnMethod(headers, method, tokenValues); - LoadingCache> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations.get(method); + LoadingCache> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations + .getUnchecked(method); for (Entry> entry : indexToHeaderParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { String value = args[entry.getKey()].toString(); @@ -1131,9 +1121,10 @@ public class RestAnnotationProcessor { } - List getParts(Method method, Object[] args, Iterable> iterable) throws ExecutionException { + List getParts(Method method, Object[] args, Iterable> iterable) { List parts = newLinkedList(); - LoadingCache> indexToPartParam = methodToIndexOfParamToPartParamAnnotations.get(method); + LoadingCache> indexToPartParam = methodToIndexOfParamToPartParamAnnotations + .getUnchecked(method); for (Entry> entry : indexToPartParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { PartParam param = (PartParam) key; @@ -1172,14 +1163,14 @@ public class RestAnnotationProcessor { } //TODO: change to LoadingCache and move this logic to the CacheLoader. - private Multimap getPathParamKeyValues(Method method, Object... args) throws ExecutionException { + private Multimap getPathParamKeyValues(Method method, Object... args) { Multimap pathParamValues = LinkedHashMultimap.create(); - LoadingCache> indexToPathParam = methodToIndexOfParamToPathParamAnnotations.get(method); + LoadingCache> indexToPathParam = methodToIndexOfParamToPathParamAnnotations.getUnchecked(method); - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method); + LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.getUnchecked(method); for (Entry> entry : indexToPathParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.get(entry.getKey()); + Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); String paramKey = ((PathParam) key).value(); Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); if (paramValue.isPresent()) @@ -1240,14 +1231,16 @@ public class RestAnnotationProcessor { } //TODO: change to LoadingCache and move this logic to the CacheLoader. - private Multimap getMatrixParamKeyValues(Method method, Object... args) throws ExecutionException { + private Multimap getMatrixParamKeyValues(Method method, Object... args) { Multimap matrixParamValues = LinkedHashMultimap.create(); - LoadingCache> indexToMatrixParam = methodToIndexOfParamToMatrixParamAnnotations.get(method); + LoadingCache> indexToMatrixParam = methodToIndexOfParamToMatrixParamAnnotations + .getUnchecked(method); - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method); + LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations + .getUnchecked(method); for (Entry> entry : indexToMatrixParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.get(entry.getKey()); + Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); String paramKey = ((MatrixParam) key).value(); Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); if (paramValue.isPresent()) @@ -1266,14 +1259,16 @@ public class RestAnnotationProcessor { //TODO: change to LoadingCache and move this logic to the CacheLoader. //take care to manage size of this cache - private Multimap getFormParamKeyValues(Method method, Object... args) throws ExecutionException { + private Multimap getFormParamKeyValues(Method method, Object... args) { Multimap formParamValues = LinkedHashMultimap.create(); - LoadingCache> indexToFormParam = methodToIndexOfParamToFormParamAnnotations.get(method); + LoadingCache> indexToFormParam = methodToIndexOfParamToFormParamAnnotations + .getUnchecked(method); - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method); + LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations + .getUnchecked(method); for (Entry> entry : indexToFormParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.get(entry.getKey()); + Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); String paramKey = ((FormParam) key).value(); Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); if (paramValue.isPresent()) @@ -1291,14 +1286,16 @@ public class RestAnnotationProcessor { } //TODO: change to LoadingCache and move this logic to the CacheLoader. - private Multimap getQueryParamKeyValues(Method method, Object... args) throws ExecutionException { + private Multimap getQueryParamKeyValues(Method method, Object... args) { Multimap queryParamValues = LinkedHashMultimap.create(); - LoadingCache> indexToQueryParam = methodToIndexOfParamToQueryParamAnnotations.get(method); + LoadingCache> indexToQueryParam = methodToIndexOfParamToQueryParamAnnotations + .getUnchecked(method); - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method); + LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations + .getUnchecked(method); for (Entry> entry : indexToQueryParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.get(entry.getKey()); + Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); String paramKey = ((QueryParam) key).value(); Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); if (paramValue.isPresent()) @@ -1317,13 +1314,13 @@ public class RestAnnotationProcessor { //TODO: change to LoadingCache and move this logic to the CacheLoader. //take care to manage size of this cache - private Map buildPostParams(Method method, Object... args) throws ExecutionException { + private Map buildPostParams(Method method, Object... args) { Map postParams = newHashMap(); - LoadingCache> indexToPathParam = methodToIndexOfParamToPostParamAnnotations.get(method); - LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method); + LoadingCache> indexToPathParam = methodToIndexOfParamToPostParamAnnotations.getUnchecked(method); + LoadingCache> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.getUnchecked(method); for (Entry> entry : indexToPathParam.asMap().entrySet()) { for (Annotation key : entry.getValue()) { - Set extractors = indexToParamExtractor.get(entry.getKey()); + Set extractors = indexToParamExtractor.getUnchecked(entry.getKey()); String paramKey = ((PayloadParam) key).value(); Optional paramValue = getParamValue(method, args, extractors, entry, paramKey); if (paramValue.isPresent())