Temporarily use a custom annotation instead of @SinceApiVersion.

The intention is to use @SinceApiVersion for this purpose, but that
would affect a number of APIs, and we would want to have good test
coverage before merging that change (in
FormSignerUtils#getAnnotatedApiVersion). However, there is some issue
wth certain tests at resent that means we cannot successfully test
all APIs that make use of @SinceApiVersion in order to assure
ourselves that FormSignerUtils will not introduce some problem.

See https://github.com/jclouds/jclouds/pull/1102#issuecomment-302682049
for details.

This annotation is introduced as a temporary measure in order to
decouple the functionality of FormSignerUtils#getAnnotatedApiVersion
from @SinceApiVersion and the tests in question. It can be removed and
replaced by @SinceApiVersion when those tests are fixed.

Designates that a method overrides the {@link ApiVersion} on the class
with a specific value.
This commit is contained in:
Geoff Macartney 2017-05-26 15:22:21 +01:00 committed by Ignasi Barrera
parent ce0a0ad213
commit 28c3c33bf0
3 changed files with 64 additions and 7 deletions

View File

@ -18,7 +18,7 @@ package org.jclouds.aws.filters;
import org.jclouds.http.HttpRequest;
import org.jclouds.reflect.Invocation;
import org.jclouds.rest.annotations.SinceApiVersion;
import org.jclouds.rest.annotations.ApiVersionOverride;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.base.Optional;
@ -32,7 +32,7 @@ public final class FormSignerUtils {
private FormSignerUtils() {}
/**
* Get the version from a @SinceApiVersion() annotation on an API method or its owning class.
* Get the version from a @ApiVersionOverride() annotation on an API method or its owning class.
* @param request The API request for the method.
* @return An optional of the value of the annotation.
*/
@ -47,12 +47,12 @@ public final class FormSignerUtils {
private static Optional<String> getAnnotatedApiVersion(Invocation invocation) {
final Invokable<?, ?> invokable = invocation.getInvokable();
if (invokable.isAnnotationPresent(SinceApiVersion.class)) {
return Optional.fromNullable(invokable.getAnnotation(SinceApiVersion.class).value());
if (invokable.isAnnotationPresent(ApiVersionOverride.class)) {
return Optional.fromNullable(invokable.getAnnotation(ApiVersionOverride.class).value());
} else {
final Class<?> owner = invokable.getOwnerType().getRawType();
if (owner.isAnnotationPresent(SinceApiVersion.class)) {
return Optional.fromNullable(owner.getAnnotation(SinceApiVersion.class).value());
if (owner.isAnnotationPresent(ApiVersionOverride.class)) {
return Optional.fromNullable(owner.getAnnotation(ApiVersionOverride.class).value());
}
}
return Optional.absent();

View File

@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.rest.annotations;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* @Deprecated The intention is to use @SinceApiVersion for this purpose, but that would affect
* a number of APIs, and we would want to have good test coverage before merging that change
* (in {@link FormSignerUtils#getAnnotatedApiVersion}). However, there is some issue with certain tests at
* present that means we cannot successfully test all APIs that make use of @SinceApiVersion in order
* to assure ourselves that FormSignerUtils will not introduce some problem. See
* <a href="https://github.com/jclouds/jclouds/pull/1102#issuecomment-302682049">
* comments on github</a> for details
* This annotation is introduced as a temporary measure in order to decouple the functionality of
* {@link FormSignerUtils#getAnnotatedApiVersion} from @SinceApiVersion and the tests in question.
* It can be removed and replaced by @SinceApiVersion when those tests are fixed.
*
* Designates that a method overrides the {@link ApiVersion} on the class with a specific value.
*
* @see ApiVersion
*/
@Deprecated
@Target({ METHOD })
@Retention(RUNTIME)
@Qualifier
public @interface ApiVersionOverride {
/**
* Value to override the default {@link ApiVersion}.
*
*/
String value();
}

View File

@ -36,6 +36,7 @@ import org.jclouds.ec2.xml.DescribeSubnetsResponseHandler;
import org.jclouds.ec2.xml.SubnetHandler;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.rest.annotations.ApiVersionOverride;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
@ -141,7 +142,7 @@ public interface AWSSubnetApi extends SubnetApi {
* @param options The options containing the attribute to modify. You can only modify one attribute at a time.
* @return true if the modification was successful
*/
@SinceApiVersion("2014-06-15")
@ApiVersionOverride("2014-06-15")
@Named("ModifySubnetAttribute")
@POST
@Path("/")