Embracing the Messiness in Search of Epic Solutions

Month: October 2013

  • Groovy: java.lang.StackOverflowError When Implementing equals()

    PROBLEM While migrating a portion of my Java code to Groovy code, I got bitten by the Groovy operator loading feature that I should have known better… and my pride hurts, but hey, I admit I write shitty code. Consider this simple POGO with custom equals() and hashCode(), both implemented using Google Guava libraries:- What… Read More…

  • Deleting Cached Web Page by URI in CodeIgniter

    PROBLEM CodeIgniter contains a wonderful feature that allows me to cache web pages to speed up the page loading. The problem is there’s no easy mechanism for me to delete specific cached web pages, especially after I have updated the page contents. I have sucky two choices:- I always do the latter even though I… Read More…

  • Rotating Log Files on Apache HTTP Server

    PROBLEM Consider the following log configuration:- At some point of time, both error.log and access.log are going to get insanely large. SOLUTION To fix this, the logs can be piped (by using |) to Apache HTTP Server’s built-in program called rotatelogs to rotate the log files. For example, the following configuration will create a daily… Read More…

  • Suppressing FindBugs Warnings

    PROBLEM FindBugs is one of the many great static code analysis tools that I use everyday. However, the generated report may usually contain a few false positives that forces me to weave through them whenever I rerun my build on Jenkins. For example, I’m using Google Guava to construct my equals(…) and hashCode():- FindBugs will… Read More…

  • How to Unit Test Spring MVC Controller

    SCENARIO Let’s assume we have the following controller that needs to be tested:- SOLUTION 1: “Works but It Won’t Get You the Promotion” This working solution relies on:- While this solution works, but it has a few problems. This test case strictly tests the actual controller API, but it completely disregards the URI and request… Read More…

  • Hibernate: Migrating from XML-Based Configuration to Annotation-Based Configuration

    Overview At some point of time, as your project scope grows, the Hibernate mapping XML files are going to get to a point where it becomes very difficult to maintain. This is where the annotation-based configuration comes in. It took me a few years to convince myself that annotation-based configuration is the way to go.… Read More…