From df859b38f0791cb5f334b38985076a15f1fe183b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Mon, 28 Feb 2011 22:54:32 +0100 Subject: [PATCH 1/3] Removed logging --- .../scala/akka/http/DefaultAkkaLoader.scala | 2 +- .../scala/akka/http/EmbeddedAppServer.scala | 11 +--- .../scala/akka/http/JettyContinuation.scala | 4 +- akka-http/src/main/scala/akka/http/Mist.scala | 35 +++------- .../scala/akka/http/Servlet30Context.scala | 8 +-- .../main/scala/akka/security/Security.scala | 14 ++-- .../main/scala/akka/servlet/AkkaLoader.scala | 64 +++++++++---------- .../main/scala/akka/servlet/Initializer.scala | 2 +- 8 files changed, 54 insertions(+), 86 deletions(-) diff --git a/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala b/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala index b7c09afde8..35a9918bc1 100644 --- a/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala +++ b/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala @@ -5,7 +5,7 @@ package akka.http import akka.config.Config -import akka.util.{Logging, Bootable} +import akka.util.{Bootable} import akka.remote.BootableRemoteActorService import akka.actor.BootableActorLoaderService import akka.servlet.AkkaLoader diff --git a/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala b/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala index d881459817..6ca38736f7 100644 --- a/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala +++ b/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala @@ -9,7 +9,7 @@ import javax.servlet.ServletConfig import java.io.File import akka.actor.BootableActorLoaderService -import akka.util.{Bootable, Logging} +import akka.util.Bootable import org.eclipse.jetty.xml.XmlConfiguration import org.eclipse.jetty.server.{Handler, Server} @@ -20,7 +20,7 @@ import akka.AkkaException /** * Handles the Akka Comet Support (load/unload) */ -trait EmbeddedAppServer extends Bootable with Logging { +trait EmbeddedAppServer extends Bootable { self: BootableActorLoaderService => import akka.config.Config._ @@ -39,7 +39,6 @@ trait EmbeddedAppServer extends Bootable with Logging { abstract override def onLoad = { super.onLoad if (isRestEnabled) { - log.slf4j.info("Attempting to start Akka HTTP service") val configuration = new XmlConfiguration(findJettyConfigXML.getOrElse(error("microkernel-server.xml not found!"))) @@ -64,15 +63,11 @@ trait EmbeddedAppServer extends Bootable with Logging { s.start() s } - log.slf4j.info("Akka HTTP service started") } } abstract override def onUnload = { super.onUnload - server foreach { t => - log.slf4j.info("Shutting down REST service (Jersey)") - t.stop() - } + server foreach { _.stop() } } } diff --git a/akka-http/src/main/scala/akka/http/JettyContinuation.scala b/akka-http/src/main/scala/akka/http/JettyContinuation.scala index c1c96f485c..9c02cf03ff 100644 --- a/akka-http/src/main/scala/akka/http/JettyContinuation.scala +++ b/akka-http/src/main/scala/akka/http/JettyContinuation.scala @@ -14,8 +14,7 @@ import Types._ /** * @author Garrick Evans */ -trait JettyContinuation extends ContinuationListener with akka.util.Logging -{ +trait JettyContinuation extends ContinuationListener { import javax.servlet.http.HttpServletResponse import MistSettings._ @@ -79,7 +78,6 @@ trait JettyContinuation extends ContinuationListener with akka.util.Logging // unexpected continution state(s) - log and do nothing // case _ => { - log.slf4j.warn("Received continuation in unexpected state: "+continuation.isInitial+" "+continuation.isSuspended+" "+continuation.isExpired+" "+continuation.isResumed) //continuation.cancel None } diff --git a/akka-http/src/main/scala/akka/http/Mist.scala b/akka-http/src/main/scala/akka/http/Mist.scala index dcad75456c..36bd20e76f 100644 --- a/akka-http/src/main/scala/akka/http/Mist.scala +++ b/akka-http/src/main/scala/akka/http/Mist.scala @@ -4,7 +4,6 @@ package akka.http -import akka.util.Logging import akka.actor.{ActorRegistry, ActorRef, Actor} import javax.servlet.http.{HttpServletResponse, HttpServletRequest} @@ -63,7 +62,7 @@ import Types._ /** * */ -trait Mist extends Logging { +trait Mist { import javax.servlet.{ServletContext} import MistSettings._ @@ -118,16 +117,11 @@ trait Mist extends Logging { val server = context.getServerInfo val (major, minor) = (context.getMajorVersion, context.getMinorVersion) - log.slf4j.info("Initializing Akka HTTP on {} with Servlet API {}.{}",Array[AnyRef](server, major: java.lang.Integer, minor: java.lang.Integer)) - _factory = if (major >= 3) { - log.slf4j.info("Supporting Java asynchronous contexts.") Some(Servlet30ContextMethodFactory) } else if (server.toLowerCase startsWith JettyServer) { - log.slf4j.info("Supporting Jetty asynchronous continuations.") Some(JettyContinuationMethodFactory) } else { - log.slf4j.error("No asynchronous request handling can be supported.") None } } @@ -185,7 +179,7 @@ class AkkaMistFilter extends Filter with Mist { case "POST" => mistify(hreq, hres)(_factory.get.Post) case "PUT" => mistify(hreq, hres)(_factory.get.Put) case "TRACE" => mistify(hreq, hres)(_factory.get.Trace) - case unknown => log.slf4j.warn("Unknown http method: {}",unknown) + case unknown => {} } chain.doFilter(req,res) case _ => chain.doFilter(req,res) @@ -270,7 +264,6 @@ trait Endpoint { this: Actor => */ protected def _na(uri: String, req: RequestMethod) = { req.NotFound("No endpoint available for [" + uri + "]") - log.slf4j.debug("No endpoint available for [{}]", uri) } } @@ -300,7 +293,7 @@ class RootEndpoint extends Actor with Endpoint { def recv: Receive = { case NoneAvailable(uri, req) => _na(uri, req) - case unknown => log.slf4j.error("Unexpected message sent to root endpoint. [{}]", unknown) + case unknown => {} } /** @@ -319,8 +312,7 @@ class RootEndpoint extends Actor with Endpoint { * * @author Garrick Evans */ -trait RequestMethod extends Logging -{ +trait RequestMethod { import java.io.IOException import javax.servlet.http.{HttpServletResponse, HttpServletRequest} @@ -387,7 +379,6 @@ trait RequestMethod extends Logging case Some(pipe) => { try { if (!suspended) { - log.slf4j.warn("Attempt to complete an expired connection.") false } else { @@ -397,13 +388,11 @@ trait RequestMethod extends Logging } } catch { case io => - log.slf4j.error("Failed to write data to connection on resume - the client probably disconnected", io) false } } case None => - log.slf4j.error("Attempt to complete request with no context.") false } @@ -411,24 +400,16 @@ trait RequestMethod extends Logging context match { case Some(pipe) => { try { - if (!suspended) { - log.slf4j.warn("Attempt to complete an expired connection.") - } - else { + if (suspended) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to write data to connection on resume") pipe.complete } - } - catch { - case io: IOException => log.slf4j.error("Request completed with internal error.", io) - } - finally { - log.slf4j.error("Request completed with internal error.", t) + } catch { + case io: IOException => {} } } - case None => - log.slf4j.error("Attempt to complete request with no context", t) + case None => {} } } diff --git a/akka-http/src/main/scala/akka/http/Servlet30Context.scala b/akka-http/src/main/scala/akka/http/Servlet30Context.scala index 974ece230d..2bc110b682 100644 --- a/akka-http/src/main/scala/akka/http/Servlet30Context.scala +++ b/akka-http/src/main/scala/akka/http/Servlet30Context.scala @@ -11,8 +11,7 @@ import Types._ /** * @author Garrick Evans */ -trait Servlet30Context extends AsyncListener with akka.util.Logging -{ +trait Servlet30Context extends AsyncListener { import javax.servlet.http.HttpServletResponse import MistSettings._ @@ -36,7 +35,6 @@ trait Servlet30Context extends AsyncListener with akka.util.Logging } catch { case ex: IllegalStateException => - log.slf4j.info("Cannot update timeout - already returned to container") false } } @@ -46,8 +44,8 @@ trait Servlet30Context extends AsyncListener with akka.util.Logging // def onComplete(e: AsyncEvent) {} def onError(e: AsyncEvent) = e.getThrowable match { - case null => log.slf4j.warn("Error occured...") - case t => log.slf4j.warn("Error occured", t) + case null => {} + case t => {} } def onStartAsync(e: AsyncEvent) {} def onTimeout(e: AsyncEvent) = { diff --git a/akka-http/src/main/scala/akka/security/Security.scala b/akka-http/src/main/scala/akka/security/Security.scala index 553984a22e..1900035c50 100644 --- a/akka-http/src/main/scala/akka/security/Security.scala +++ b/akka-http/src/main/scala/akka/security/Security.scala @@ -25,7 +25,6 @@ package akka.security import akka.actor.{Scheduler, Actor, ActorRef, ActorRegistry, IllegalActorStateException} import akka.actor.Actor._ import akka.config.Config -import akka.util.Logging import com.sun.jersey.api.model.AbstractMethod import com.sun.jersey.spi.container.{ResourceFilterFactory, ContainerRequest, ContainerRequestFilter, ContainerResponse, ContainerResponseFilter, ResourceFilter} @@ -69,9 +68,9 @@ case class SpnegoCredentials(token: Array[Byte]) extends Credentials /** * Jersey Filter for invocation intercept and authorization/authentication */ -class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { +class AkkaSecurityFilterFactory extends ResourceFilterFactory { class Filter(actor: ActorRef, rolesAllowed: Option[List[String]]) - extends ResourceFilter with ContainerRequestFilter with Logging { + extends ResourceFilter with ContainerRequestFilter { override def getRequestFilter: ContainerRequestFilter = this @@ -91,7 +90,6 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { throw new WebApplicationException(r.asInstanceOf[Response]) case None => throw new WebApplicationException(408) case unknown => { - log.slf4j.warn("Authenticator replied with unexpected result [{}]", unknown) throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR) } } @@ -244,7 +242,7 @@ trait BasicAuthenticationActor extends AuthenticationActor[BasicCredentials] { * class to create an authenticator. Don't forget to set the authenticator FQN in the * rest-part of the akka config */ -trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] with Logging { +trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] { import LiftUtils._ private object InvalidateNonces @@ -257,8 +255,7 @@ trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] w case InvalidateNonces => val ts = System.currentTimeMillis nonceMap.filter(tuple => (ts - tuple._2) < nonceValidityPeriod) - case unknown => - log.slf4j.error("Don't know what to do with: ", unknown) + case unknown => {} } //Schedule the invalidation of nonces @@ -345,7 +342,7 @@ import org.ietf.jgss.GSSContext import org.ietf.jgss.GSSCredential import org.ietf.jgss.GSSManager -trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] with Logging { +trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] { override def unauthorized = Response.status(401).header("WWW-Authenticate", "Negotiate").build @@ -371,7 +368,6 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] w Some(UserInfo(user, null, rolesFor(user))) } catch { case e: PrivilegedActionException => { - log.slf4j.error("Action not allowed", e) return None } } diff --git a/akka-http/src/main/scala/akka/servlet/AkkaLoader.scala b/akka-http/src/main/scala/akka/servlet/AkkaLoader.scala index 6aef44d733..db689c9dac 100644 --- a/akka-http/src/main/scala/akka/servlet/AkkaLoader.scala +++ b/akka-http/src/main/scala/akka/servlet/AkkaLoader.scala @@ -6,12 +6,12 @@ package akka.servlet import akka.config.Config import akka.actor.Actor -import akka.util. {Switch, Logging, Bootable} +import akka.util. {Switch, Bootable} /* * This class is responsible for booting up a stack of bundles and then shutting them down */ -class AkkaLoader extends Logging { +class AkkaLoader { private val hasBooted = new Switch(false) @volatile private var _bundles: Option[Bootable] = None @@ -23,50 +23,50 @@ class AkkaLoader extends Logging { */ def boot(withBanner: Boolean, b : Bootable): Unit = hasBooted switchOn { if (withBanner) printBanner - log.slf4j.info("Starting Akka...") + println("Starting Akka...") b.onLoad Thread.currentThread.setContextClassLoader(getClass.getClassLoader) _bundles = Some(b) - log.slf4j.info("Akka started successfully") + println("Akka started successfully") } /* * Shutdown, well, shuts down the bundles used in boot */ def shutdown: Unit = hasBooted switchOff { - log.slf4j.info("Shutting down Akka...") + println("Shutting down Akka...") _bundles.foreach(_.onUnload) _bundles = None Actor.shutdownHook.run - log.slf4j.info("Akka succesfully shut down") + println("Akka succesfully shut down") } private def printBanner = { - log.slf4j.info("==================================================") - log.slf4j.info(" t") - log.slf4j.info(" t t t") - log.slf4j.info(" t t tt t") - log.slf4j.info(" tt t t tt t") - log.slf4j.info(" t ttttttt t ttt t") - log.slf4j.info(" t tt ttt t ttt t") - log.slf4j.info(" t t ttt t ttt t t") - log.slf4j.info(" tt t ttt ttt ttt t") - log.slf4j.info(" t t ttt ttt t tt t") - log.slf4j.info(" t ttt ttt t t") - log.slf4j.info(" tt ttt ttt t") - log.slf4j.info(" ttt ttt") - log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt") - log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt") - log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.slf4j.info(" ttt ttt ttt ttt ttt tt ttt ttt") - log.slf4j.info(" tttt ttttttttt tttttttt tttt") - log.slf4j.info(" ttttttttt ttt ttt ttt ttt ttttttttt") - log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt") - log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt") - log.slf4j.info("==================================================") - log.slf4j.info(" Running version {}", Config.VERSION) - log.slf4j.info("==================================================") + println("==================================================") + println(" t") + println(" t t t") + println(" t t tt t") + println(" tt t t tt t") + println(" t ttttttt t ttt t") + println(" t tt ttt t ttt t") + println(" t t ttt t ttt t t") + println(" tt t ttt ttt ttt t") + println(" t t ttt ttt t tt t") + println(" t ttt ttt t t") + println(" tt ttt ttt t") + println(" ttt ttt") + println(" tttttttt ttt ttt ttt ttt tttttttt") + println(" ttt tt ttt ttt ttt ttt ttt ttt") + println(" ttt ttt ttt ttt ttt ttt ttt ttt") + println(" ttt ttt ttt ttt ttt tt ttt ttt") + println(" tttt ttttttttt tttttttt tttt") + println(" ttttttttt ttt ttt ttt ttt ttttttttt") + println(" ttt ttt ttt ttt ttt ttt ttt ttt") + println(" ttt ttt ttt ttt ttt ttt ttt ttt") + println(" ttt tt ttt ttt ttt ttt ttt ttt") + println(" tttttttt ttt ttt ttt ttt tttttttt") + println("==================================================") + println(" Running version {}", Config.VERSION) + println("==================================================") } } diff --git a/akka-http/src/main/scala/akka/servlet/Initializer.scala b/akka-http/src/main/scala/akka/servlet/Initializer.scala index cef7463f59..75b036d635 100644 --- a/akka-http/src/main/scala/akka/servlet/Initializer.scala +++ b/akka-http/src/main/scala/akka/servlet/Initializer.scala @@ -7,7 +7,7 @@ package akka.servlet import akka.remote.BootableRemoteActorService import akka.actor.BootableActorLoaderService import akka.config.Config -import akka.util.{Logging, Bootable} +import akka.util.Bootable import javax.servlet.{ServletContextListener, ServletContextEvent} From 006f7f52781a02943e692aa8a1b1c98209d4acdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Wed, 2 Mar 2011 00:14:45 +0100 Subject: [PATCH 2/3] Added the ErrorHandler notifications to all try-catch blocks --- akka-http/src/main/scala/akka/http/Mist.scala | 5 ++++- akka-http/src/main/scala/akka/http/Servlet30Context.scala | 2 ++ akka-http/src/main/scala/akka/security/Security.scala | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/akka-http/src/main/scala/akka/http/Mist.scala b/akka-http/src/main/scala/akka/http/Mist.scala index 36bd20e76f..70063b2acd 100644 --- a/akka-http/src/main/scala/akka/http/Mist.scala +++ b/akka-http/src/main/scala/akka/http/Mist.scala @@ -5,6 +5,7 @@ package akka.http import akka.actor.{ActorRegistry, ActorRef, Actor} +import akka.actor.{ErrorHandler, ErrorHandlerEvent} import javax.servlet.http.{HttpServletResponse, HttpServletRequest} import javax.servlet.http.HttpServlet @@ -388,6 +389,7 @@ trait RequestMethod { } } catch { case io => + ErrorHandler notifyListeners ErrorHandlerEvent(io, this) false } } @@ -405,7 +407,8 @@ trait RequestMethod { pipe.complete } } catch { - case io: IOException => {} + case io: IOException => + ErrorHandler notifyListeners ErrorHandlerEvent(io, this) } } diff --git a/akka-http/src/main/scala/akka/http/Servlet30Context.scala b/akka-http/src/main/scala/akka/http/Servlet30Context.scala index 2bc110b682..ac057a5756 100644 --- a/akka-http/src/main/scala/akka/http/Servlet30Context.scala +++ b/akka-http/src/main/scala/akka/http/Servlet30Context.scala @@ -7,6 +7,7 @@ package akka.http import javax.servlet. {AsyncContext, AsyncListener, AsyncEvent}; import Types._ +import akka.actor.{ErrorHandler, ErrorHandlerEvent} /** * @author Garrick Evans @@ -35,6 +36,7 @@ trait Servlet30Context extends AsyncListener { } catch { case ex: IllegalStateException => + ErrorHandler notifyListeners ErrorHandlerEvent(ex, this) false } } diff --git a/akka-http/src/main/scala/akka/security/Security.scala b/akka-http/src/main/scala/akka/security/Security.scala index 1900035c50..8a31a05f4e 100644 --- a/akka-http/src/main/scala/akka/security/Security.scala +++ b/akka-http/src/main/scala/akka/security/Security.scala @@ -23,6 +23,7 @@ package akka.security import akka.actor.{Scheduler, Actor, ActorRef, ActorRegistry, IllegalActorStateException} +import akka.actor.{ErrorHandler, ErrorHandlerEvent} import akka.actor.Actor._ import akka.config.Config @@ -368,6 +369,7 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] { Some(UserInfo(user, null, rolesFor(user))) } catch { case e: PrivilegedActionException => { + ErrorHandler notifyListeners ErrorHandlerEvent(e, this) return None } } From 93bdb33e8ca22422ed59ac8f4124983037b9f1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Wed, 2 Mar 2011 18:19:17 +0100 Subject: [PATCH 3/3] Renamed to EventHandler and added 'info, debug, warning and error' --- akka-http/src/main/scala/akka/http/Mist.scala | 8 ++++---- akka-http/src/main/scala/akka/http/Servlet30Context.scala | 4 ++-- akka-http/src/main/scala/akka/security/Security.scala | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/akka-http/src/main/scala/akka/http/Mist.scala b/akka-http/src/main/scala/akka/http/Mist.scala index 70063b2acd..53a6d8f6d0 100644 --- a/akka-http/src/main/scala/akka/http/Mist.scala +++ b/akka-http/src/main/scala/akka/http/Mist.scala @@ -5,7 +5,7 @@ package akka.http import akka.actor.{ActorRegistry, ActorRef, Actor} -import akka.actor.{ErrorHandler, ErrorHandlerEvent} +import akka.actor.{EventHandler} import javax.servlet.http.{HttpServletResponse, HttpServletRequest} import javax.servlet.http.HttpServlet @@ -388,8 +388,8 @@ trait RequestMethod { true } } catch { - case io => - ErrorHandler notifyListeners ErrorHandlerEvent(io, this) + case io: Exception => + EventHandler notifyListeners EventHandler.Error(io, this) false } } @@ -408,7 +408,7 @@ trait RequestMethod { } } catch { case io: IOException => - ErrorHandler notifyListeners ErrorHandlerEvent(io, this) + EventHandler notifyListeners EventHandler.Error(io, this) } } diff --git a/akka-http/src/main/scala/akka/http/Servlet30Context.scala b/akka-http/src/main/scala/akka/http/Servlet30Context.scala index ac057a5756..1caeeb83ef 100644 --- a/akka-http/src/main/scala/akka/http/Servlet30Context.scala +++ b/akka-http/src/main/scala/akka/http/Servlet30Context.scala @@ -7,7 +7,7 @@ package akka.http import javax.servlet. {AsyncContext, AsyncListener, AsyncEvent}; import Types._ -import akka.actor.{ErrorHandler, ErrorHandlerEvent} +import akka.actor.{EventHandler} /** * @author Garrick Evans @@ -36,7 +36,7 @@ trait Servlet30Context extends AsyncListener { } catch { case ex: IllegalStateException => - ErrorHandler notifyListeners ErrorHandlerEvent(ex, this) + EventHandler notifyListeners EventHandler.Error(ex, this) false } } diff --git a/akka-http/src/main/scala/akka/security/Security.scala b/akka-http/src/main/scala/akka/security/Security.scala index 8a31a05f4e..6105c5265e 100644 --- a/akka-http/src/main/scala/akka/security/Security.scala +++ b/akka-http/src/main/scala/akka/security/Security.scala @@ -23,7 +23,7 @@ package akka.security import akka.actor.{Scheduler, Actor, ActorRef, ActorRegistry, IllegalActorStateException} -import akka.actor.{ErrorHandler, ErrorHandlerEvent} +import akka.actor.{EventHandler} import akka.actor.Actor._ import akka.config.Config @@ -369,8 +369,8 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] { Some(UserInfo(user, null, rolesFor(user))) } catch { case e: PrivilegedActionException => { - ErrorHandler notifyListeners ErrorHandlerEvent(e, this) - return None + EventHandler notifyListeners EventHandler.Error(e, this) + None } } }