Skip to content

Commit 0a9a9b0

Browse files
committed
#452 Prevent WSAPI failure
1 parent 5c4e191 commit 0a9a9b0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

thehive-backend/app/services/CustomWSAPI.scala

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package services
22

3-
import javax.inject.{ Inject, Singleton }
3+
import scala.util.control.NonFatal
44

5+
import javax.inject.{ Inject, Singleton }
56
import play.api.inject.ApplicationLifecycle
67
import play.api.libs.ws._
78
import play.api.libs.ws.ahc.{ AhcWSClient, AhcWSClientConfig, AhcWSClientConfigParser }
@@ -92,8 +93,15 @@ class CustomWSAPI(
9293

9394
def withConfig(subConfig: Configuration): CustomWSAPI = {
9495
logger.debug(s"Override WS configuration using $subConfig")
95-
new CustomWSAPI(
96-
Configuration(subConfig.underlying.atKey("play").withFallback(config.underlying)),
97-
environment, lifecycle, mat)
96+
try {
97+
new CustomWSAPI(
98+
Configuration(subConfig.underlying.atKey("play").withFallback(config.underlying)),
99+
environment, lifecycle, mat)
100+
}
101+
catch {
102+
case NonFatal(e)
103+
logger.error(s"WSAPI configuration error, use default values", e)
104+
this
105+
}
98106
}
99107
}

0 commit comments

Comments
 (0)