Topic archive
Java
Java tutorials, examples, and performance tips.
-
JSON to Java, Kotlin and TypeScript in the Browser: What JSON2Class Infers and Where It Stops
A walk through the type inference behind JSON2Class, a browser-only JSON to class generator I build and maintain: the Java, Kotlin and TypeScript it emits for one order payload, the annotation directives you can write inside the JSON, how array element types widen across every element, and the limits that remain before you paste production…
-
Async Logging with the LMAX Disruptor in Java: What Blocks, What Drops, and What You Lose
A tested Disruptor 4.0.0 async logger: why ringBuffer.next() blocks when the buffer is full, how tryNext() drops, two ways to lose log lines silently, and a benchmark with stated boundaries.

-
Java Virtual Threads on JDK 21: What 2,000 Connections, One Carrier Thread, and a synchronized Block Actually Do
A measured look at virtual threads on JDK 21.0.3: an echo server under 2,000 concurrent connections, the synchronized pinning stall reproduced with one carrier, where the 10x win is, and the case where virtual threads were slower.

-
Idempotency Keys in a Spring Boot REST API: Atomic Claims, Request Fingerprints, and 20 Concurrent Duplicates
A Spring Boot 3.5.16 payment endpoint with Idempotency-Key handling in Redis, tested with 20 simultaneous duplicates (one row, 1 x 201, 19 x 409), and the two ways the usual SETNX-lock recipe fails: a failed first attempt locks the key for a day, and the template it injects does not exist.

-
Cache-Aside with Caffeine: Which Read Path Prevents a Stampede, and What Expiry, Refresh, and Stats Really Do
Tested on Caffeine 3.2.4 and Java 17: the getIfPresent/put helper let 32 of 32 concurrent misses hit the database, cache.get(key, fn) let one through, and the published async example did not compile.

-
Envoy as a Sidecar for a Java Service: A Configuration That Loads, and What Retries, Timeouts, Outlier Ejection and Circuit Breakers Actually Do
The earlier envoy.yaml is rejected by Envoy 1.23 and 1.39.1 alike and its docker command cannot reach a service on the host. This version runs Envoy 1.39.1 in front of a plain Java HTTP server and reads retries, a 1 s route timeout, consecutive-5xx ejection, the panic threshold and a 1-connection circuit breaker off the…

-
Implementing Production-Grade Java Application Configuration Reloading without Downtime
Learn how to implement dynamic, zero-downtime configuration reloading in Spring Boot 3 applications using Spring Cloud Config and Actuator with secure, validated refresh workflows and operational best practices.

-
Leveraging Java JMH for Microbenchmarking Performance Critical Code
A comprehensive guide to using Java JMH for precise microbenchmarking of performance-critical Java code.
