Tudor Luca
05/20/2023, 3:11 PMJarkko Miettinen
05/22/2023, 11:59 AMErik Dreyer
05/26/2023, 4:23 PMJwtDecoder
bean due to an ambiguous constructor in a java class
The error I get is:
/auth0/my-auth0-demo/auth0/src/main/kotlin/com/curbee/auth0/SecurityConfig.kt:48:7
Kotlin: None of the following functions can be called with the arguments supplied:
public constructor DelegatingOAuth2TokenValidator<T : OAuth2Token!>(vararg tokenValidators: OAuth2TokenValidator<TypeVariable(T)!>!) defined in org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator
public constructor DelegatingOAuth2TokenValidator<T : OAuth2Token!>(tokenValidators: (Mutable)Collection<OAuth2TokenValidator<TypeVariable(T)!>!>!) defined in org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator
To help assist, the constructors for the class in error:
`DelegatingOAuth2TokenValidator.java`:
public DelegatingOAuth2TokenValidator(Collection<OAuth2TokenValidator<T>> tokenValidators) {
Assert.notNull(tokenValidators, "tokenValidators cannot be null");
this.tokenValidators = new ArrayList<>(tokenValidators);
}
@SafeVarargs
public DelegatingOAuth2TokenValidator(OAuth2TokenValidator<T>... tokenValidators) {
this(Arrays.asList(tokenValidators));
}
I’ve tried all kinds of combinations to try and get this to compile.
e.g.
• DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(withIssuer)
• DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(*withIssuer)
• DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(listOf(withIssuer))
• DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(*listOf(withIssuer))
• DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(java.utils.Arrays.asList(withIssuer))
I could use some help figuring how to give a hint to which consructorDaniel
05/29/2023, 2:07 PMsealed class Event {
abstract val receivedAt: Instant
abstract val occurredAt: Instant
...
data class Incoming(
override val receivedAt: Instant,
override val occurredAt: Instant,
...
) : Event()
sealed class Stored : Event() {
abstract val authorUid: ULong
data class Pending(
override val receivedAt: Instant,
override val authorUid: ULong,
override val occurredAt: Instant,
...
) : Stored()
data class Uploaded(
override val receivedAt: Instant,
override val authorUid: ULong,
override val occurredAt: Instant,
...
val uploadedAt: Instant
) : Stored()
}
}
interface EventRepository {
fun storeEvent(authorUid: ULong, event: Event.Incoming): Event.Stored.Pending
fun confirmEvent(event: Event.Stored.Pending, uploadTime: Instant = Instant.now()): Event.Stored.Uploaded
fun getEvents(): Collection<Event.Stored>
fun getEventsCount(): ULong
fun pendingEvents(): Collection<Event.Stored.Pending>
fun pendingEventsCount(): ULong
}
Ryan Brink
05/29/2023, 7:04 PMfun String.runCommand(workingDir: File): ProcessUtils.Result {
val parts = this.split("\\s".toRegex())
val proc = ProcessBuilder(parts)
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
proc.waitFor(60, TimeUnit.SECONDS)
val exitCode = proc.exitValue()
val outputText = proc.inputStream.bufferedReader().readText().trim()
return ProcessUtils.Result(exitCode, outputText)
}
I have confirmed that _workingDir.exists_() && _workingDir_._isDirectory_()
is true, but when the proc starts, it errors out with a dir not found error. Cannot fathom how the first statement can be true (confirmed dir does exist) but the proc cannot find it. My only guess is a permissions issue, but I cant find anything to confirm this is the case. Anyone have any ideas?carlos
05/30/2023, 12:52 AMAjay Narayanan
06/05/2023, 1:15 PMHaksun Li
06/08/2023, 12:14 AMHaksun Li
06/08/2023, 12:14 AMHaksun Li
06/08/2023, 12:15 AMHaksun Li
06/08/2023, 12:18 AMKhurram Malik
06/08/2023, 9:46 AMplugins {
id("org.jetbrains.kotlin.jvm") version "1.8.20"
id("org.jetbrains.kotlin.plugin.allopen") version "1.8.20"
id("com.google.devtools.ksp") version "1.8.20-1.0.10"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.micronaut.application") version "4.0.0-M2"
}
version = project.properties["version"] as String? ?: "0.0.1"
group = "dk.****"
val kotlinVersion = project.properties["kotlinVersion"]
repositories {
mavenCentral()
}
dependencies {
implementation("io.micronaut:micronaut-jackson-databind")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-management")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
testImplementation("io.micronaut:micronaut-http-client")
}
application {
mainClass.set("dk.***.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("17")
}
tasks {
compileKotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
compileTestKotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
}
graalvmNative.toolchainDetection.set(false)
micronaut {
runtime("netty")
testRuntime("kotest5")
processing {
incremental(true)
annotations("dk.***.*")
}
}
Benjamin Tissot
06/08/2023, 5:52 PMval myCollection = database.getCollection<Object>()
class MyService {
companion object {
suspend fun myMethod(){
myCollection.doSomething()
}
}
}
The issue is that the database
object called here is imported from my Server class where it is imported as such:
val client = KMongo.createClient().coroutine
val database = client.getDatabase("debug_name")
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
Now, this worked perfectly until I needed to test it (I know I should've started by the tests, my bad)
The issue is that, as it is, when my test class calls MyService.myMethod()
, the collection used is the "debug_name". I have instantiated another database in the @BeforeClass
method from my test class, but I can't figure out how to use it.
My different ideas so far have consisted of :
• using a constructor for the Service class with the database to use, which I know is not a good solution
• detecting the type of build running to pass a different parameter to the getDatabase()
method (maybe via environment variables?), but I feel like this would not be optimal at all and kind of go against the idea behind testing philosophy, as it sould still be using the database
variable stored in the Server
file instead of a controlled test-environment database
I am absolutely unsure of how to go about this and nothing I have tried has even started to work a tiny bit. If you have insights on how to properly do this, I'd be super grateful !
A wannabe-programmerDominik Sandjaja
06/09/2023, 8:14 AMtimestamp
column.
PostgreSQL has microsecond resolution for that column.
On MacOS, this works because Clock.System.now()
also returns an Instant
with microsecond resolution, so comparing an object before persisting it and after retrieving it from the database works.
On Linux (which we use for our pipeline) this same comparison fails because 2023-06-09T07:34:27.965341799Z != 2023-06-09T07:34:27.965342Z
I found similar issues for e.g. H2, but there it seems possible to simply store nanoseconds in the database.
It is not necessarily an issue to change the tests, we can simply set fixed instants (without nanosecond precision), but the question remains nevertheless:
Is there a way to force Kotlin to always use a specific precision?Omer Katz
06/12/2023, 5:16 PMpackage bla.testdoubles.stubs
import bla.testdoubles.TreehouseTestFixture
import bla.testdoubles.fakes.FakeRequest
import bla.ServiceRequest
typealias Builder = ServiceRequest.ServiceRequestBuilder<FakeRequest>
val FakeRequestFixture = MyCustomTestFixture<FakeRequest> {
}
val ServiceRequestFixture = MyCustomTestFixture<Builder> {
property<Builder, FakeRequest>(Builder::request) {
FakeRequestFixture
}
property<Builder, String>("fullRequestURI") {
// TODO: use Faker
"123"
}
}
The compiler says that Builder::request
is a private member and cannot be accessed. I'm trying to refer to the automatically generated setter and not the private request variable that the Builder declared.
This is the error:
Cannot access 'request': it is private in 'ServiceRequestBuilder'
The generated setter uses the setRequest
method and that should be public.
What am I doing wrong here?sangjaekim
06/13/2023, 2:51 AM@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class ReflectionTarget(
val clazz: KClass<out Any> = Any::class,
)
data class UserInfo(
val name: String,
@ReflectionTarget(clazz = UserDetailsResponse::class)
val userDetails: UserDetails,
)
data class UserDetails(
val age: Int,
val email: String,
)
How can I get the information of annotation and the field of annotation by reflection using the code below on runtime?Matthew Adams
06/14/2023, 2:54 PMServerSocket
or similar to listen on a particular port for wifi direct group members to connect to?Charles Maina
06/16/2023, 7:43 AMasavio
06/20/2023, 10:04 AMdave
06/21/2023, 12:32 PMferdiafagan
06/21/2023, 4:11 PMAlexander S
06/21/2023, 9:26 PMJohann Pardanaud
06/22/2023, 12:52 PMLeandro Garcia
06/23/2023, 12:44 PMnumpy
for kotlin? I was copying a small script I have for border detection from python to kotlin and stuff like matrix operations were a pain to do.Alexander S
06/25/2023, 9:06 PMAlexander S
07/03/2023, 1:36 PMauthenticate(...)
call in Ktor? Alternatively, is there a way to update a session every time a route is called without having to call a function inside of each endpoint handler?
Edit: I ended up solving this using the alternative solution with custom plugins to update the session.Jeroen Flietstra
07/03/2023, 7:36 PMAndrew O'Hara
07/04/2023, 3:12 PMTomáš Krasoň
07/06/2023, 9:59 AMWaref Haque
07/11/2023, 4:25 PMcompileKotlin
task when trying to build my kotlin project is infinitely looping. I left it running and as we can see it didn’t finish for 1.5 hours. I don’t think I changed anything in particular other than upgrading the kotlin plugin on Intellij. Is anyone else facing this recently?
Some metadata if anyone finds it useful:
kotlin("jvm") version "1.7.21"
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
I tried changing the kotlin compiler to use the experimental K2 as well but no luck. Unfortunately its blocking some critical development that needs to happen in my organization so any advice would be much appreciated! 🙏