Skip to content

Commit a9cf8a7

Browse files
author
Alexander Furer
committed
code cleanups
1 parent 106b6ca commit a9cf8a7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/GRpcServerRunner.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.springframework.beans.factory.config.BeanDefinition;
1212
import org.springframework.boot.CommandLineRunner;
1313
import org.springframework.context.support.AbstractApplicationContext;
14+
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
1415
import org.springframework.core.type.StandardMethodMetadata;
1516

1617
import java.lang.annotation.Annotation;
@@ -97,32 +98,28 @@ private ServerServiceDefinition bindInterceptors(ServerServiceDefinition service
9798
privateInterceptors)
9899
.distinct()
99100
.collect(Collectors.toList());
100-
Collections.sort(interceptors,org.springframework.core.annotation.AnnotationAwareOrderComparator.INSTANCE);
101+
interceptors.sort(AnnotationAwareOrderComparator.INSTANCE);
101102
Collections.reverse(interceptors);
102103
return ServerInterceptors.intercept(serviceDefinition, interceptors);
103104
}
104105

105106

106107
private void startDaemonAwaitThread() {
107-
Thread awaitThread = new Thread() {
108-
@Override
109-
public void run() {
108+
Thread awaitThread = new Thread(()->{
110109
try {
111110
GRpcServerRunner.this.server.awaitTermination();
112111
} catch (InterruptedException e) {
113112
log.error("gRPC server stopped.", e);
114113
}
115-
}
116-
117-
};
114+
});
118115
awaitThread.setDaemon(false);
119116
awaitThread.start();
120117
}
121118

122119
@Override
123120
public void destroy() throws Exception {
124121
log.info("Shutting down gRPC server ...");
125-
serviceList.stream().forEach(s -> healthStatusManager.clearStatus(s));
122+
serviceList.forEach(s -> healthStatusManager.clearStatus(s));
126123
Optional.ofNullable(server).ifPresent(Server::shutdown);
127124
log.info("gRPC server stopped.");
128125
}

0 commit comments

Comments
 (0)