Skip to content

Commit a874b45

Browse files
committed
Formatted code using google code style for java
1 parent ac1312e commit a874b45

File tree

412 files changed

+11422
-9746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

412 files changed

+11422
-9746
lines changed

.mvn/jvm.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1+
--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
2+
--add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4+
--add-opens jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED
5+
--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
6+
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
7+
--add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
--add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
9+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
10+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
11+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
12+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
13+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
114
-XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom

annotation-error-decoder/src/main/java/feign/error/AnnotationErrorDecoder.java

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package feign.error;
1515

16+
import static feign.Feign.configKey;
17+
1618
import feign.Response;
1719
import feign.codec.Decoder;
1820
import feign.codec.ErrorDecoder;
@@ -22,16 +24,14 @@
2224
import java.util.HashMap;
2325
import java.util.Map;
2426
import java.util.Optional;
25-
import static feign.Feign.configKey;
2627

2728
public class AnnotationErrorDecoder implements ErrorDecoder {
2829

2930
private final Map<String, MethodErrorHandler> errorHandlerMap;
3031
private final ErrorDecoder defaultDecoder;
3132

32-
33-
AnnotationErrorDecoder(Map<String, MethodErrorHandler> errorHandlerMap,
34-
ErrorDecoder defaultDecoder) {
33+
AnnotationErrorDecoder(
34+
Map<String, MethodErrorHandler> errorHandlerMap, ErrorDecoder defaultDecoder) {
3535
this.errorHandlerMap = errorHandlerMap;
3636
this.defaultDecoder = defaultDecoder;
3737
}
@@ -44,7 +44,6 @@ public Exception decode(String methodKey, Response response) {
4444
return defaultDecoder.decode(methodKey, response);
4545
}
4646

47-
4847
public static AnnotationErrorDecoder.Builder builderFor(Class<?> apiType) {
4948
return new Builder(apiType);
5049
}
@@ -54,7 +53,6 @@ public static class Builder {
5453
private ErrorDecoder defaultDecoder = new ErrorDecoder.Default();
5554
private Decoder responseBodyDecoder = new Decoder.Default();
5655

57-
5856
public Builder(Class<?> apiType) {
5957
this.apiType = apiType;
6058
}
@@ -76,10 +74,11 @@ public AnnotationErrorDecoder build() {
7674

7775
Map<String, MethodErrorHandler> generateErrorHandlerMapFromApi(Class<?> apiType) {
7876

79-
ExceptionGenerator classLevelDefault = new ExceptionGenerator.Builder()
80-
.withResponseBodyDecoder(responseBodyDecoder)
81-
.withExceptionType(ErrorHandling.NO_DEFAULT.class)
82-
.build();
77+
ExceptionGenerator classLevelDefault =
78+
new ExceptionGenerator.Builder()
79+
.withResponseBodyDecoder(responseBodyDecoder)
80+
.withExceptionType(ErrorHandling.NO_DEFAULT.class)
81+
.build();
8382
Map<Integer, ExceptionGenerator> classLevelStatusCodeDefinitions =
8483
new HashMap<Integer, ExceptionGenerator>();
8584

@@ -105,8 +104,10 @@ Map<String, MethodErrorHandler> generateErrorHandlerMapFromApi(Class<?> apiType)
105104
}
106105

107106
MethodErrorHandler methodErrorHandler =
108-
new MethodErrorHandler(methodErrorHandling.statusCodesMap,
109-
classLevelStatusCodeDefinitions, methodDefault);
107+
new MethodErrorHandler(
108+
methodErrorHandling.statusCodesMap,
109+
classLevelStatusCodeDefinitions,
110+
methodDefault);
110111

111112
methodErrorHandlerMap.put(configKey(apiType, method), methodErrorHandler);
112113
}
@@ -147,25 +148,32 @@ private static ErrorHandling getErrorHandlingAnnotation(AnnotatedElement element
147148
return annotation;
148149
}
149150

150-
static ErrorHandlingDefinition readAnnotation(ErrorHandling errorHandling,
151-
Decoder responseBodyDecoder) {
152-
ExceptionGenerator defaultException = new ExceptionGenerator.Builder()
153-
.withResponseBodyDecoder(responseBodyDecoder)
154-
.withExceptionType(errorHandling.defaultException())
155-
.build();
151+
static ErrorHandlingDefinition readAnnotation(
152+
ErrorHandling errorHandling, Decoder responseBodyDecoder) {
153+
ExceptionGenerator defaultException =
154+
new ExceptionGenerator.Builder()
155+
.withResponseBodyDecoder(responseBodyDecoder)
156+
.withExceptionType(errorHandling.defaultException())
157+
.build();
156158
Map<Integer, ExceptionGenerator> statusCodesDefinition =
157159
new HashMap<Integer, ExceptionGenerator>();
158160

159161
for (ErrorCodes statusCodeDefinition : errorHandling.codeSpecific()) {
160162
for (int statusCode : statusCodeDefinition.codes()) {
161163
if (statusCodesDefinition.containsKey(statusCode)) {
162164
throw new IllegalStateException(
163-
"Status Code [" + statusCode + "] " +
164-
"has already been declared to throw ["
165-
+ statusCodesDefinition.get(statusCode).getExceptionType().getName() + "] " +
166-
"and [" + statusCodeDefinition.generate() + "] - dupe definition");
165+
"Status Code ["
166+
+ statusCode
167+
+ "] "
168+
+ "has already been declared to throw ["
169+
+ statusCodesDefinition.get(statusCode).getExceptionType().getName()
170+
+ "] "
171+
+ "and ["
172+
+ statusCodeDefinition.generate()
173+
+ "] - dupe definition");
167174
}
168-
statusCodesDefinition.put(statusCode,
175+
statusCodesDefinition.put(
176+
statusCode,
169177
new ExceptionGenerator.Builder()
170178
.withResponseBodyDecoder(responseBodyDecoder)
171179
.withExceptionType(statusCodeDefinition.generate())
@@ -180,9 +188,8 @@ private static class ErrorHandlingDefinition {
180188
private final ExceptionGenerator defaultThrow;
181189
private final Map<Integer, ExceptionGenerator> statusCodesMap;
182190

183-
184-
private ErrorHandlingDefinition(ExceptionGenerator defaultThrow,
185-
Map<Integer, ExceptionGenerator> statusCodesMap) {
191+
private ErrorHandlingDefinition(
192+
ExceptionGenerator defaultThrow, Map<Integer, ExceptionGenerator> statusCodesMap) {
186193
this.defaultThrow = defaultThrow;
187194
this.statusCodesMap = statusCodesMap;
188195
}

annotation-error-decoder/src/main/java/feign/error/ExceptionGenerator.java

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package feign.error;
1515

16+
import static feign.Util.checkState;
17+
1618
import feign.Request;
1719
import feign.Response;
1820
import feign.Types;
@@ -27,7 +29,6 @@
2729
import java.util.Collection;
2830
import java.util.HashMap;
2931
import java.util.Map;
30-
import static feign.Util.checkState;
3132

3233
class ExceptionGenerator {
3334

@@ -37,13 +38,15 @@ class ExceptionGenerator {
3738
Map<String, Collection<String>> testHeaders = new HashMap<String, Collection<String>>();
3839
testHeaders.put("TestHeader", Arrays.asList("header-value"));
3940

40-
TEST_RESPONSE = Response.builder()
41-
.status(500)
42-
.body((Response.Body) null)
43-
.headers(testHeaders)
44-
.request(Request.create(Request.HttpMethod.GET, "http://test", testHeaders,
45-
Request.Body.empty(), null))
46-
.build();
41+
TEST_RESPONSE =
42+
Response.builder()
43+
.status(500)
44+
.body((Response.Body) null)
45+
.headers(testHeaders)
46+
.request(
47+
Request.create(
48+
Request.HttpMethod.GET, "http://test", testHeaders, Request.Body.empty(), null))
49+
.build();
4750
}
4851

4952
private final Integer bodyIndex;
@@ -54,9 +57,14 @@ class ExceptionGenerator {
5457
private final Class<? extends Exception> exceptionType;
5558
private final Decoder bodyDecoder;
5659

57-
ExceptionGenerator(Integer bodyIndex, Integer requestIndex, Integer headerMapIndex,
58-
Integer numOfParams, Type bodyType,
59-
Class<? extends Exception> exceptionType, Decoder bodyDecoder) {
60+
ExceptionGenerator(
61+
Integer bodyIndex,
62+
Integer requestIndex,
63+
Integer headerMapIndex,
64+
Integer numOfParams,
65+
Type bodyType,
66+
Class<? extends Exception> exceptionType,
67+
Decoder bodyDecoder) {
6068
this.bodyIndex = bodyIndex;
6169
this.requestIndex = requestIndex;
6270
this.headerMapIndex = headerMapIndex;
@@ -66,9 +74,11 @@ class ExceptionGenerator {
6674
this.bodyDecoder = bodyDecoder;
6775
}
6876

69-
70-
Exception createException(Response response) throws InvocationTargetException,
71-
NoSuchMethodException, InstantiationException, IllegalAccessException {
77+
Exception createException(Response response)
78+
throws InvocationTargetException,
79+
NoSuchMethodException,
80+
InstantiationException,
81+
IllegalAccessException {
7282

7383
Class<?>[] paramClasses = new Class[numOfParams];
7484
Object[] paramValues = new Object[numOfParams];
@@ -84,9 +94,7 @@ Exception createException(Response response) throws InvocationTargetException,
8494
paramValues[headerMapIndex] = response.headers();
8595
paramClasses[headerMapIndex] = Map.class;
8696
}
87-
return exceptionType.getConstructor(paramClasses)
88-
.newInstance(paramValues);
89-
97+
return exceptionType.getConstructor(paramClasses).newInstance(paramValues);
9098
}
9199

92100
Class<? extends Exception> getExceptionType() {
@@ -138,37 +146,44 @@ public ExceptionGenerator build() {
138146
boolean foundAnnotation = false;
139147
for (Annotation annotation : paramAnnotations) {
140148
if (annotation.annotationType().equals(ResponseHeaders.class)) {
141-
checkState(headerMapIndex == -1,
142-
"Cannot have two parameters tagged with @ResponseHeaders");
143-
checkState(Types.getRawType(parameterTypes[i]).equals(Map.class),
144-
"Response Header map must be of type Map, but was %s", parameterTypes[i]);
149+
checkState(
150+
headerMapIndex == -1, "Cannot have two parameters tagged with @ResponseHeaders");
151+
checkState(
152+
Types.getRawType(parameterTypes[i]).equals(Map.class),
153+
"Response Header map must be of type Map, but was %s",
154+
parameterTypes[i]);
145155
headerMapIndex = i;
146156
foundAnnotation = true;
147157
break;
148158
}
149159
}
150160
if (!foundAnnotation) {
151161
if (parameterTypes[i].equals(Request.class)) {
152-
checkState(requestIndex == -1,
153-
"Cannot have two parameters either without annotations or with object of type feign.Request");
162+
checkState(
163+
requestIndex == -1,
164+
"Cannot have two parameters either without annotations or with object of type"
165+
+ " feign.Request");
154166
requestIndex = i;
155167
} else {
156-
checkState(bodyIndex == -1,
157-
"Cannot have two parameters either without annotations or with @ResponseBody annotation");
168+
checkState(
169+
bodyIndex == -1,
170+
"Cannot have two parameters either without annotations or with @ResponseBody"
171+
+ " annotation");
158172
bodyIndex = i;
159173
bodyType = parameterTypes[i];
160174
}
161175
}
162176
}
163177

164-
ExceptionGenerator generator = new ExceptionGenerator(
165-
bodyIndex,
166-
requestIndex,
167-
headerMapIndex,
168-
numOfParams,
169-
bodyType,
170-
exceptionType,
171-
responseBodyDecoder);
178+
ExceptionGenerator generator =
179+
new ExceptionGenerator(
180+
bodyIndex,
181+
requestIndex,
182+
headerMapIndex,
183+
numOfParams,
184+
bodyType,
185+
exceptionType,
186+
responseBodyDecoder);
172187

173188
validateGeneratorCanBeUsedToGenerateExceptions(generator);
174189
return generator;
@@ -179,12 +194,15 @@ private void validateGeneratorCanBeUsedToGenerateExceptions(ExceptionGenerator g
179194
generator.createException(TEST_RESPONSE);
180195
} catch (Exception e) {
181196
throw new IllegalStateException(
182-
"Cannot generate exception - check constructor parameter types (are headers Map<String,Collection<String>> or is something causing an exception on construction?)",
197+
"Cannot generate exception - check constructor parameter types (are headers"
198+
+ " Map<String,Collection<String>> or is something causing an exception on"
199+
+ " construction?)",
183200
e);
184201
}
185202
}
186203

187-
private Constructor<? extends Exception> getConstructor(Class<? extends Exception> exceptionClass) {
204+
private Constructor<? extends Exception> getConstructor(
205+
Class<? extends Exception> exceptionClass) {
188206
Constructor<? extends Exception> preferredConstructor = null;
189207
for (Constructor<?> constructor : exceptionClass.getConstructors()) {
190208

@@ -210,8 +228,10 @@ private Constructor<? extends Exception> getConstructor(Class<? extends Exceptio
210228
return exceptionClass.getConstructor();
211229
} catch (NoSuchMethodException e) {
212230
throw new IllegalStateException(
213-
"Cannot find any suitable constructor in class [" + exceptionClass.getName()
214-
+ "] - did you forget to mark one with @FeignExceptionConstructor or at least have a public default constructor?",
231+
"Cannot find any suitable constructor in class ["
232+
+ exceptionClass.getName()
233+
+ "] - did you forget to mark one with @FeignExceptionConstructor or at least"
234+
+ " have a public default constructor?",
215235
e);
216236
}
217237
}

annotation-error-decoder/src/main/java/feign/error/FeignExceptionConstructor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
@Retention(RetentionPolicy.RUNTIME)
2222
@Target({ElementType.CONSTRUCTOR})
23-
public @interface FeignExceptionConstructor {
24-
}
23+
public @interface FeignExceptionConstructor {}

annotation-error-decoder/src/main/java/feign/error/MethodErrorHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class MethodErrorHandler {
2323
private final Map<Integer, ExceptionGenerator> classLevelExceptionsByCode;
2424
private final ExceptionGenerator defaultException;
2525

26-
MethodErrorHandler(Map<Integer, ExceptionGenerator> methodLevelExceptionsByCode,
26+
MethodErrorHandler(
27+
Map<Integer, ExceptionGenerator> methodLevelExceptionsByCode,
2728
Map<Integer, ExceptionGenerator> classLevelExceptionsByCode,
2829
ExceptionGenerator defaultException) {
2930
this.methodLevelExceptionsByCode = methodLevelExceptionsByCode;
3031
this.classLevelExceptionsByCode = classLevelExceptionsByCode;
3132
this.defaultException = defaultException;
3233
}
3334

34-
3535
public Exception decode(Response response) {
3636
ExceptionGenerator constructorDefinition = getConstructorDefinition(response);
3737
return createException(constructorDefinition, response);

annotation-error-decoder/src/main/java/feign/error/ResponseBody.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
@Retention(RetentionPolicy.RUNTIME)
2222
@Target({ElementType.PARAMETER})
23-
public @interface ResponseBody {
24-
}
23+
public @interface ResponseBody {}

annotation-error-decoder/src/main/java/feign/error/ResponseHeaders.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
@Retention(RetentionPolicy.RUNTIME)
2222
@Target({ElementType.PARAMETER})
23-
public @interface ResponseHeaders {
24-
}
23+
public @interface ResponseHeaders {}

annotation-error-decoder/src/test/java/feign/error/AbstractAnnotationErrorDecoderTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
package feign.error;
1515

1616
import static feign.Feign.configKey;
17+
18+
import feign.Request;
19+
import feign.Response;
1720
import java.nio.charset.StandardCharsets;
1821
import java.util.Collection;
1922
import java.util.HashMap;
2023
import java.util.Map;
21-
import feign.Request;
22-
import feign.Response;
2324

2425
public abstract class AbstractAnnotationErrorDecoderTest<T> {
2526

26-
27-
2827
public abstract Class<T> interfaceAtTest();
2928

3029
String feignConfigKey(String methodName) throws NoSuchMethodException {
@@ -44,8 +43,9 @@ Response testResponse(int status, String body, Map<String, Collection<String>> h
4443
.status(status)
4544
.body(body, StandardCharsets.UTF_8)
4645
.headers(headers)
47-
.request(Request.create(Request.HttpMethod.GET, "http://test", headers,
48-
Request.Body.empty(), null))
46+
.request(
47+
Request.create(
48+
Request.HttpMethod.GET, "http://test", headers, Request.Body.empty(), null))
4949
.build();
5050
}
5151
}

0 commit comments

Comments
 (0)