Sometimes we give terrible advice. Like in that article about how to use Java 8 for a cached, functional approach to calculating fibonacci numbers. As Matthias, one of our readers, noticed in the comments, the proposed algorithm may just never halt. Consider the following program: public class Test { static Map<Integer, Integer> cache = new … Continue reading Avoid Recursion in ConcurrentHashMap.computeIfAbsent()
Tag: Recursion
Top 10 Easy Performance Optimisations in Java
There has been a lot of hype about the buzzword "web scale", and people are going through lengths of reorganising their application architecture to get their systems to "scale". But what is scaling, and how can we make sure that we can scale? Different aspects of scaling The hype mentioned above is mostly about scaling … Continue reading Top 10 Easy Performance Optimisations in Java
Inadvertent Recursion Protection with Java ThreadLocals
Now here's a little trick for those of you hacking around with third-party tools, trying to extend them without fully understanding them (yet!). Assume the following situation: You want to extend a library that exposes a hierarchical data model (let's assume you want to extend Apache Jackrabbit) That library internally checks access rights before accessing … Continue reading Inadvertent Recursion Protection with Java ThreadLocals