From 6cadb0d03526ea93d42d1a86b82887606b90b7fb Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 13 Mar 2010 14:06:52 +0100 Subject: [PATCH 1/6] Fixing container detection for SBT console mode --- akka-comet/src/main/scala/BootableCometActorService.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/akka-comet/src/main/scala/BootableCometActorService.scala b/akka-comet/src/main/scala/BootableCometActorService.scala index f6895aeee9..496cc33aed 100644 --- a/akka-comet/src/main/scala/BootableCometActorService.scala +++ b/akka-comet/src/main/scala/BootableCometActorService.scala @@ -43,8 +43,7 @@ trait BootableCometActorService extends Bootable with Logging { adapter.setHandleStaticResources(true) adapter.setServletInstance(new AkkaServlet) adapter.setContextPath(uri.getPath) - //Using autodetection for now - //adapter.addInitParameter("cometSupport", "org.atmosphere.container.GrizzlyCometSupport") + adapter.addInitParameter("cometSupport", "org.atmosphere.container.GrizzlyCometSupport") if (HOME.isDefined) adapter.setRootFolder(HOME.get + "/deploy/root") log.info("REST service root path [%s] and context path [%s]", adapter.getRootFolder, adapter.getContextPath) From 81b35c1f7d122f1e0a7026db52476649a2d470f9 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 13 Mar 2010 14:07:37 +0100 Subject: [PATCH 2/6] Return 408 is authentication times out --- akka-security/src/main/scala/Security.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/akka-security/src/main/scala/Security.scala b/akka-security/src/main/scala/Security.scala index 1f0d8a94aa..8a144f4282 100644 --- a/akka-security/src/main/scala/Security.scala +++ b/akka-security/src/main/scala/Security.scala @@ -87,10 +87,11 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { override def filter(request: ContainerRequest): ContainerRequest = rolesAllowed match { case Some(roles) => { - (authenticator !! (Authenticate(request, roles), 10000)).get.asInstanceOf[AnyRef] match { - case OK => request - case r if r.isInstanceOf[Response] => + (authenticator.!![AnyRef](Authenticate(request, roles), 10000)) match { + case Some(OK) => request + case Some(r) if r.isInstanceOf[Response] => throw new WebApplicationException(r.asInstanceOf[Response]) + case None => throw new WebApplicationException(408) case x => { log.error("Authenticator replied with unexpected result [%s]", x); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR) From d1a9e4a2861c6ebbf258250a44a38eb7147c961e Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 13 Mar 2010 14:08:02 +0100 Subject: [PATCH 3/6] Fixed deprecation warning --- akka-core/src/test/scala/ThreadBasedDispatcherTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-core/src/test/scala/ThreadBasedDispatcherTest.scala b/akka-core/src/test/scala/ThreadBasedDispatcherTest.scala index b9663352c7..c848c56991 100644 --- a/akka-core/src/test/scala/ThreadBasedDispatcherTest.scala +++ b/akka-core/src/test/scala/ThreadBasedDispatcherTest.scala @@ -78,7 +78,7 @@ class ThreadBasedDispatcherTest extends JUnitSuite { }) dispatcher.start for (i <- 0 until 100) { - dispatcher.dispatch(new MessageInvocation(key1, new Integer(i), None, None, None)) + dispatcher.dispatch(new MessageInvocation(key1, i, None, None, None)) } assert(handleLatch.await(5, TimeUnit.SECONDS)) assert(!threadingIssueDetected.get) From 7e517ede0d6748c510b8c0bbd642ab0b2cd772d1 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 13 Mar 2010 14:08:30 +0100 Subject: [PATCH 4/6] Revert to Atmosphere 0.5.4 because of issue in 0.6-SNAPSHOT --- project/build/AkkaProject.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 2df647a5bd..c3c7211d97 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -42,7 +42,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { // ------------------------------------------------------------ // project versions val JERSEY_VERSION = "1.1.5" - val ATMO_VERSION = "0.6-SNAPSHOT" + val ATMO_VERSION = "0.5.4" val CASSANDRA_VERSION = "0.5.0" // ------------------------------------------------------------ From ae0ef2d06c313e813fb995bb5cac420cca03d2dc Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Mon, 15 Mar 2010 11:08:25 +0100 Subject: [PATCH 5/6] OS-specific substring search in paths (fixes 'sbt dist' issue on Windows) --- project/build/AkkaProject.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index c3c7211d97..891126f22e 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -358,7 +358,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { def deployTask(info: ProjectInfo, toDir: Path) = task { val projectPath = info.projectPath.toString - val moduleName = projectPath.substring(projectPath.lastIndexOf('/') + 1, projectPath.length) + val moduleName = projectPath.substring(projectPath.lastIndexOf(System.getProperty("file.separator")) + 1, projectPath.length) // FIXME need to find out a way to grab these paths from the sbt system val JAR_FILE_NAME = moduleName + "_%s-%s.jar".format(defScalaVersion.value, version) val JAR_FILE_PATH = projectPath + "/target/scala_%s/".format(defScalaVersion.value) + JAR_FILE_NAME From 823661c499349a9c32b6c1a68d2f83972de03dc3 Mon Sep 17 00:00:00 2001 From: Jan Van Besien Date: Tue, 16 Mar 2010 12:25:58 +0100 Subject: [PATCH 6/6] Fixed bug which allowed messages to be "missed" if they arrived after looping through the mailbox, but before releasing the lock. --- .../ExecutorBasedEventDrivenDispatcher.scala | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenDispatcher.scala b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenDispatcher.scala index 77879e0e3b..b48e7717cf 100644 --- a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenDispatcher.scala +++ b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenDispatcher.scala @@ -62,19 +62,24 @@ class ExecutorBasedEventDrivenDispatcher(_name: String) extends MessageDispatche def dispatch(invocation: MessageInvocation) = if (active) { executor.execute(new Runnable() { def run = { - val lockedForDispatching = invocation.receiver._dispatcherLock.tryLock - if (lockedForDispatching) { - try { - // Only dispatch if we got the lock. Otherwise another thread is already dispatching. - var messageInvocation = invocation.receiver._mailbox.poll - while (messageInvocation != null) { - messageInvocation.invoke - messageInvocation = invocation.receiver._mailbox.poll + var lockAcquiredOnce = false + // this do-wile loop is required to prevent missing new messages between the end of the inner while + // loop and releasing the lock + do { + if (invocation.receiver._dispatcherLock.tryLock) { + lockAcquiredOnce = true + try { + // Only dispatch if we got the lock. Otherwise another thread is already dispatching. + var messageInvocation = invocation.receiver._mailbox.poll + while (messageInvocation != null) { + messageInvocation.invoke + messageInvocation = invocation.receiver._mailbox.poll + } + } finally { + invocation.receiver._dispatcherLock.unlock } - } finally { - invocation.receiver._dispatcherLock.unlock } - } + } while ((lockAcquiredOnce && !invocation.receiver._mailbox.isEmpty)) } }) } else throw new IllegalStateException("Can't submit invocations to dispatcher since it's not started") @@ -94,4 +99,4 @@ class ExecutorBasedEventDrivenDispatcher(_name: String) extends MessageDispatche "Can't build a new thread pool for a dispatcher that is already up and running") private[akka] def init = withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity.buildThreadPool -} \ No newline at end of file +}