Commit 98d460c
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 <guins_j@guins.org>1 parent 8263e80 commit 98d460c
File tree
1 file changed
+9
-5
lines changed- core/src/main/java/com/linecorp/armeria/client
1 file changed
+9
-5
lines changedLines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
0 commit comments