|
11 | 11 | import org.springframework.beans.factory.config.BeanDefinition; |
12 | 12 | import org.springframework.boot.CommandLineRunner; |
13 | 13 | import org.springframework.context.support.AbstractApplicationContext; |
| 14 | +import org.springframework.core.annotation.AnnotationAwareOrderComparator; |
14 | 15 | import org.springframework.core.type.StandardMethodMetadata; |
15 | 16 |
|
16 | 17 | import java.lang.annotation.Annotation; |
@@ -97,32 +98,28 @@ private ServerServiceDefinition bindInterceptors(ServerServiceDefinition service |
97 | 98 | privateInterceptors) |
98 | 99 | .distinct() |
99 | 100 | .collect(Collectors.toList()); |
100 | | - Collections.sort(interceptors,org.springframework.core.annotation.AnnotationAwareOrderComparator.INSTANCE); |
| 101 | + interceptors.sort(AnnotationAwareOrderComparator.INSTANCE); |
101 | 102 | Collections.reverse(interceptors); |
102 | 103 | return ServerInterceptors.intercept(serviceDefinition, interceptors); |
103 | 104 | } |
104 | 105 |
|
105 | 106 |
|
106 | 107 | private void startDaemonAwaitThread() { |
107 | | - Thread awaitThread = new Thread() { |
108 | | - @Override |
109 | | - public void run() { |
| 108 | + Thread awaitThread = new Thread(()->{ |
110 | 109 | try { |
111 | 110 | GRpcServerRunner.this.server.awaitTermination(); |
112 | 111 | } catch (InterruptedException e) { |
113 | 112 | log.error("gRPC server stopped.", e); |
114 | 113 | } |
115 | | - } |
116 | | - |
117 | | - }; |
| 114 | + }); |
118 | 115 | awaitThread.setDaemon(false); |
119 | 116 | awaitThread.start(); |
120 | 117 | } |
121 | 118 |
|
122 | 119 | @Override |
123 | 120 | public void destroy() throws Exception { |
124 | 121 | log.info("Shutting down gRPC server ..."); |
125 | | - serviceList.stream().forEach(s -> healthStatusManager.clearStatus(s)); |
| 122 | + serviceList.forEach(s -> healthStatusManager.clearStatus(s)); |
126 | 123 | Optional.ofNullable(server).ifPresent(Server::shutdown); |
127 | 124 | log.info("gRPC server stopped."); |
128 | 125 | } |
|
0 commit comments