A Common Mistake Developers Make When Caching Nullable Values

Caching is hard in various ways. Whenever you're caching things, you have to at least think of: Memory consumption Invalidation In this article, I want to show a flaw that often sneaks into custom cache implementations, making them inefficient for some execution paths. I've encountered this flaw in Eclipse, recently. What did Eclipse do wrong? … Continue reading A Common Mistake Developers Make When Caching Nullable Values

Avoid Recursion in ConcurrentHashMap.computeIfAbsent()

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()

Infinite Loops. Or: Anything that Can Possibly Go Wrong, Does.

A wise man once said: Anything that can possibly go wrong, does -- Murphy Some programmers are wise men, thus a wise programmer once said: A good programmer is someone who looks both ways before crossing a one-way street. -- Doug Linder In a perfect world, things work as expected and you may think that … Continue reading Infinite Loops. Or: Anything that Can Possibly Go Wrong, Does.

MySQL Bad Idea #573

This is MySQL's Bad Idea #573 (after #384, which I've blogged about before) I've just had a terrible experience with a bug report from the jOOQ User Group, related to escaping of backslashes in string literals in MySQL. First, I thought to myself, whatever. SQL doesn't escape backslashes. The only escape character within a string … Continue reading MySQL Bad Idea #573