https://kotlinlang.org logo
Docs
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
server
  • b

    Baidyanath

    09/13/2021, 12:58 PM
    Hi Guys, Is it possible to run another gradlew project from gradlew project- Usecase: I've one backend service using gradlew, and I need to run another gradlew project which will be pulled in CI/CD pipeline. If yes, please suggest the way?
    :not-kotlin: 4
    s
    • 2
    • 9
  • m

    Michael Ralston

    09/17/2021, 10:38 AM
    Hey... I'm writing some http endpoints that I want to return immediately and then do their work in the background. Can I use cooroutines for this or would threads be better?
    b
    e
    +4
    • 7
    • 9
  • r

    Rob Elliot

    09/17/2021, 5:03 PM
    Is there a nice Kotlin shim around `java.lang.Process`/`java.lang.ProcessBuilder` that has been packaged up into a library? Things I’d like: • Optionally captures stdout, stderr & exit status wrapped up as a data class as the return value • Allows piping the stdout of one subprocess as the stdin of another, and capture the final result I’m sort of looking for something like the syntax and ease of plugging other executables together that you get with bash or similar, but in Kotlin so it’s easier to actually write & test the business logic.
    l
    r
    k
    • 4
    • 6
  • t

    therealbluepandabear

    09/22/2021, 10:45 PM
    import kotlin.random.Random
    
    fun main(args: Array<String>) {
        val quizCreator = QuizCreator()
        quizCreator.makeQuiz()
    }
    
    class QuizCreator {
        private val quizInstance = Quiz("", listOf())
    
        fun makeQuiz() {
            println("Choose quiz name:")
    
            quizInstance.quizName = readLine().toString()
    
            while (true) {
                println("New Question? (Y/n)")
    
                if (readLine()?.lowercase() == "y") {
                    var question = Question(null, null)
    
                    println("Question name?")
    
                    question.questionText = readLine()
    
                    println("Question answer?")
    
                    question.questionAnswer = readLine()
    
                    quizInstance.questions.toMutableList().add(question)
    
                    println(quizInstance.questions[0])
                } else {
                    println("OK")
                    quizInstance.startQuiz()
                    break
                }
            }
        }
    
    }
    
    
    data class Quiz(var quizName: String, val questions: List<Question>) {
        fun startQuiz() {
            for (question in questions) {
                println(question.questionText)
    
                val answer = readLine()
    
                if (answer?.lowercase() != question.questionAnswer?.lowercase()) {
                    println("Incorrect, the answer was ${question.questionAnswer}")
                } else {
                    println("Correct")
                }
            }
        }
    }
    
    data class Question(var questionText: String?, var questionAnswer: String?)
    ok so I have this code, and for some reason when running this it's saying that the list of questions is empty:
    Choose quiz name:
    j
    New Question? (Y/n)
    y
    Question name?
    j
    Question answer?
    j
    Exception in thread "main" java.lang.IndexOutOfBoundsException: Empty list doesn't contain element at index 0.
    	at kotlin.collections.EmptyList.get(Collections.kt:36)
    	at kotlin.collections.EmptyList.get(Collections.kt:24)
    	at QuizCreator.makeQuiz(Main.kt:32)
    	at MainKt.main(Main.kt:5)
    
    Process finished with exit code 1
    e
    • 2
    • 1
  • j

    Justin (Midas) Gilman

    09/27/2021, 7:55 PM
    Does anyone here have any experience mocking an extension function and capturing the lambda parameter? I am using Mockk and I'm getting this error
    java.lang.AbstractMethodError: Receiver class kotlin.jvm.functions.Function1$Subclass0 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke(java.lang.Object)' of interface kotlin.jvm.functions.Function1.
    Here's my test:
    @Test
        fun `attempt 2`() {
            val routing = mockk<Routing>(relaxed = true)
    
            val configure = slot<Route.() -> Unit>()
            val mockedRoute = mockk<Route>()
    
            every { any<Route>().static(capture(configure)) } answers {
                configure.captured.invoke(mockedRoute)
                mockedRoute
            }
    
            var testObj = ResourcePortalModuleRouter(routing, node)
            testObj.attachPortalCoreRoutes()
    
            verify {
                mockedRoute.default("index")
            }
        }
    The error is thrown on the
    every
    line, and I don't understand why this isn't working
    t
    e
    j
    • 4
    • 4
  • t

    Tiago Nunes

    09/29/2021, 10:57 AM
    Hey everyone, I’m trying to make an
    AutoRefreshToken
    interceptor plugin in my Ktor client (
    HttpClient
    ), which is supposed to see if the response is a token time-out error, and if it is, generate a new token and resend the request. For getting the response, should I intercept the
    receivePipeline
    or the
    responsePipeline
    ?
    r
    • 2
    • 2
  • t

    Tiago Nunes

    09/29/2021, 1:57 PM
    Hey everyone, how can I copy an
    HttpRequest
    ? I want to send a new request in
    responsePipeline
    based on the previous request, with a small difference in the body
    🧵 1
    r
    • 2
    • 7
  • m

    Marcus Brito

    10/01/2021, 12:55 PM
    I wonder how many people out there are using (or interesting in using) Kotlin with the Akka/Lightbend platform
    h
    • 2
    • 17
  • f

    Franco

    10/01/2021, 11:10 PM
    Hey everyone, we have recently started working on developing Google Cloud Functions with Kotlin/JVM but we haven't found any examples on how to use coroutines in this environment. Has anyone worked on this or knows of any examples online we can look at? From what we found, seems like the calls to the cloud functions are blocking so we are using
    runBlocking
    to call suspend tunctions for now, but it doesn't sound right 🤔
    n
    e
    • 3
    • 13
  • b

    Berkay

    10/06/2021, 10:56 AM
    Hi there 🙋‍♂️, is there a way to proguard or using dex on ktor backend application?
    e
    • 2
    • 2
  • k

    Kartick Vijayakumar

    10/13/2021, 5:51 PM
    I'm from a startup in India called Hypto. We are investing in building some infrastructure and web-services in the fintech space and was exploring gRPC and Kotlin coroutine based server for our webservices. Managed to put together a basic starter for this - https://github.com/hwslabs/grpc-kotlin-starter At some point, we would need to generate clients across multiple programming languages. I'm thinking we should separate the proto files alone into an independent repo and include that as a dependency in the build process of various other repos (each of which is a different programming language). One of those could be the Kotlin server side impl and others would simply be the language-specific client impl. Any thoughts? Has someone tried something like this?
    m
    • 2
    • 7
  • j

    jasman arora

    10/14/2021, 11:04 AM
    Hello everyone, I'm trying to learn ktor for server side development so can anyone tell me some good blogs for this
    j
    a
    • 3
    • 5
  • m

    Marcus Widegren

    10/15/2021, 11:46 AM
    Has anyone noticed any differences in Json deserialization when upgrading to kotlin 1.5? We haven’t been able to confirm that it’s that exact change that did it, but it’s one of our guesses. We have some kotlin classes that have multiple @JvmStatic valueOf methods (that take different types), and one private constructor (that takes a long). Previously this was deserializing from json without any configuration. When we upgraded to kotlin 1.5 (from 1.4) and spring-boot 2.5 it stopped working specifically for the Kotlin classes (the java classes that are declared in an identical fashion as far as we can tell still work). We can get it to work by adding @JsonCreator to one of the valueOf methods, but we are a bit concerned that it’s going to be tricky to find all classes where the deserialization is broken.
    h
    • 2
    • 1
  • s

    spierce7

    10/17/2021, 9:55 PM
    What is the best kotlin server to use? I’m looking for good compile times, and good compatability / startup times for graalvm. I’ve been nervous to use some of the servers that rely on annotation processors due to compile times.
    b
    n
    +4
    • 7
    • 17
  • l

    Luiz Aguiar

    10/21/2021, 8:55 PM
    Hi there! Do you have any recommendations for "scheduling/background jobs" framework other than Quartz? Ideally more kotlin-friendly.
    b
    h
    c
    • 4
    • 6
  • c

    Charles Jo

    10/22/2021, 1:29 AM
    Hi! Is there any solution to build SSL websocket server with ktor in Android? Here I think Android is not main point. Main point is that how I can implement SSL websocket server with ktor. Thanks.
    r
    • 2
    • 2
  • t

    therealbluepandabear

    10/23/2021, 2:39 AM
    Everyone I'm creating a Pixel art editor for Android called PyxlMoose in Kotlin, come and contribute! https://github.com/realtomjoney/PyxlMoose
    b
    • 2
    • 2
  • e

    EmmaG

    10/24/2021, 5:31 PM
    Hello everyone, I've been able to build RESTAPI with Ktor, but now I'm planning on building a bill payment platform RESTAPI for mobile, thinking if I could still use Ktor for it
    h
    • 2
    • 22
  • c

    Carlos Rodriguez Bollain

    10/26/2021, 10:42 AM
    Hi guys, I am running into an error when trying to mock method calls that use inline classes as parameters using mockito. I have uploaded a very small proof of concept on my personal github so that you can see the issue. https://github.com/CarlosR-B/mockito_inline_classes
    d
    • 2
    • 1
  • d

    David Smith

    10/27/2021, 9:25 AM
    I’m struggling with micronaut trying to deserialize stuff that isn’t there
    n
    a
    • 3
    • 5
  • g

    Guilherme Gomes Correia

    10/29/2021, 9:37 PM
    Hey guys! Does anyone knows how to order big lists in Kotlin with great performance? Is it possible to use parallel stream? Basically, I have a list of almost 100k records and need to order based on two fields: ID (string) and Date(OffsetDateTime).
    p
    s
    r
    • 4
    • 3
  • c

    Chukwukammadu Anizoba

    11/03/2021, 6:40 AM
    Hey guys! Are there any examples on server-side rendering using Kotlin JS node with routing? I'm currently using this GitHub project for the server-side rendering bit: https://github.com/techprd/kotlin_node_js_seed. However, this approach is suitable if there is only 1 component in the project and no routing is involved. Cheers!
    h
    • 2
    • 1
  • k

    Khurram Malik

    11/03/2021, 1:26 PM
    Hey guys! I have a server application with standard KTOR configuration (generated with Ktor Project Generator). I wish to configure different build configurations. Here the primary interest is that i can add command line arguments for expose (dbName, password, etc), port, produktion checks, etc. I was not able to find any official documentation regarding that. Has any one accomplished that? Or know how i can do that
    a
    • 2
    • 1
  • l

    Luiz Aguiar

    11/03/2021, 10:16 PM
    Hello folks 👋 Is someone using Quarkus with :kotlin: for a while? I’d like to know about pain-points when comparing to Boot or Micronaut that seems to have better Kotlin support (and more love from the Kotlin community)
    r
    n
    • 3
    • 5
  • e

    Emil Kantis

    11/04/2021, 8:17 AM
    I don’t want to derail @Luiz Aguiar question above, but what makes Ktor a non-contender in these cases? 🙏 @nfrankel @Richard Gomez
    n
    d
    +3
    • 6
    • 12
  • i

    ipolyzos

    11/04/2021, 9:06 AM
    Please do a thumbs up if you’d like to see more of Kotlin around: 1. Functional event-driven microservices 2. Cloud-Native Event Stream Processing 3. Unified Batch and Streaming Pipelines 4. Edge IoT Analytics feel free to comment any thoughts - would love other people’s thoughts on where kotlin is headed in the data world [Kotlin, Arrow, Apache Flink, Apache Pulsar, Delta Lake for Lakehouses, Trino and Kubernetes]
    ✅ 1
    👍 43
    a
    • 2
    • 3
  • g

    Geert

    11/07/2021, 2:26 PM
    Is it possible to let kotlin (ktor) make a beeping sound on the terminal output? On MacOs I could just print:
    say "hello"
    but when I print this with kotlin it is not working, I also tried
    afplay /System/Library/Sounds/Ping.aiff
    which is working in terminal, but not when using println or logger.info()
    c
    p
    • 3
    • 3
  • e

    edrd

    11/08/2021, 4:04 PM
    message has been deleted
    👍 3
    h
    e
    • 3
    • 8
  • f

    Folger Fonseca

    11/09/2021, 11:13 AM
    Hello everyone, I've been working with Kotlin, spring boot and microservices on the server side for the last 3 years, I was wondering what do you think would be interesting to write about on a blog post if you could choose on a topic? Testing, deploying to AWS, building resiliency, bootstrapping an app end to end?
    h
    a
    • 3
    • 2
  • k

    Khurram Malik

    11/12/2021, 9:34 AM
    Hello everyone, i've been working on Kotlin server application for a while now and i am thinking of adding automated linting checks on future PRs. I've searched a bit on the internet what linting plugins are available for Kotlin. I could not find anything that is official Jetbrains developed. So the question is: 1. Are there any plans of developing an official linting library for Kotlin? 2. Are there any recommendations from Kotlin team what linting library developers should use?
    s
    e
    • 3
    • 4
