Database Connection Leak and Connection Protector

Connection leakage. Too many open connections. Did you face it in some legacy code maybe? If yes, you probably know how hard is to find where is the leakage. Especially when you have some additional aspects in your code that "should" work, but there is no way to figure it out. Is there a way to monitor connection leakage? Is there a way to execute some code and cleanup connections if code is clunky?

It looks like we can use some hack here, that will work in any, especially legacy environment. We can use Mockit to inject our code into legacy connection pool. Gather all active connections and manage them.

We can also try to execute our code in special context where we can discover where is our nasty leakage.

Secured context execution can be used in tests, to execute "suspicous" code and see how many connections we have. We can also wrap each test case execution and assert open connections size. What do you think about this?


Deploy war on jetty in Jenkins or Hudson job

I don't want to say how many times I was writing combination of words: "Deploy jetty jenkins hudson job war" in Google search text field. I don't want to: use Cargo, use Jenkins/Hudson plugins, other automagick stuff that is working sometimes for specified conditions. My goal was to just deploy application war for testing purposes. if(Running) Done. I want this simple. I also want to deploy each application on separate port so I don't kill all applications when change code in one! Simple!

Build Environment :: Properties Content


Build :: Execute Shell

# cleanup workspace
rm -rf *
# download jetty
wget http://download.eclipse.org/jetty/$JETTY_VERSION/dist/jetty-distribution-$JETTY_VERSION.tar.gz
tar xfz jetty-distribution-$JETTY_VERSION.tar.gz
mv jetty-distribution-$JETTY_VERSION jetty
rm jetty-distribution-$JETTY_VERSION.tar.gz

Build :: Copy artifacts from another project

Project name: <jenkins build name where war artifact is stored>
Artifacts to copy: **/*.war
Target directory: jetty/webapps

Build :: Execute Shell

# kill jetty if running
pkill -9 -f jetty.port=$JETTY_PORT || true
sleep 5
cd jetty
start jetty & prevent jenkins killing job after finish
BUILD_ID=dontKillMe nohup java -jar start.jar jetty.port=$JETTY_PORT > ../jetty.log 2>&1 &


You know how to do this simpler? Drop a line.

Edit 1: As Łukasz pointed out, it's good idea to combine two last lines (prevent & run) into single one


Progressive disclosure

The great example how to present informations to users. Great idea for not overwhelming people, and get their attention.


Design like Apple

Many want to design like Apple. But how to do it? What is the design process involved? See One Minute MBA's five rules in an awsome short. The video below: