
Thoughts after JCrete unconference
I don’t always write conference reviews. But when I do, they are about awesome ones. And JCrete was truly awesome. I got invited by Heinz Kabutz himself and this is pretty much the only way to get ...

I don’t always write conference reviews. But when I do, they are about awesome ones. And JCrete was truly awesome. I got invited by Heinz Kabutz himself and this is pretty much the only way to get ...

“Reactive Programming with RxJava: Creating Asynchronous, Event-Based Applications” book was finally published on paper. More than a year of hard work resulted in almost 350 pages packed with RxJav...
In part 1: thread pools we designed and implemented relatively simple system for processing events in real time. Make sure you read previous part as it contains some classes that we’ll reuse. Just ...
Once again I prepared a programming contest on GeeCON 2016 for my company. This time the assignment required designing and optionally implementing a system given the following requirements: A sy...
Properly handling dates, time, time zones, daylight saving time, leap years and such has been my pet peeve for a long time. This article is not a comprehensive guide to time domain, see Date and ti...
This article was initially an appendix in our Reactive Programming with RxJava book. However introduction to monads, albeit very much related to reactive programming, didn’t suit very well. So I de...
CompletableFuture is still a relatively fresh concept, despite being introduced almost two years ago (!) in March 2014 with Java 8. But maybe it’s good that this class is not so well known since it...
During this year’s GeeCON and GeeCON Prague my company 4FinanceIT was giving away some gifts for people who correctly answered a couple of programming questions. Quite a few people asked about corr...
Spock framework has multiple built-in extensions that support many core features like @Ignore and @Timeout annotations. But more importantly developers are encouraged to write their own extensions....
When you restart your enterprise application, what do your clients see when they open the web browser? They see nothing, server doesn’t respond yet so web browser displays ERR_CONNECTION_REFUSE...
Quoting Dependency Injection Demystified: “Dependency Injection” is a 25-dollar term for a 5-cent concept. *James Shore, 22 Mar, 2006 Dependency injection, as much as it is important when wr...
Spring framework 4.2 GA is almost released, let’s look at some new features it provides. The one that got my attention is a simple new class SseEmitter - an abstraction over sever-sent events easil...

Few weeks ago I attended GOTO Amsterdam conference. Beautiful venue, great food but most importantly, couple of interesting talks that caught my attention. Out of two days and five to six tracks I ...
I don’t like RESTful principles and APIs. In recent years it is seen as universal protocol for inter-process communication, especially in distributed systems. However I see many deficiencies of RES...
Classical producer-consumer pattern is relatively simple in Java since we have java.util.concurrent.BlockingQueue. To avoid busy waiting and error-prone manual locking we simply take advantage of p...