Powered by Linen
Title
k

Khurram Malik

11/12/2021, 9:34 AM
Hello everyone, i've been working on Kotlin server application for a while now and i am thinking of adding automated linting checks on future PRs. I've searched a bit on the internet what linting plugins are available for Kotlin. I could not find anything that is official Jetbrains developed. So the question is: 1. Are there any plans of developing an official linting library for Kotlin? 2. Are there any recommendations from Kotlin team what linting library developers should use?
s

simon.vergauwen

11/12/2021, 9:38 AM
Detekt is a popular one, #detekt. Another one is KtLint, but it doesn’t really do a lot of automated linting checks more auto-formatting. For auto-formatting there is also KtFmt. All 3 can work nicely together. There is also support for Detekt to automatically make comments for code smells etc on Git platforms.
☝️ 1
🙌 1
e

edrd

11/12/2021, 12:04 PM
JetBrains recently announced Qodana: https://www.jetbrains.com/qodana/jvm/
➕ 1
✔️ 1
s

simon.vergauwen

11/12/2021, 12:07 PM
That works specifically for JVM, no? Or doesn’t it also offer help for Kotlin specific linting ?
k

Khurram Malik

11/12/2021, 1:49 PM
@edrd It is perfect for my use-case since i am developing on jvm.
🤘 1
View count: 11