Skip to content
31 changes: 17 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ apiValidation {
"exemplar",
"exemplarchat",
"detektive",
"misk-schema-migrator-gradle-plugin"
"misk-schema-migrator-gradle-plugin",
)
ignoredProjects.addAll(subprojects.map { it.name }.filter { it in ignorable })
additionalSourceSets.add("testFixtures")
Expand Down Expand Up @@ -191,13 +191,13 @@ val hibernateProjects = listOf(
"misk-jdbc-testing",
"misk-hibernate-testing",
"misk-rate-limiting-bucket4j-mysql",
"misk-sqldelight"
"misk-sqldelight",
)

val redisProjects = listOf(
"misk-redis",
"misk-redis-lettuce",
"misk-rate-limiting-bucket4j-redis"
"misk-rate-limiting-bucket4j-redis",
)

val detektConfig = file("detekt.yaml")
Expand Down Expand Up @@ -275,6 +275,7 @@ subprojects {
add("api", platform(rootProject.libs.jacksonBom))
add("api", platform(rootProject.libs.jerseyBom))
add("api", platform(rootProject.libs.jettyBom))
add("api", platform(rootProject.libs.jettyEe9Bom))
add("api", platform(rootProject.libs.kotlinBom))
add("api", platform(rootProject.libs.nettyBom))
add("api", platform(rootProject.libs.prometheusClientBom))
Expand Down Expand Up @@ -314,7 +315,7 @@ subprojects {
"dd.civisibility.git.upload.enabled" to false,
"dd.integration.opentracing.enabled" to true,
"dd.instrumentation.telemetry.enabled" to false,
)
),
)
develocity.testRetry {
maxRetries.set(1)
Expand Down Expand Up @@ -380,7 +381,7 @@ subprojects {
if (name in configurationNames) {
attributes.attribute(
Usage.USAGE_ATTRIBUTE,
this@subprojects.objects.named(Usage::class, Usage.JAVA_RUNTIME)
this@subprojects.objects.named(Usage::class, Usage.JAVA_RUNTIME),
)
}

Expand Down Expand Up @@ -485,7 +486,7 @@ abstract class StartRedisTask @Inject constructor(
val portIsOccupied = try {
Socket("localhost", redisPort).close()
true
} catch (e: IOException) {
} catch (_: IOException) {
false
}
if (portIsOccupied) {
Expand All @@ -502,7 +503,7 @@ abstract class StartRedisTask @Inject constructor(
"-p", "$redisPort:6379",
redisImage,
"redis-server",
"--loglevel debug"
"--loglevel debug",
)
execOperations.exec {
workingDir(rootDir.get().asFile)
Expand Down Expand Up @@ -536,7 +537,7 @@ abstract class StartRedisClusterTask @Inject constructor(
val portIsOccupied = try {
Socket("localhost", redisSeedPort).close()
true
} catch (e: IOException) {
} catch (_: IOException) {
false
}
if (portIsOccupied) {
Expand All @@ -555,34 +556,36 @@ abstract class StartRedisClusterTask @Inject constructor(
"-e", "MASTERS=3",
"-e", "SLAVES_PER_MASTER=1",
"-p", "7000-7005:7000-7005",
redisImage
redisImage,
)
execOperations.exec {
workingDir(rootDir.get().asFile)
commandLine(*dockerArguments)
}

waitForRedisCluster(redisContainerName,redisSeedPort)
waitForRedisCluster(redisContainerName, redisSeedPort)

logger.info("Started Redis Cluster docker image $redisImage on port $redisSeedPort")
}

private fun waitForRedisCluster(containerName:String, port:Int){
private fun waitForRedisCluster(containerName: String, port: Int) {
println("Waiting for Redis cluster to become available...")
val deadline = System.currentTimeMillis() + 60.seconds.inWholeMilliseconds

fun clusterReady(): Boolean {
try {
val process = ProcessBuilder("docker", "exec", containerName,
"redis-cli", "-c", "-p", port.toString(), "cluster", "info")
val process = ProcessBuilder(
"docker", "exec", containerName,
"redis-cli", "-c", "-p", port.toString(), "cluster", "info",
)
.redirectErrorStream(true)
.start()

val output = process.inputStream.bufferedReader().readText()
process.waitFor(5, TimeUnit.SECONDS)

return "cluster_state:ok" in output && "slots_assigned:16384" in output
} catch (e: Exception) {
} catch (_: Exception) {
return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class AnnotatePublicApisWithJvmOverloads(config: Config) : Rule(config) {
)
element.addAfter(KtPsiFactory.contextual(element.parent, markGenerated = true).createWhiteSpace(), null)
} else if (elementType == ElementType.FUNCTION) {
annotation.addBefore(KtPsiFactory.contextual(element.parent, markGenerated = true).createNewLine(), null)
annotation.addBefore(
KtPsiFactory.contextual(element.parent, markGenerated = true).createNewLine(),
null,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cash.detektive.javacompat

import cash.detektive.javacompat.AnnotatePublicApisWithJvmOverloads.ElementType
import io.github.detekt.parser.DetektPomModel
import io.github.detekt.test.utils.compileForTest
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Severity
Expand All @@ -12,12 +13,11 @@ import io.gitlab.arturbosch.detekt.test.getContextForPaths
import java.io.File
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.com.intellij.mock.MockProject
import org.jetbrains.kotlin.com.intellij.mock.MockApplication
import org.jetbrains.kotlin.com.intellij.mock.MockProject
import org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger
import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.com.intellij.pom.PomModel
import io.github.detekt.parser.DetektPomModel
import org.jetbrains.kotlin.config.CompilerConfigurationKey
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactoryImpl
Expand Down
18 changes: 10 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ googleHttp = "2.0.0"
guava = "33.5.0-jre"
hoplite = "2.7.5"
jackson = "2.21.2"
jetty = "12.0.23"
jooq = "3.19.29"
junit = "5.14.2"
kotest = "6.0.7"
Expand Down Expand Up @@ -136,20 +137,21 @@ jerseyBom = { module = "org.glassfish.jersey:jersey-bom", version = "3.1.11" }
jetbrainsAnnotations = { module = "org.jetbrains:annotations", version = "26.0.2-1" }
jettyAlpnServer = { module = "org.eclipse.jetty:jetty-alpn-server" }
jettyAlpnServerJava = { module = "org.eclipse.jetty:jetty-alpn-java-server" }
jettyBom = { module = "org.eclipse.jetty:jetty-bom", version = "11.0.26" }
jettyBom = { module = "org.eclipse.jetty:jetty-bom", version.ref = "jetty" }
jettyEe9Bom = { module = "org.eclipse.jetty.ee9:jetty-ee9-bom", version.ref = "jetty" }
jettyEe9Nested = { module = "org.eclipse.jetty.ee9:jetty-ee9-nested" }
jettyHttp = { module = "org.eclipse.jetty:jetty-http" }
jettyHttp2 = { module = "org.eclipse.jetty.http2:http2-server" }
jettyHttp2Common = { module = "org.eclipse.jetty.http2:http2-common" }
jettyHttp2 = { module = "org.eclipse.jetty.http2:jetty-http2-server", version.ref = "jetty" }
jettyHttp2Common = { module = "org.eclipse.jetty.http2:jetty-http2-common", version.ref = "jetty" }
jettyIo = { module = "org.eclipse.jetty:jetty-io" }
jettyServer = { module = "org.eclipse.jetty:jetty-server" }
jettyServlet = { module = "org.eclipse.jetty:jetty-servlet" }
jettyServlet = { module = "org.eclipse.jetty.ee9:jetty-ee9-servlet" }
jettyServletApi = { module = "org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api", version = "5.0.2" }
jettyServlets = { module = "org.eclipse.jetty:jetty-servlets" }
jettyServlets = { module = "org.eclipse.jetty.ee9:jetty-ee9-servlets" }
jettyUds = { module = "org.eclipse.jetty:jetty-unixdomain-server" }
jettyUnixSocket = { module = "org.eclipse.jetty:jetty-unixsocket-server" }
jettyUtil = { module = "org.eclipse.jetty:jetty-util" }
jettyWebsocketApi = { module = "org.eclipse.jetty.websocket:websocket-jetty-api" }
jettyWebsocketServer = { module = "org.eclipse.jetty.websocket:websocket-jetty-server" }
jettyWebsocketApiEE9 = { module = "org.eclipse.jetty.ee9.websocket:jetty-ee9-websocket-jetty-api" }
jettyWebsocketServerEE9 = { module = "org.eclipse.jetty.ee9.websocket:jetty-ee9-websocket-jetty-server" }
jnrUnixsocket = { module = "com.github.jnr:jnr-unixsocket", version = "0.38.24" }
jooq = { module = "org.jooq:jooq" }
jooqBom = { module = "org.jooq:jooq-bom", version.ref = "jooq" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ internal class ActionScopePropagationTest {

val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

val callable = scope.create(seedData).inScope {
scope.propagate(Callable { tester.fooValue() })
}
val callable = scope.create(seedData).inScope { scope.propagate(Callable { tester.fooValue() }) }

scope.create(seedData).inScope {
// Submit to same thread after we've already entered the scope
Expand All @@ -50,9 +48,7 @@ internal class ActionScopePropagationTest {

val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

val callable = scope.create(seedData).inScope {
scope.propagate(Callable { tester.fooValue() })
}
val callable = scope.create(seedData).inScope { scope.propagate(Callable { tester.fooValue() }) }

// Submit to other thread after we've exited the scope
val result = singleThreadExecutor.submit(callable).get()
Expand All @@ -69,9 +65,7 @@ internal class ActionScopePropagationTest {

// Propagate on the the KCallable directly
val f: KFunction<String> = tester::fooValue
val callable = scope.create(seedData).inScope {
scope.propagate(f)
}
val callable = scope.create(seedData).inScope { scope.propagate(f) }

scope.create(seedData).inScope {
// Submit to same thread after we've already entered the scope
Expand All @@ -90,9 +84,7 @@ internal class ActionScopePropagationTest {

// Propagate on the the KCallable directly
val f: KFunction<String> = tester::fooValue
val callable = scope.create(seedData).inScope {
scope.propagate(f)
}
val callable = scope.create(seedData).inScope { scope.propagate(f) }

// Submit to other thread after we've exited the scope
val result = singleThreadExecutor.submit(Callable { callable.call() }).get()
Expand All @@ -108,9 +100,7 @@ internal class ActionScopePropagationTest {
val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

// Propagate on a lambda directly
val function = scope.create(seedData).inScope {
scope.propagate { tester.fooValue() }
}
val function = scope.create(seedData).inScope { scope.propagate { tester.fooValue() } }

scope.create(seedData).inScope {
// Submit to same thread after we've already entered the scope
Expand All @@ -128,9 +118,7 @@ internal class ActionScopePropagationTest {
val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

// Propagate on a lambda directly
val function = scope.create(seedData).inScope {
scope.propagate { tester.fooValue() }
}
val function = scope.create(seedData).inScope { scope.propagate { tester.fooValue() } }

// Submit to other thread after we've exited the scope
val result = singleThreadExecutor.submit(Callable { function() }).get()
Expand Down
24 changes: 9 additions & 15 deletions misk-action-scopes/src/test/kotlin/misk/scope/ActionScopedTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ internal class ActionScopedTest {
val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "seed-value")

scope.create(seedData).inScope {
runBlocking(scope.asContextElement()) {
assertThat(foo.get()).isEqualTo("seed-value and bar and foo!")
}
runBlocking(scope.asContextElement()) { assertThat(foo.get()).isEqualTo("seed-value and bar and foo!") }
}
}

Expand Down Expand Up @@ -218,14 +216,12 @@ internal class ActionScopedTest {

val instance = scope.snapshotActionScopeInstance()
thread {
try {
instance.inScope {
assertThat(foo.get()).isEqualTo("seed-value and bar and foo!")
try {
instance.inScope { assertThat(foo.get()).isEqualTo("seed-value and bar and foo!") }
} catch (t: Throwable) {
thrown = t
}
} catch (t: Throwable) {
thrown = t
}
}
.join()
assertThat(thrown).isNull()
}
Expand Down Expand Up @@ -260,14 +256,12 @@ internal class ActionScopedTest {

val instance = scope.snapshotActionScopeInstance()
thread {
try {
instance.inScope {
assertThat(foo.get()).isEqualTo("seed-value and bar and foo!")
try {
instance.inScope { assertThat(foo.get()).isEqualTo("seed-value and bar and foo!") }
} catch (t: Throwable) {
thrown = t
}
} catch (t: Throwable) {
thrown = t
}
}
.join()
assertThat(thrown).isNull()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ internal class ActionScopedCoroutineTest {

val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

val value = scope.create(seedData).inScope {
scope.runBlocking {
tester.fooValue()
}
}
val value = scope.create(seedData).inScope { scope.runBlocking { tester.fooValue() } }

assertThat(value).isEqualTo("my seed data and bar and foo!")
}
Expand All @@ -48,11 +44,7 @@ internal class ActionScopedCoroutineTest {

val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

val value = scope.create(seedData).inScope {
scope.runBlocking(Dispatchers.IO) {
tester.fooValue()
}
}
val value = scope.create(seedData).inScope { scope.runBlocking(Dispatchers.IO) { tester.fooValue() } }

assertThat(value).isEqualTo("my seed data and bar and foo!")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ internal class ActionScopedExecutorServiceTest {

val seedData: Map<Key<*>, Any> = mapOf(keyOf<String>(Names.named("from-seed")) to "my seed data")

val future = scope.create(seedData).inScope {
executor.submit(Callable { tester.fooValue() })
}
val future = scope.create(seedData).inScope { executor.submit(Callable { tester.fooValue() }) }

assertThat(future.get()).isEqualTo("my seed data and bar and foo!")
}
Expand Down
4 changes: 2 additions & 2 deletions misk-actions/src/main/kotlin/misk/MiskCaller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ constructor(
/**
* When true, this caller is authorized for all endpoints regardless of required capabilities, services, or users.
*
* This is intended for use in controlled environments (e.g., staging playpens) where a trusted caller needs
* blanket access for testing. It should never be set in production.
* This is intended for use in controlled environments (e.g., staging playpens) where a trusted caller needs blanket
* access for testing. It should never be set in production.
*/
val allowAll: Boolean = false,
) {
Expand Down
4 changes: 1 addition & 3 deletions misk-actions/src/main/kotlin/misk/web/Http.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ annotation class ResponseContentType(vararg val value: String)
* }
* ```
*/
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION)
annotation class EnableUnframedRequests
@Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FUNCTION) annotation class EnableUnframedRequests

/**
* When the service is overloaded Misk will intervene and reject calls by returning "HTTP 503 Service Unavailable". We
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ constructor(
}

// Module that allows testing/development environments to bind up the admin dashboard
class AdminDashboardTestingModule @JvmOverloads constructor(
private val enableTurbo: Boolean = true,
) : KAbstractModule() {
class AdminDashboardTestingModule @JvmOverloads constructor(private val enableTurbo: Boolean = true) :
KAbstractModule() {
override fun configure() {
// Set dummy values for access, these shouldn't matter,
// as test environments should prefer to use the FakeCallerAuthenticator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import misk.web.v2.DashboardV2RedirectAction
* - `admin-dashboard` tab which loads all other tabs and provides navbar, menu links, auth
* - `@misk` packages used by Misk-Web tabs from window to provide faster tab loads
*/
class BaseDashboardModule @JvmOverloads constructor(
class BaseDashboardModule
@JvmOverloads
constructor(
private val isDevelopment: Boolean,
private val layoutConfig: DashboardLayoutConfig = DashboardLayoutConfig(),
) : KAbstractModule() {
Expand Down
Loading