I get it. Every innovation requires a rewrite by a newer (and typically younger) generation. Containers, Blockchain, Crypto, WASM - they all could have been built on the existing tech (and, well, TLDs). Yet hipsters gonna hip! But every now and then something truly bizarre happens. To me, that’s MCP. MC who? Model Context Protocol (MCP) is a “standard” (gone are the days of…
Rootless Docker is one of the most exciting recent changes in the Docker ecosystem. It allows you to run the same good old Docker but without having to obtain root privileges on the machine. Installing Rootless Docker on a fresh VM Although you can run Rootless Docker-in-Docker, I wanted to try it on a fresh environment. A few seconds later, I had an Ubuntu VM running on Oracle Cloud to play with:
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. One of the unique features of Project Reactor is the Context support. It allows you to associate an immutable context (represented by key/value pairs) and pass it to the upstream subscribers: public Flux<Item> getItems() { return…
Introduction Recently, I started playing with Kubernetes and Knative. The trigger was the credits I received to play with Oracle Cloud. I did not know how to use them and on which services (Java is the only Oracle’s product I use :D), so I googled “oracle cloud kubernetes” and 15 minutes later I had a running cluster to play with. Nice! After installing Knative (k apply -f FTW!)…
When you develop a library that provides some abstraction, or write a spec, it is a good practice to include a TCK (Technology Compatibility Kit) that the implementers can use to verify the behavior of their implementation and how well it matches the spec. You may find various TCKs out there, e.g. the Reactive Streams TCK. I just need something to test Let’s start with a simple example…
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. ThreadLocals is one of the most common pain points topics nobody wants to talk about in the reactive world. Unlike in synchronous programming, asynchronous programming makes them hard to use due to a lot of context switching and thread pooling.…
Testcontainers is a very helpful library when it comes to integration testing. One of the main benefits of it is that you can code your “dependencies” (like databases, brokers, cloud mocks, and other I/O sources) and start them with Docker from your tests - no need to run any additional command like docker-compose up or anything! But sometimes it is still useful to start your…
Spring Boot 2.3.0.M1 comes with a number of great features. I find one of them especially interesting - now you can build layered Docker images using Cloud Native Buildpacks! It is a very fast way of building Docker images compared to the Dockerfile approach thanks to Buildpacks. It is so fast that we can use it… to build, start and test our service as a Docker container (with…
I admit it - people are used to static ports. Web server? port 80! Redis? 6379! Java app? 8080! But let’s be honest, the following also looks painfully familiar: Bind for 0.0.0.0:80 failed: port is already allocated. But there is more - localhost is the king! There was some disturbance back in the days of docker-machine (magical 192.168.99.100, anyone? Heck, I even wrote a tool that…
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. In one of the previous Daily Reactive posts we talked about the polling. Today we will focus on an interesting example of the polling: Pagination. Example Let’s say we have the following API: interface Page extends Iterable<Item> {…
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. Although it is not common, sometimes there is a need to split a Flux into a few. And one has to be careful to do it correctly! Let’s say we have a stream of persons and we want to return a Tuple of names and ids:
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. Although streaming sources are very efficient with Reactive Streams, there are still many poll-based APIs. Kafka/Pulsar, REST, SQS/PubSub… You name it! Let’s say we have the following blocking legacy API provided by the database: //…
This post is a part of the “Daily Reactive” series of short posts about common situations with Project Reactor and Reactive Programming. Exceptions For Flow Contol? Throwing an error is a very easy way of terminating the processing. Consider the following example: public Mono<Void> sendRequest() { return doSendAndReceiveResponse() .doOnNext(buffer -> { throw new…
“Daily Reactive” is a series of posts about Reactive Programming and Project Reactor. The posts are inspired by some real world situations observed in Project Reactor’s Gitter, or from working with the community, or even from the bug reports :) Learn from others and avoid the most common pitfalls! ℹ️ You can subscribe to the “Daily Reactive” only by using this RSS…
Jackson is a great library for working with JSON. However, it is a bit too heavyweight to have it as a public dependency of your API. Especially if you’re working on an Open Source library. While refactoring docker-java, I got a challenge: There are two modules: api and core api module (unlike core) should not have any dependency core can be shaded, which means that we cannot use provided…
GraalVM’s native-image is great, but (at least at the time this post was published) it only supports Java 8. Since Java 8, we got new language features like var, switch expressions, Milling of Project Coin and others. But, if we want to use these features, Java compiler leaves no option other than producing Java 12+ bytecode, even tho they don’t need it and can be compiled to Java 8.
The world is not perfect, so are the tests, and one day you will get… a flaky test 😱 Flaky… what? As per Nebojša Stričević: An essential property of an automated test and the entire test suite is its determinism. This means that a test should always have the same result when the tested code doesn’t change. A test that fails randomly is commonly called a flaky test.
There is one super popular thing I never did/do in my Gradle projects: ext { lib_version = '1.2.3' } dependencies { compile 'org.corp:lib:$lib_version' } Why not? I know that this approach was/is popular among Maven projects. But I always preferred the dependencyManagement section of a parent POM because… it is standartized. When you switch between projects and want to change a version of…
Asynchronous and non-blocking programming in JVM can provide very impressive performance results. Unlike the more classical blocking model, it runs on just a few threads from a pool. But, to keep it performant, you must ensure that you are not blocking these threads. Just imagine having 4 threads in total, and blocking one of them for 100 milliseconds? But how do you “protect” your…
Most of my time I write Java code. It isn’t perfect, yet I find it good enough as my primary language. But sometimes I dream about the future of Java. Given the latest activities around the Java language design (See Project Amber), the future looks brighter JEP-by-JEP, but one feature I really miss which isn’t discussed by Amber is… Extension methods. The problem Java language…
One of the best things Docker gave us was the port randomization. You no longer have to care about possible conflicts, especially on CI environments. But it also created a big confusion for many users who got used to Redis listening on port 6379, or the Java debugger on 5005. Many tools are not container aware and expect things on static ports. Well, we can’t change the whole world (yet),…
The Builder pattern is one of the most popular patterns in Java. It is simple, helps to keep objects immutable, and can be generated with tools like Project Lombok’s @Builder or Immutables, to name a few. Example of a fluent variant of the pattern: public class User { private final String firstName; private final String lastName; User(String firstName, String lastName) { this.firstName =…
Year 2018 was an eye-opening year for me as an OSS project maintainer. The reason is due to the emerge of GitHub bots. Maintaining a project on GitHub could be a challenging task, especially when the project becomes popular. Issue management, releases, follow-ups, dependency management, oh my! But, as most of the developers, we’re lazy enough and spend time automating things. Dependabot…
Ever wanted to override a method of an object instance in Java? Let’s say you want to implement a custom Scheduler hook for Project Reactor. You start with Schedulers.addExecutorServiceDecorator, implement a BiFunction accepting Scheduler’s instance and ScheduledExecutorService and you need to return another ScheduledExecutorService instance where schedule* methods wrapped with your…
As a JVM guy, I got used to “write once, run everywhere” paradigm. But recently I got an interesting challenge to solve. I was working on a debugging tool for Project Reactor and part of it is implemented as a native library for Java, using JNI technology. I did some C++ in the past but never thought how hard is it, to cross-compile a library for 3 major platforms (Windows, Linux and…