Skip to content

Commit 0fcbb84

Browse files
authored
WEB: 暖気処理のステータスが処理中から変化しないことがある(4.0) (#2204)
- 暖気処理で発生した例外は Throwable でキャッチする - 例外をキャッチした場合、ステータスを FAILED に変更する
1 parent fc2b5d4 commit 0fcbb84

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

iplass-web/src/main/java/org/iplass/mtp/impl/web/WarmupStatusServlet.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private int getHttpStatus(WarmupStatus status) {
136136
* ウォームアップタスク実行
137137
* <p>
138138
* サーブレットの初期化処理で非同期実行されるウォームアップ処理のエントリポイントです。
139+
* エントリポイントでは Throwable で例外をキャッチし、例外をキャッチした場合はステータスを失敗に変更します。
139140
* </p>
140141
*/
141142
protected static class WarmupTaskExecutor implements Callable<Void> {
@@ -171,9 +172,23 @@ public Void call() throws Exception {
171172

172173
return null;
173174

174-
} catch (Exception e) {
175-
logger.error("Warmup failed.", e);
176-
throw e;
175+
} catch (Throwable t) {
176+
logger.error("Warmup failed.", t);
177+
178+
try {
179+
ServiceRegistry.getRegistry()
180+
.getService(WarmupService.class)
181+
.changeStatus(WarmupStatus.FAILED);
182+
183+
} catch (Exception e) {
184+
logger.error("Failed to change warmup status to FAILED.", e);
185+
}
186+
187+
switch (t) {
188+
case Exception e -> throw e;
189+
case Error e -> throw e;
190+
default -> throw new RuntimeException(t);
191+
}
177192
}
178193
}
179194

0 commit comments

Comments
 (0)