From 34a631965b6a2b28f83fe838ed266cc9ba0a8e9d Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 4 Oct 2021 23:44:03 -0700 Subject: [PATCH] Update spotless version (#4296) * Update spotless version * Apply new spotless version --- benchmark-overhead-jmh/build.gradle.kts | 16 +++-- build.gradle.kts | 2 +- conventions/build.gradle.kts | 4 +- .../scala/AkkaHttpTestAsyncWebServer.scala | 4 +- .../test/scala/AkkaHttpTestWebServer.scala | 9 ++- .../scala/FinatraController.scala | 55 ++++++++++------ .../ResponseSettingExceptionMapper.scala | 2 +- .../src/test/scala/FinatraController.scala | 66 ++++++++++++------- .../ResponseSettingExceptionMapper.scala | 2 +- .../src/test/kotlin/KotlinCoroutineTests.kt | 2 +- .../src/test/scala/ScalaConcurrentTests.scala | 43 ++++++------ testing/agent-for-testing/build.gradle.kts | 8 ++- 12 files changed, 128 insertions(+), 85 deletions(-) diff --git a/benchmark-overhead-jmh/build.gradle.kts b/benchmark-overhead-jmh/build.gradle.kts index 9e11c695d7..34aa0249b2 100644 --- a/benchmark-overhead-jmh/build.gradle.kts +++ b/benchmark-overhead-jmh/build.gradle.kts @@ -53,13 +53,15 @@ tasks { "-Dotel.instrumentation.http-url-connection.enabled=false" ) if (jmhStartFlightRecording != null) { - args.addAll(listOf( - "-XX:+FlightRecorder", - "-XX:StartFlightRecording=$jmhStartFlightRecording", - // enabling profiling at non-safepoints helps with micro-profiling - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+DebugNonSafepoints" - )) + args.addAll( + listOf( + "-XX:+FlightRecorder", + "-XX:StartFlightRecording=$jmhStartFlightRecording", + // enabling profiling at non-safepoints helps with micro-profiling + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+DebugNonSafepoints" + ) + ) } // see https://github.com/melix/jmh-gradle-plugin/issues/200 jvmArgsPrepend.add(args.joinToString(" ")) diff --git a/build.gradle.kts b/build.gradle.kts index 258764cb6e..53901f62e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ -import java.time.Duration import nebula.plugin.release.git.opinion.Strategies +import java.time.Duration plugins { id("idea") diff --git a/conventions/build.gradle.kts b/conventions/build.gradle.kts index a53dae6c76..3e78e15867 100644 --- a/conventions/build.gradle.kts +++ b/conventions/build.gradle.kts @@ -2,7 +2,7 @@ plugins { `java-gradle-plugin` `kotlin-dsl` // When updating, update below in dependencies too - id("com.diffplug.spotless") version "5.13.0" + id("com.diffplug.spotless") version "5.16.0" } spotless { @@ -37,7 +37,7 @@ dependencies { implementation("org.apache.maven:maven-aether-provider:3.3.9") // When updating, update above in plugins too - implementation("com.diffplug.spotless:spotless-plugin-gradle:5.14.0") + implementation("com.diffplug.spotless:spotless-plugin-gradle:5.16.0") implementation("com.google.guava:guava:30.1-jre") implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0") implementation("org.ow2.asm:asm:9.1") diff --git a/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestAsyncWebServer.scala b/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestAsyncWebServer.scala index bdebd6b470..57792da0e8 100644 --- a/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestAsyncWebServer.scala +++ b/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestAsyncWebServer.scala @@ -29,7 +29,9 @@ object AkkaHttpTestAsyncWebServer { endpoint, new Closure[HttpResponse](()) { def doCall(): HttpResponse = { - val resp = HttpResponse(status = endpoint.getStatus) //.withHeaders(headers.Type)resp.contentType = "text/plain" + val resp = HttpResponse(status = + endpoint.getStatus + ) //.withHeaders(headers.Type)resp.contentType = "text/plain" endpoint match { case SUCCESS => resp.withEntity(endpoint.getBody) case INDEXED_CHILD => diff --git a/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestWebServer.scala b/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestWebServer.scala index a96f4e72ce..5330c1fffe 100644 --- a/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestWebServer.scala +++ b/instrumentation/akka-http-10.0/javaagent/src/test/scala/AkkaHttpTestWebServer.scala @@ -21,11 +21,10 @@ object AkkaHttpTestWebServer { // needed for the future flatMap/onComplete in the end implicit val executionContext = system.dispatcher - val exceptionHandler = ExceptionHandler { - case ex: Exception => - complete( - HttpResponse(status = EXCEPTION.getStatus).withEntity(ex.getMessage) - ) + val exceptionHandler = ExceptionHandler { case ex: Exception => + complete( + HttpResponse(status = EXCEPTION.getStatus).withEntity(ex.getMessage) + ) } val route = { //handleExceptions(exceptionHandler) { diff --git a/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/FinatraController.scala b/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/FinatraController.scala index b752bed614..34202ad1a8 100644 --- a/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/FinatraController.scala +++ b/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/FinatraController.scala @@ -12,42 +12,57 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest.controller class FinatraController extends Controller { any(SUCCESS.getPath) { request: Request => - controller(SUCCESS, new Closure[Response](null) { - override def call(): Response = { - response.ok(SUCCESS.getBody) + controller( + SUCCESS, + new Closure[Response](null) { + override def call(): Response = { + response.ok(SUCCESS.getBody) + } } - }) + ) } any(ERROR.getPath) { request: Request => - controller(ERROR, new Closure[Response](null) { - override def call(): Response = { - response.internalServerError(ERROR.getBody) + controller( + ERROR, + new Closure[Response](null) { + override def call(): Response = { + response.internalServerError(ERROR.getBody) + } } - }) + ) } any(QUERY_PARAM.getPath) { request: Request => - controller(QUERY_PARAM, new Closure[Response](null) { - override def call(): Response = { - response.ok(QUERY_PARAM.getBody) + controller( + QUERY_PARAM, + new Closure[Response](null) { + override def call(): Response = { + response.ok(QUERY_PARAM.getBody) + } } - }) + ) } any(EXCEPTION.getPath) { request: Request => - controller(EXCEPTION, new Closure[Future[Response]](null) { - override def call(): Future[Response] = { - throw new Exception(EXCEPTION.getBody) + controller( + EXCEPTION, + new Closure[Future[Response]](null) { + override def call(): Future[Response] = { + throw new Exception(EXCEPTION.getBody) + } } - }) + ) } any(REDIRECT.getPath) { request: Request => - controller(REDIRECT, new Closure[Response](null) { - override def call(): Response = { - response.found.location(REDIRECT.getBody) + controller( + REDIRECT, + new Closure[Response](null) { + override def call(): Response = { + response.found.location(REDIRECT.getBody) + } } - }) + ) } } diff --git a/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/ResponseSettingExceptionMapper.scala b/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/ResponseSettingExceptionMapper.scala index dbc7841e47..f6f1ad9852 100644 --- a/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/ResponseSettingExceptionMapper.scala +++ b/instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/ResponseSettingExceptionMapper.scala @@ -9,7 +9,7 @@ import com.twitter.finatra.http.response.ResponseBuilder import javax.inject.{Inject, Singleton} @Singleton -class ResponseSettingExceptionMapper @Inject()(response: ResponseBuilder) +class ResponseSettingExceptionMapper @Inject() (response: ResponseBuilder) extends ExceptionMapper[Exception] { override def toResponse(request: Request, exception: Exception): Response = { diff --git a/instrumentation/finatra-2.9/javaagent/src/test/scala/FinatraController.scala b/instrumentation/finatra-2.9/javaagent/src/test/scala/FinatraController.scala index fbc801d907..6e5c78fcbf 100644 --- a/instrumentation/finatra-2.9/javaagent/src/test/scala/FinatraController.scala +++ b/instrumentation/finatra-2.9/javaagent/src/test/scala/FinatraController.scala @@ -12,50 +12,68 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest.controller class FinatraController extends Controller { any(SUCCESS.getPath) { request: Request => - controller(SUCCESS, new Closure[Response](null) { - override def call(): Response = { - response.ok(SUCCESS.getBody) + controller( + SUCCESS, + new Closure[Response](null) { + override def call(): Response = { + response.ok(SUCCESS.getBody) + } } - }) + ) } any(ERROR.getPath) { request: Request => - controller(ERROR, new Closure[Response](null) { - override def call(): Response = { - response.internalServerError(ERROR.getBody) + controller( + ERROR, + new Closure[Response](null) { + override def call(): Response = { + response.internalServerError(ERROR.getBody) + } } - }) + ) } any(QUERY_PARAM.getPath) { request: Request => - controller(QUERY_PARAM, new Closure[Response](null) { - override def call(): Response = { - response.ok(QUERY_PARAM.getBody) + controller( + QUERY_PARAM, + new Closure[Response](null) { + override def call(): Response = { + response.ok(QUERY_PARAM.getBody) + } } - }) + ) } any(EXCEPTION.getPath) { request: Request => - controller(EXCEPTION, new Closure[Future[Response]](null) { - override def call(): Future[Response] = { - throw new Exception(EXCEPTION.getBody) + controller( + EXCEPTION, + new Closure[Future[Response]](null) { + override def call(): Future[Response] = { + throw new Exception(EXCEPTION.getBody) + } } - }) + ) } any(REDIRECT.getPath) { request: Request => - controller(REDIRECT, new Closure[Response](null) { - override def call(): Response = { - response.found.location(REDIRECT.getBody) + controller( + REDIRECT, + new Closure[Response](null) { + override def call(): Response = { + response.found.location(REDIRECT.getBody) + } } - }) + ) } any("/path/:id/param") { request: Request => - controller(PATH_PARAM, new Closure[Response](null) { - override def call(): Response = { - response.ok(request.params("id")) + controller( + PATH_PARAM, + new Closure[Response](null) { + override def call(): Response = { + response.ok(request.params("id")) + } } - }) + ) } } diff --git a/instrumentation/finatra-2.9/javaagent/src/test/scala/ResponseSettingExceptionMapper.scala b/instrumentation/finatra-2.9/javaagent/src/test/scala/ResponseSettingExceptionMapper.scala index dbc7841e47..f6f1ad9852 100644 --- a/instrumentation/finatra-2.9/javaagent/src/test/scala/ResponseSettingExceptionMapper.scala +++ b/instrumentation/finatra-2.9/javaagent/src/test/scala/ResponseSettingExceptionMapper.scala @@ -9,7 +9,7 @@ import com.twitter.finatra.http.response.ResponseBuilder import javax.inject.{Inject, Singleton} @Singleton -class ResponseSettingExceptionMapper @Inject()(response: ResponseBuilder) +class ResponseSettingExceptionMapper @Inject() (response: ResponseBuilder) extends ExceptionMapper[Exception] { override def toResponse(request: Request, exception: Exception): Response = { diff --git a/instrumentation/kotlinx-coroutines/javaagent/src/test/kotlin/KotlinCoroutineTests.kt b/instrumentation/kotlinx-coroutines/javaagent/src/test/kotlin/KotlinCoroutineTests.kt index 4921187b76..62196e1184 100644 --- a/instrumentation/kotlinx-coroutines/javaagent/src/test/kotlin/KotlinCoroutineTests.kt +++ b/instrumentation/kotlinx-coroutines/javaagent/src/test/kotlin/KotlinCoroutineTests.kt @@ -6,7 +6,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.trace.Tracer import io.opentelemetry.extension.kotlin.asContextElement -import java.util.concurrent.TimeUnit import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope @@ -24,6 +23,7 @@ import kotlinx.coroutines.selects.select import kotlinx.coroutines.withContext import kotlinx.coroutines.withTimeout import kotlinx.coroutines.yield +import java.util.concurrent.TimeUnit class KotlinCoroutineTests(private val dispatcher: CoroutineDispatcher) { val tracer: Tracer = GlobalOpenTelemetry.getTracer("test") diff --git a/instrumentation/scala-executors/javaagent/src/test/scala/ScalaConcurrentTests.scala b/instrumentation/scala-executors/javaagent/src/test/scala/ScalaConcurrentTests.scala index 4da735ff09..0efd159da2 100644 --- a/instrumentation/scala-executors/javaagent/src/test/scala/ScalaConcurrentTests.scala +++ b/instrumentation/scala-executors/javaagent/src/test/scala/ScalaConcurrentTests.scala @@ -59,16 +59,15 @@ class ScalaConcurrentTests { val goodFuture: Future[Integer] = Future { 1 } - goodFuture onSuccess { - case _ => - Future { - 2 - } onSuccess { - case _ => { - tracedChild("callback") - latch.countDown() - } + goodFuture onSuccess { case _ => + Future { + 2 + } onSuccess { + case _ => { + tracedChild("callback") + latch.countDown() } + } } latch.await() @@ -131,16 +130,22 @@ class ScalaConcurrentTests { val parentScope = Java8BytecodeBridge.currentContext().`with`(parentSpan).makeCurrent() try { - val completedVal = Future.firstCompletedOf(List(Future { - tracedChild("timeout1") - false - }, Future { - tracedChild("timeout2") - false - }, Future { - tracedChild("timeout3") - true - })) + val completedVal = Future.firstCompletedOf( + List( + Future { + tracedChild("timeout1") + false + }, + Future { + tracedChild("timeout2") + false + }, + Future { + tracedChild("timeout3") + true + } + ) + ) Await.result(completedVal, 30 seconds) } finally { parentSpan.end() diff --git a/testing/agent-for-testing/build.gradle.kts b/testing/agent-for-testing/build.gradle.kts index 6928c0edcb..c05e939e2b 100644 --- a/testing/agent-for-testing/build.gradle.kts +++ b/testing/agent-for-testing/build.gradle.kts @@ -28,9 +28,11 @@ tasks { // Extracts manifest from OpenTelemetry Java agent to reuse it later val agentManifest by registering(Copy::class) { dependsOn(agent) - from(zipTree(agent.singleFile).matching { - include("META-INF/MANIFEST.MF") - }) + from( + zipTree(agent.singleFile).matching { + include("META-INF/MANIFEST.MF") + } + ) into("$buildDir/tmp") }