https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
spring
  • l

    Leonardo Borges

    01/18/2022, 12:03 PM
    I have a spring boot application which is structured in hexagonal architecture (using clean architecture). So I have a sealed class which is at domain layer and I would not like to "mess" it with annotations. The issue is that I wouldn't like to expose the domain, but a resource class. I usually do it easily, creating a
    toDomain()
    function. But in this case, I don't know how to do it. Since I'm new to sealed class, maybe there is a solution which I haven't found... The sealed class (domain) is something like:
    sealed class TypeInstruction(val type: String) {
        data class TypeOne(val isRequired: Boolean, val maxConcurrency: Short) : TypeInstruction(type = "typeOne")
    
        data class TypeTwo(val isRequired: Boolean, val maxAttemps: Short): TypeInstruction(type = "typeTwo")
    }
    And the resource is:
    sealed class TypeInstructionResource(val type: String) {
        data class TypeOne(val isRequired: Boolean, val maxConcurrency: Short) : TypeInstruction(type = "typeOne")
    
        data class TypeTwo(val isRequired: Boolean, val maxAttemps: Short): TypeInstruction(type = "typeTwo")
    }
    Then an extended function:
    fun TypeInstructionResource.toDomain() = when(type) {
        "typeOne" -> TypeInstruction.TypeOne(isRequired = isRequired, maxConcurrency = maxConcurrency)
        "typeTwo" -> TypeInstruction.TypeTwo(isRequired = isRequired, maxAttemps = maxAttemps)
        else -> /* */
    }
    But of course, the extended function does not recognize the "children" values, such as
    isRequired
    . Any suggestions?
    t
    • 2
    • 9
  • g

    George

    01/19/2022, 9:18 AM
    Hi, I have a spring boot application and I'm trying to use kotlin serialization, i have set up my project according by the springs docs. So I trying to test my controller if it returns the expected result. If I boot my application the content is not as expected as I have some transient fields in my class but nonetheless the appear on the response. So I created a test to assert the expected body but I'm getting an error from fasterxml.jackson invalid definition. So far my guess is for some reason I'm not using kotlins seralization. The catch is my object has a field with type any and marked with contextual , so I tried to create my own serializers module based on kotlin.serialization docs/guides but I had no luck to be able to tell spring to use my own custom serializers module . Any idea ? Thanks In advance !
    e
    s
    • 3
    • 23
  • h

    henrik

    01/21/2022, 12:22 PM
    Say I have a class like this:
    @RestController
    class Foo(val bar: Bar, val baz: Baz = Baz("ding"))
    bar
    and
    baz
    will be autowired automatically as expected. But is it possible to disable autowiring for
    baz
    since it has a default value?
    t
    j
    • 3
    • 9
  • r

    Robert

    01/25/2022, 6:59 AM
    What's the best way to handle java.lang.OutOfMemory Error? Usually I let it propagate to the JVM/Docker container so the instance get’s killed / restarted. In my current application this error get’s caught in the Tomcat server of spring boot and I don't know why … any clues?
    :not-kotlin: 4
    j
    k
    • 3
    • 5
  • d

    dany giguere

    01/26/2022, 10:50 PM
    Anyone could give me feedbacks regarding https://ebean.io/ for spring book with kotlin ? It doens’t seem to be updated anymore but maybe it’s mature enough so it doesn’t.
    k
    • 2
    • 1
  • m

    Michael de Kaste

    01/31/2022, 10:12 AM
    Hello! I have a question regarding validation on web requests. We're validating the requestbody with some constraints, however, we have an additional constraint which needs access to the "referentie" parameter. We made it a value_parameter constraint, but unlike a nice 400 we normally can get back, with this, we get a 500. Is there a way to make this work?
    n
    • 2
    • 1
  • s

    Slackbot

    02/02/2022, 6:41 PM
    This message was deleted.
    :not-kotlin: 2
    t
    • 2
    • 2
  • s

    Slackbot

    02/06/2022, 1:43 AM
    This message was deleted.
    s
    • 2
    • 1
  • s

    SecretX

    02/06/2022, 9:09 PM
    Is there any functional difference between
    @PostMapping
    suspend fun uploadFile(@RequestParam file: Mono<FilePart>)
    and
    @PostMapping
    suspend fun uploadFile(@RequestParam file: FilePart)
    other than maybe allow the former to not pass any value?
    r
    • 2
    • 1
  • m

    Manoj

    02/21/2022, 10:41 AM
    Hi, Any resources for spring boot + kotlin best practices and tutorials?
    a
    l
    t
    • 4
    • 8
  • l

    Lucas León

    02/22/2022, 4:09 AM
    Hi everyone! I cannot add Ktor Client to Spring Boot Maven project. I’m trying to add Ktor Client to my Spring Boot Maven project but IntelliJ does not detect the dependencies. Already tried with reimporting maven dependencies, cleaning cache, mvn idea:idea and also creating another Spring Boot Maven project in a different machine and still doesn’t work. This is my pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="<http://maven.apache.org/POM/4.0.0>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
             xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <https://maven.apache.org/xsd/maven-4.0.0.xsd>">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.6.3</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>demoproject</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>demoproject</name>
        <description>demoproject</description>
        <properties>
            <java.version>1.8</java.version>
            <kotlin.version>1.6.10</kotlin.version>
            <ktor.version>1.6.7</ktor.version>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-webflux</artifactId>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.module</groupId>
                <artifactId>jackson-module-kotlin</artifactId>
            </dependency>
            <dependency>
                <groupId>io.projectreactor.kotlin</groupId>
                <artifactId>reactor-kotlin-extensions</artifactId>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-reflect</artifactId>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-jdk8</artifactId>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlinx</groupId>
                <artifactId>kotlinx-coroutines-reactor</artifactId>
            </dependency>
            <dependency>
                <groupId>io.ktor</groupId>
                <artifactId>ktor-client-core</artifactId>
                <version>${ktor.version}</version>
            </dependency>
            <dependency>
                <groupId>io.ktor</groupId>
                <artifactId>ktor-client-cio</artifactId>
                <version>${ktor.version}</version>
            </dependency>
            <dependency>
                <groupId>io.ktor</groupId>
                <artifactId>ktor-client-serialization</artifactId>
                <version>${ktor.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>io.projectreactor</groupId>
                <artifactId>reactor-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
            <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <configuration>
                        <args>
                            <arg>-Xjsr305=strict</arg>
                        </args>
                        <compilerPlugins>
                            <plugin>spring</plugin>
                        </compilerPlugins>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.jetbrains.kotlin</groupId>
                            <artifactId>kotlin-maven-allopen</artifactId>
                            <version>${kotlin.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    
    </project>
    And this is what I get in IntelliJ
    n
    • 2
    • 3
  • s

    Sourabh Rawat

    02/25/2022, 10:46 AM
    Why does
    @Component
    class Foo {
        inline fun foo() {}
    }
    gives me
    inline' modifier is not allowed on virtual members. Only private or final members can be inlined
    s
    • 2
    • 4
  • m

    Manoj

    03/02/2022, 10:25 AM
    How to use
    @ Value
    annotation in spring with Kotlin?
    s
    • 2
    • 17
  • a

    Alfy

    03/03/2022, 3:21 PM
    Anyone know how to retrieve the spring provided instance of an object mapper? I've tried autowiring as such
    @Autowired
    lateinit var builder: Jackson2ObjectMapperBuilder
    :not-kotlin: 1
    t
    t
    • 3
    • 4
  • m

    Manoj

    03/06/2022, 5:35 PM
    Anyone know how to create bean for sealed classes. when i try using @Component annotation, it is throwing an error
    Consider defining a bean of type '' in your configuration.
    ?
    k
    • 2
    • 1
  • z

    zero_coding

    03/15/2022, 1:53 PM
    https://stackoverflow.com/questions/71483390/avoid-basic-auth-when-using-x-509-authentication
    k
    t
    • 3
    • 2
  • a

    Alfy

    03/21/2022, 6:40 PM
    ❓ How do we make non-blocking http post request in springboot? I have service A that is making about 100 or so request to service B. I want service A to make non-blocking http post request, that is make the http post request but don't wait for a response to make another one.
    :not-kotlin: 1
    e
    s
    s
    • 4
    • 5
  • l

    Lucas León

    03/23/2022, 10:20 PM
    Hi everyone! How can I use Kotlin Serializer in a Spring Boot app?
    a
    s
    • 3
    • 3
  • m

    Manoj

    03/25/2022, 2:25 PM
    Hi all, Any good resources/courses/books for reactive programming with kotlin (for backend) with spring boot ?
    s
    • 2
    • 2
  • e

    Eric

    03/25/2022, 5:34 PM
    Has anyone been able to use AspectJ w/ Spring Boot and Kotlin? I’m trying to instrument a third party library, but for some reason it isn’t picking up my settings in
    META-INF/aop.xml
    . Also, when instrumenting Kotlin classes, it throws
    org.aspectj.weaver.loadtime.Aj - com/company/<NameOfKotlinClass>MethodAccess java.lang.RuntimeException: Illegal type for StackMapType: 12
    .
    • 1
    • 2
  • s

    sdeleuze

    03/31/2022, 11:49 AM
    Releases on their way, related blog post https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
    :thank-you: 6
    👍🏻 1
    👍 9
    r
    • 2
    • 1
  • p

    Peter

    04/22/2022, 4:47 PM
    I have a @Scheduled job that has a runBlocking { … } inside and performs cpu intensive work for multiple minutes. Due to this load, the actuator health endpoint becomes slow too, making the service seemingly unhealthy and thus triggers the cloud provider to restart the container. I tried isolating @Scheduled logic coroutine execution into a separate thread, but this does not help:
    val pollingContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
    withContext(pollingContext) {
    ...
    }
    Anyone any ideas? Thanks!
    a
    • 2
    • 1
  • a

    André Martins

    05/02/2022, 4:06 PM
    Hey is there any coroutine version of web filters for kotlin?
    s
    • 2
    • 3
  • a

    André Martins

    05/03/2022, 3:39 PM
    Hello, I’m following this approach in order to get coroutine wrappers for Webflux WebFilters and I’m now trying to propagate MDC context in order to have it on my controllers. Im using
    withContext(MDCContext())
    whenever I put something in MDC, also using Mono
    contextWrite(Context.of(coroutineContext[MDCContext.Key]?.contextMap ?: emptyMap()))
    when calling WebFilter base
    chain
    Although this is not working and I suspect that is due to passing the coroutine context to the ReactorContext somehow I’m not doing it right
    r
    • 2
    • 3
  • a

    André Martins

    05/03/2022, 6:30 PM
    Hey how can I get reactor context when using suspend like controller handlers?
    • 1
    • 1
  • e

    efemoney

    05/11/2022, 3:49 PM
    😞 https://github.com/spring-projects/spring-framework/issues/27345 Just bumping visibility of this isssue
    s
    e
    • 3
    • 8
  • o

    Okan Yıldırım

    05/17/2022, 10:50 AM
    Hello friends, may anybody help me about custom Query using JpaRepository ? I do use this query:
    @Query("select id, email from User")
    fun getAllIdsAndEmails(): List<Pair<Long, String>>
    But sadly I get an error of
    No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [kotlin.Pair<?, ?>]
    g
    p
    • 3
    • 11
  • s

    SecretX

    05/20/2022, 3:43 AM
    Does Spring Data has any native support for
    suspend
    functions inside interfaces (like
    ReactiveMongoRepository
    or something similar, but for coroutines)?
    i
    • 2
    • 1
  • s

    Slackbot

    06/05/2022, 11:31 PM
    This message was deleted.
    :not-kotlin: 2
    t
    d
    • 3
    • 3
  • m

    mp

    06/09/2022, 8:02 PM
    hi there does any one configure logback with kotlin instead of groovy/xml?
    👀 1
    a
    • 2
    • 5
Powered by Linen
Title
m

mp

06/09/2022, 8:02 PM
hi there does any one configure logback with kotlin instead of groovy/xml?
👀 1
a

Adrian Stypiński

06/10/2022, 2:38 PM
Not me, but I'm interested now too 😅
m

mp

06/10/2022, 2:39 PM
I have a plan to dive in to this evening and considering at the moment what alcohol should I pick 😂
😂 1
a

Adrian Stypiński

06/10/2022, 2:40 PM
It can't be that bad/hard 😅
m

mp

06/10/2022, 2:41 PM
Actually I want to use xml - but then saw documentation where logback team says that they haven’t xsd dtd scheema for it thats why I’m expecting from this process to be tricky. more or less
waiting for 1.3 with xml for now =( If u will create your instance of
ch.qos.logback.classic.spi.Configurator
logback wont be able to find it by interface with Service loader =( https://stackoverflow.com/a/72498725
😢 1
View count: 63