As far as HTTP is concerned, what client is downloading is just a bunch of bytes. However client would really like to know how to interpret these bytes. Is it an image? Or maybe a ZIP file? The las...
In the age of botnets that you can rent for few hundred bucks and run your very own distributed-denial-of-service attack, having emergency switches that selectively turn off expensive functionality...
HEAD is an often forgotten HTTP method (verb) that behaves just like GET, but does not return body. You use HEAD in order to check the existence of a resource (it should return 404 in case of absen...
We will explore more HTTP request and response headers this time to improve download server implementation: Content-length and Range. The former signals how big the download is, the latter allows d...
Caching on the client side is one of the foundations of World Wide Web. Server should inform client about validity of resources and client should cache them as eagerly as possible. Without caching ...
Downloading various files (either text or binary) is a bread and butter of every enterprise application. PDF documents, attachments, media, executables, CSV, very large files, etc. Almost every app...
Two classes new in Java 8 deserve some attention: LongAccumulator and DoubleAccumulator. They are designed to accumulate (more on what does that mean later) values across threads safely while being...

Courtesy of my company, 4Finance IT, I attended Spring I/O Barcelona this year. 2 days full of Spring, Groovy, Grails and Cloud, as the conference advertises itself, is not an exaggeration. And alt...
If you use Spring framework for more than a week you are probably aware of this feature. Suppose you have more than one bean implementing a given interface. Trying to autowire just one bean of such...

TL;DR: I did a computer simulation of behavior evolution of monkeys, continue reading to see how problem was stated originally in The Selfish Gene. First part shows my Java implementation, second p...
I wrote a lot about InterruptedException and interrupting threads already. In short if you call Future.cancel() not inly given Future will terminate pending get(), but also it will try to interrupt...
Idempotency in HTTP means that the same request can be performed multiple times with the same effect as if it was executed just once. If you replace current state of some resource with new one, no ...
Retry-After is a lesser known HTTP response header. Let me quote relevant part of RFC 2616 (HTTP 1.1 spec): 14.37 Retry-After The Retry-After response-header field can be used with a 503 (Se...
One of the killer-features of Hystrix is a low-latency, data-intensive and beautiful dashboard: Even though it’s just a side-effect of what Hystrix is really doing (circuit breakers, thread pool...
One day I was rewriting poorly implemented multi-threaded code that was blocking at some point on Future.get(): public void serve() throws InterruptedException, ExecutionException, TimeoutExceptio...
At one project I was setting up Hazelcast cluster in a private cloud. Within cluster all nodes must see each other, so during bootstrapping Hazelcast will try to locate other cluster members. There...
This article will touch upon multiple subjects: reactive programming, HTTP, parsing JSON and integrating with social API. All in one use case: we will load and process new meetup.com events in real...
In previous article “Batching (collapsing) requests in Hystrix” we looked at collapsing API in Hystrix. Check it out before proceeding with this article. Example presented there was rather artifici...
CompletableFuture<T> from Java 8 is an advanced abstraction over a promise that value of type T will be available in the future. Observable<T> is quite similar, but it promises arbitrar...
ExecutorService abstraction has been around since Java 5. We are talking about 2004 here. Just a quick reminder: both Java 5 and 6 are no longer supported, Java 7 won’t be in half a year. The reaso...
Hystrix has an advanced feature of collapsing (or batching) requests. If two or more commands run similar request at the same time, Hystrix can combine them together, run one batched request and di...

Java Performance: The Definitive Guide is the best Java book I read this year. In about 400 pages Scott Oaks touches every aspect of Java-based applications, from core terminology and methodologies...
One of the core data structures provided by Hazelcast is IMap<K, V> extending java.util.concurrent.ConcurrentMap - which is basically a distributed map, often used as cache. You can configure...
In the previous article we examined how Spock can be used to implement property-based testing. One of the “hello, world” examples of property-based testing is making sure absolute value of arbitrar...
Property based testing is an alternative approach to testing, complementing example based testing. The latter is what we’ve been doing all our lives: exercising production code against “examples” -...
Apparently writing a URL shortener service is the new “Hello, world!” in the IoT/microservice/era world. It all started with A URL shortener service in 45 lines of Scala - neat piece of Scala, flav...
When writing unit tests we mostly focus on business correctness. We do our best to exercise happy path and all edge cases. We sometimes microbenchmark and measure throughput. But one aspect that is...
For some reason I needed extremely large, possibly even infinite InputStream that would simply return the same byte[] over and over. This way I could produce insanely big stream of data by repeatin...
Continuing first article, this time we will write some more useful custom collectors: for grouping by given criteria, sampling input, batching and sliding over with fixed size window. Grouping (co...
Java 8 introduced the concept of collectors. Most of the time we barely use factory methods from Collectors class, e.g. collect(toList()), toSet() or maybe something more fancy like counting() or g...
When I was learning programming, back in the days of Turbo Pascal, I managed to list files in directory using FindFirst, FindNext and FindClose functions. First I came up with a procedure printing ...

A Clojure for Machine Learning, together with Clojure Data Analysis Cookbook, are two compelling books for people interested in data mining and reasoning. It is also worth mentioning that the amoun...
We had a lengthy discussion recently during code review whether scala.Option.fold() is idiomatic and clever or maybe unreadable and tricky? Let’s first describe what the problem is. Option.fold doe...
My colleagues are developing a trading system that processes quite heavy stream of incoming transactions. Each transaction covers one Instrument (think bond or stock) and has some (now) unimportant...
If InterruptedException wasn’t a checked exception, probably no one wouldn’t even notice it - which would actually prevent couple of bugs throughout these years. But since it has to be handled, man...