Fixed highly unlikely, non-critical NPE in machine (could happen in the very rare case that an executor thread started while the machine was being removed from the network, leading it to run while the machine is unconnected - that's still possible, but non-critical; it'll just stop/silently error and stop now).

This commit is contained in:
Florian Nücke 2015-01-18 14:27:23 +01:00
parent db05a22430
commit 13a8dde8a6

View File

@ -255,7 +255,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
})
override def invoke(address: String, method: String, args: Array[AnyRef]) =
Option(node.network.node(address)) match {
if (node != null && node.network != null) Option(node.network.node(address)) match {
case Some(component: Component) if component.canBeSeenFrom(node) || component == node =>
val direct = component.annotation(method).direct
if (direct && architecture.isInitialized) {
@ -264,6 +264,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
component.invoke(method, this, args: _*)
case _ => throw new IllegalArgumentException("no such component")
}
else {
// Not really, but makes the VM stop, which is what we want in this case,
// because it means we've been disconnected / disposed already.
throw new LimitReachedException()
}
override def invoke(value: Value, method: String, args: Array[AnyRef]): Array[AnyRef] = Callbacks(value).get(method) match {
case Some(callback) =>