Home » JVM Languages

JVM Languages

Simulating & troubleshooting StackOverflowError in Scala

In this series of simulating and troubleshooting performance problems in Scala, let’s discuss how to simulate StackOverflowError. StackOverflowError is a runtime error, which is thrown, when a thread’s stack size exceeds its allocated memory limit.  Sample Program Here is a sample Scala program, which generates the StackOverflowError: package com.yc class StackOverflowApp { } object StackOverflowApp { def main(args: Array[String]): Unit ...

Read More »

Simulating & troubleshooting BLOCKED threads in Kotlin

In this series of simulating and troubleshooting performance problems in Kotlin, let’s discuss how to make threads go into BLOCKED state. A thread will enter into a BLOCKED state when it couldn’t acquire a lock on an object because another thread already holds the lock on the same object and doesn’t release it. Kotlin blocked thread Program Here is a ...

Read More »

Simulating & troubleshooting CPU spike in Kotlin

In this series of simulating and troubleshooting performance problems in Kotlin articles, let’s discuss how to simulate CPU consumption to spike up to 100% on a host (or container). CPU consumption will spike up whenever a thread goes on an infinite loop. Kotlin CPU Spike Program Here is a sample kotlin program, which generates the cpu spike. package com.buggyapp class ...

Read More »

Service to Service call patterns in Google Cloud – GKE

This is a series of posts that will explore service to service call patterns in some of the application runtimes in Google Cloud. This specific post will explore GKE without using a service mesh and the next post will explore GKE with Anthos Service Mesh. Set Up The set-up is simple, two applications – caller and producer are hosted on ...

Read More »

Kotlin: Type conversion with adapters

In this post we will learn how we can use Kotlin extension functions to provide a simple and elegant type conversion mechanism. Maybe you have used Apache Sling before. In this case, you are probably familiar with Slings usage of adapters. We will implement a very similar approach in Kotlin. Creating an extension function With Kotlins extension functions we can ...

Read More »

Deriving a Kotlin “Try” type

Functional programming languages like Scala often have a type called “Try” to hold the result of a computation if successful or to capture an exception on failure.  This is an incredibly useful type, allowing a caller to pointedly control how to handle an exceptional scenario. In this post I will try and create such a type from scratch. As an example, ...

Read More »

Kotlin dependency injection with Koin

Dependency injection is a common technique in today’s software design. With dependency injection we pass dependencies to a component instead of creating it inside the component. This way we can separate construction and use of dependencies. In this post we will look at Koin, a lightweight Kotlin dependency injection library. Koin describes itself as a DSL, a light container and ...

Read More »