From cc947dd551047a84b5754c671a937b3df6787088 Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 17 Dec 2015 14:27:13 -0300 Subject: = All: downgrade sbt to 0.13.8 in order to avoid issues with scalariform --- .../src/main/scala/kamon/autoweave/Autoweave.scala | 15 ++++---- .../scala/kamon/autoweave/loader/AgentLoader.scala | 45 +++++++++++----------- 2 files changed, 29 insertions(+), 31 deletions(-) (limited to 'kamon-autoweave/src/main/scala/kamon/autoweave') diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala index 29c4254a..58111b48 100644 --- a/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala +++ b/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala @@ -19,14 +19,13 @@ import kamon.Kamon import kamon.autoweave.loader.AgentLoader import org.aspectj.weaver.loadtime.Agent - object Autoweave { - val config = Kamon.config.getConfig("kamon.autowave.options") - val verbose = config.getBoolean("verbose") - val showWeaveInfo = config.getBoolean("showWeaveInfo") + val config = Kamon.config.getConfig("kamon.autowave.options") + val verbose = config.getBoolean("verbose") + val showWeaveInfo = config.getBoolean("showWeaveInfo") - System.setProperty("aj.weaving.verbose", verbose.toString) - System.setProperty("org.aspectj.weaver.showWeaveInfo", showWeaveInfo.toString) + System.setProperty("aj.weaving.verbose", verbose.toString) + System.setProperty("org.aspectj.weaver.showWeaveInfo", showWeaveInfo.toString) - AgentLoader.attachAgentToJVM(classOf[Agent]) - } + AgentLoader.attachAgentToJVM(classOf[Agent]) +} diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala index d4efdb85..0ad7fdf7 100644 --- a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala +++ b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala @@ -15,18 +15,18 @@ package kamon.autoweave.loader -import java.io.{File, FileOutputStream, InputStream} +import java.io.{ File, FileOutputStream, InputStream } import java.lang.management.ManagementFactory import java.util import java.util.jar.Attributes.Name -import java.util.jar.{JarEntry, JarOutputStream, Manifest} +import java.util.jar.{ JarEntry, JarOutputStream, Manifest } import com.sun.tools.attach.spi.AttachProvider -import com.sun.tools.attach.{VirtualMachine, VirtualMachineDescriptor} +import com.sun.tools.attach.{ VirtualMachine, VirtualMachineDescriptor } import sun.tools.attach._ import scala.util.control.NoStackTrace -import scala.util.{Failure, Success, Try} +import scala.util.{ Failure, Success, Try } object AgentLoader { @@ -113,25 +113,25 @@ object AgentLoader { private def unqualify(clazz: Class[_]): String = clazz.getName.replace('.', '/') + ".class" /** - * Gets the current HotSpotVirtualMachine implementation otherwise a failure. - * - * @return - * Returns the HotSpotVirtualMachine implementation of the running JVM. - */ - private def findVirtualMachineImplementation(): Try[Class[_ <: HotSpotVirtualMachine]] = System.getProperty("os.name") match { - case os if os.startsWith("Windows") => Success(classOf[WindowsVirtualMachine]) - case os if os.startsWith("Mac OS X") => Success(classOf[BsdVirtualMachine]) - case os if os.startsWith("Solaris") => Success(classOf[SolarisVirtualMachine]) - case os if os.startsWith("Linux") || os.startsWith("LINUX") => Success(classOf[LinuxVirtualMachine]) - case other => Failure(new RuntimeException(s"Cannot use Attach API on unknown OS: $other") with NoStackTrace) + * Gets the current HotSpotVirtualMachine implementation otherwise a failure. + * + * @return + * Returns the HotSpotVirtualMachine implementation of the running JVM. + */ + private def findVirtualMachineImplementation(): Try[Class[_ <: HotSpotVirtualMachine]] = System.getProperty("os.name") match { + case os if os.startsWith("Windows") ⇒ Success(classOf[WindowsVirtualMachine]) + case os if os.startsWith("Mac OS X") ⇒ Success(classOf[BsdVirtualMachine]) + case os if os.startsWith("Solaris") ⇒ Success(classOf[SolarisVirtualMachine]) + case os if os.startsWith("Linux") || os.startsWith("LINUX") ⇒ Success(classOf[LinuxVirtualMachine]) + case other ⇒ Failure(new RuntimeException(s"Cannot use Attach API on unknown OS: $other") with NoStackTrace) } /** - * Attach to the running JVM. - * - * @return - * Returns the attached VirtualMachine - */ + * Attach to the running JVM. + * + * @return + * Returns the attached VirtualMachine + */ private def attachToRunningJVM(): VirtualMachine = { val AttachProvider = new AttachProvider() { override def name(): String = null @@ -141,15 +141,14 @@ object AgentLoader { } findVirtualMachineImplementation() match { - case Success(vmClass) => + case Success(vmClass) ⇒ val pid = getPidFromRuntimeMBean // This is only done with Reflection to avoid the JVM pre-loading all the XyzVirtualMachine classes. val vmConstructor = vmClass.getConstructor(classOf[AttachProvider], classOf[String]) val newVM = vmConstructor.newInstance(AttachProvider, pid) newVM.asInstanceOf[VirtualMachine] - case Failure(reason) => throw reason + case Failure(reason) ⇒ throw reason } } } - -- cgit v1.2.3