Skip to content

Commit

Permalink
#452 Prevent WSAPI failure
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 12, 2018
1 parent 5c4e191 commit 0a9a9b0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions thehive-backend/app/services/CustomWSAPI.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package services

import javax.inject.{ Inject, Singleton }
import scala.util.control.NonFatal

import javax.inject.{ Inject, Singleton }
import play.api.inject.ApplicationLifecycle
import play.api.libs.ws._
import play.api.libs.ws.ahc.{ AhcWSClient, AhcWSClientConfig, AhcWSClientConfigParser }
Expand Down Expand Up @@ -92,8 +93,15 @@ class CustomWSAPI(

def withConfig(subConfig: Configuration): CustomWSAPI = {
logger.debug(s"Override WS configuration using $subConfig")
new CustomWSAPI(
Configuration(subConfig.underlying.atKey("play").withFallback(config.underlying)),
environment, lifecycle, mat)
try {
new CustomWSAPI(
Configuration(subConfig.underlying.atKey("play").withFallback(config.underlying)),
environment, lifecycle, mat)
}
catch {
case NonFatal(e)
logger.error(s"WSAPI configuration error, use default values", e)
this
}
}
}

0 comments on commit 0a9a9b0

Please sign in to comment.