Skip to content

Commit 068cc28

Browse files
committed
change to be build with java 8
1 parent 0511a5c commit 068cc28

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling/GrpcExceptionAspect.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.lang.reflect.InvocationTargetException;
2121
import java.lang.reflect.Method;
2222
import java.lang.reflect.Parameter;
23+
import java.lang.reflect.Type;
2324
import java.util.Map.Entry;
2425
import java.util.Optional;
2526

@@ -37,6 +38,10 @@
3738
/**
3839
* Exception handling for thrown {@link RuntimeException} inside gRPC service classes, which implements
3940
* {@link io.grpc.BindableService}.
41+
*
42+
* TODO...
43+
*
44+
* @author Andjelko ([email protected])
4045
*/
4146
@Slf4j
4247
@Aspect
@@ -114,11 +119,11 @@ private Object[] determineInstancedParameters(Method mappedMethod) {
114119
}
115120

116121
private Class<?> convertToClass(Parameter parameter) {
117-
return Optional.of(parameter)
118-
.map(Parameter::getParameterizedType)
119-
.filter(type -> type instanceof Class)
120-
.map(type -> (Class<?>) type)
121-
.orElseThrow();
122+
Type paramType = parameter.getParameterizedType();
123+
if (paramType instanceof Class) {
124+
return (Class<?>) paramType;
125+
}
126+
throw new IllegalStateException("Parametertype of method has to be from Class, it was: " + paramType);
122127
}
123128

124129
private Throwable castToThrowable(Object statusThrowable) {

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling/GrpcExceptionHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525

26+
/**
27+
* TODO..
28+
*
29+
* @author Andjelko ([email protected])
30+
*/
2631
@Documented
2732
@Target(ElementType.METHOD)
2833
@Retention(RetentionPolicy.RUNTIME)

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling/GrpcExceptionHandlerMethodResolver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@
3636
import lombok.RequiredArgsConstructor;
3737
import lombok.extern.slf4j.Slf4j;
3838

39+
/**
40+
* TODO..
41+
*
42+
* @author Andjelko ([email protected])
43+
*/
3944
@Slf4j
4045
@Configuration
4146
@RequiredArgsConstructor
4247
@ConditionalOnBean(annotation = GrpcServiceAdvice.class)
4348
public class GrpcExceptionHandlerMethodResolver implements InitializingBean {
4449

50+
// TODO remove lombok
51+
4552
private final Map<Class<? extends Throwable>, Method> mappedMethods = new HashMap<>(16);
4653
private final ApplicationContext applicationContext;
4754

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling/GrpcServiceAdvice.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
/**
2929
* Special {@link Component @Component} to declare GrpcException Handling.
30+
*
31+
* @author Andjelko ([email protected])
3032
*/
3133
@Target(ElementType.TYPE)
3234
@Retention(RetentionPolicy.RUNTIME)

0 commit comments

Comments
 (0)