You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid addShutdownHook to JVM during its shutdown (#5524)
Motivation:
Currently a JVM shutdown hook is added when DefaultClientFactory is used
for the first time
([code](https://github.com/line/armeria/blob/main/core/src/main/java/com/linecorp/armeria/client/DefaultClientFactory.java#L80-L83)).
It is possible that a JVM shutdown hook is being added after the JVM has
started its shutdown and results in an exception below:
```
Caused by: java.lang.IllegalStateException: Shutdown in progress
at java.base/java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
at java.base/java.lang.Runtime.addShutdownHook(Runtime.java:216)
at grpc_shaded.com.linecorp.armeria.client.DefaultClientFactory.<clinit>(DefaultClientFactory.java:79)
... 24 more
```
Modifications:
- Skip adding the hook if we explicitly disabled it.
- Add try-catch for ` java.lang.IllegalStateException`
Result:
- Closes#5494
---------
Co-authored-by: jrhee17 <[email protected]>
0 commit comments