Minor fixes from review

This commit is contained in:
Patrik Nordwall 2011-11-24 14:34:42 +01:00
parent 3fd629e92d
commit c9187e21f6
4 changed files with 13 additions and 11 deletions

View file

@ -78,7 +78,7 @@ public abstract class Parseable implements ConfigParseable {
// so that exceptions are thrown from the public parse() function and not
// from the creation of the Parseable. Essentially this is a lazy field.
// The parser should close the reader when it's done with it.
// ALSO, IMPortANT: if the file or URL is not found, this must throw.
// ALSO, IMPORTANT: if the file or URL is not found, this must throw.
// to support the "allow missing" feature.
protected abstract Reader reader() throws IOException;

View file

@ -389,15 +389,15 @@ class ActorSystemImpl(val name: String, val applicationConfig: Config) extends A
* Returns any extension registered to the specified key or returns null if not registered
*/
@tailrec
def lookupExtension[T <: AnyRef](key: ExtensionKey[T]): T = extensions.get(key) match {
case c: CountDownLatch c.await(); lookupExtension(key) //Registration in process, await completion and retry
case e: Extension[_] e.asInstanceOf[T] //Profit!
case null null.asInstanceOf[T] //Doesn't exist
def findExtension[T <: AnyRef](key: ExtensionKey[T]): Option[T] = extensions.get(key) match {
case c: CountDownLatch c.await(); findExtension(key) //Registration in process, await completion and retry
case e: Extension[_] Some(e.asInstanceOf[T]) //Profit!
case null None //Doesn't exist
}
lookupExtension(ext.key) match {
case e: Extension[_] e.asInstanceOf[Extension[T]] //Profit!
case null //Doesn't already exist, commence registration
findExtension(ext.key) match {
case Some(e: Extension[_]) e.asInstanceOf[Extension[T]] //Profit!
case None //Doesn't already exist, commence registration
val inProcessOfRegistration = new CountDownLatch(1)
extensions.putIfAbsent(ext.key, inProcessOfRegistration) match { // Signal that registration is in process
case null try { // Signal was successfully sent

View file

@ -54,11 +54,12 @@ trait Extension[T <: AnyRef] {
*/
def key: ExtensionKey[T]
// FIXME ActorSystemImpl exposed to user API. We might well choose to introduce a new interface for this level of access, just so we can shuffle around the implementation
/**
* This method is called by the ActorSystem when the extension is registered
* to trigger initialization of the extension.
*/
def init(system: ActorSystemImpl)
def init(system: ActorSystemImpl): Unit
}
/**

View file

@ -82,11 +82,12 @@ abstract class EventFilter(occurrences: Int) {
def intercept[T](code: T)(implicit system: ActorSystem): T = {
system.eventStream publish TestEvent.Mute(this)
val testKitExtension = TestKitExtension(system)
val leeway = testKitExtension.settings.TestEventFilterLeeway
try {
val result = code
if (!awaitDone(testKitExtension.settings.TestEventFilterLeeway))
if (!awaitDone(leeway))
if (todo > 0)
throw new AssertionError("Timeout (" + testKitExtension.settings.TestEventFilterLeeway + ") waiting for " + todo + " messages on " + this)
throw new AssertionError("Timeout (" + leeway + ") waiting for " + todo + " messages on " + this)
else
throw new AssertionError("Received " + (-todo) + " messages too many on " + this)
result