summaryrefslogtreecommitdiffstats
path: root/container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala
diff options
context:
space:
mode:
authorgjoranv <gv@yahoo-inc.com>2017-05-31 11:18:41 +0200
committergjoranv <gv@yahoo-inc.com>2017-05-31 11:18:41 +0200
commit77ddf302a8f3ad82ff0eb2d0ef75a4b8f112785f (patch)
tree7f942bb1ab3545291d0d3c2ddf58fa506eee0726 /container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala
parenta66b8e55fc81ae2e60301a35503c21baaf24d0ae (diff)
Remove the timeout for component construction.
Diffstat (limited to 'container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala')
-rw-r--r--container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala31
1 files changed, 8 insertions, 23 deletions
diff --git a/container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala b/container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala
index 477dfa40aad..242d4c97a79 100644
--- a/container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala
+++ b/container-di/src/main/scala/com/yahoo/container/di/componentgraph/core/ComponentNode.scala
@@ -95,27 +95,15 @@ class ComponentNode(componentId: ComponentId,
case other => other
}
- val instanceFuture = Future {
- try {
- constructor.newInstance(actualArguments: _*)
- } catch {
- case e: InvocationTargetException =>
- throw removeStackTrace(ErrorOrComponentConstructorException(cutStackTraceAtConstructor(e.getCause), s"Error constructing $idAndType"))
- }
- }
+ val instance =
+ try {
+ constructor.newInstance(actualArguments: _*)
+ } catch {
+ case e: InvocationTargetException =>
+ throw removeStackTrace(ErrorOrComponentConstructorException(cutStackTraceAtConstructor(e.getCause), s"Error constructing $idAndType"))
+ }
- try {
- val instance = Await.result(instanceFuture, ComponentConstructTimeout)
- initId(instance)
- } catch {
- case constructorException: ComponentConstructorException =>
- throw constructorException
- case _:TimeoutException =>
- throw new ComponentConstructorException(s"Timed out after $ComponentConstructTimeout while constructing component $idAndType.")
- case e: InterruptedException =>
- Thread.currentThread().interrupt()
- throw new RuntimeException(s"Interrupted while constructing component $idAndType", e)
- }
+ initId(instance)
}
private def ErrorOrComponentConstructorException(cause: Throwable, message: String) : Throwable = {
@@ -186,9 +174,6 @@ class ComponentNode(componentId: ComponentId,
object ComponentNode {
val log = Logger.getLogger(classOf[ComponentNode].getName)
- // XXX: var for testing only. Do not reset in production code!
- var ComponentConstructTimeout: FiniteDuration = 60 seconds
-
private def bestConstructor(clazz: Class[AnyRef]) = {
val publicConstructors = clazz.getConstructors.asInstanceOf[Array[Constructor[AnyRef]]]