Doing GUI testing on a headless Ubuntu server
Recently at Jintec, the company I work for, we leased a server for our Java development.
As good developers, we have a Hudson running on that server, guarding the stability of our code (and our sanity). As I'm currently doing a rich client GUI project, doing GUI tests on my workstation isn't a problem, doing them on the server is, as this server doesn't have a graphical interface.
Look out: WeakHashMap
Reading the Javadocs is something people don't do very often. Programming has been a trial and error profession (which profession isn't?) and although test driven development has mitigated most of the error-part, creating bugs due to those little nuances in Javadocs which one might skip easily happens all to often.
As was the case today. We just got a bugreport for a OutOfMemoryError, which got traced back to a WeakHashMap that wasn't discarding its values on garbage collection. How could that be, one might ask? It's the reason of existing for a WeakHashMap: avoiding out of memory errors.
Don’t forget about C3P0
Using Hibernate is a breeze. You can find numerous tutorials, blog entries and a extensive manual on the net. However, that last item is something people only tend to look at when things go awry and you don't have a clue why. As I had with a MySQL problem recently.
It's a little known fact that the JDBC driver MySQL provides drops connections after being idle for 8 hours. Granted, it can be solved easily by providing a simple parameter on the JDBC url to reconnect when this happens, but it's often overlooked (and not really recommended, as it doesn't really promote safe programming). Another thing easily overlooked is the default pool Hibernate uses for its connections. This pool is, as the manual clearly warns, very basic and doesn't do any clean-up when it comes to idle connections. The result is, after 8 hours of inactivity, your Hibernate application will grind to a halt and only a restart will fix the problem.