Friday, May 25, 2007

Visiting New York

I spent the last few days in New Jersey preparing a pretty cool presales demo. The on-site schedule ended yesterday, and I decided to take today off to spend some quality time in New York. It's my fourth time in the city, but I still feel amazed by the overwhelming sense of life around here.

It seems I couldn't have picked a better day to stay here, the weather is just perfect and people are getting ready for the long Memorial Day weekend. Even the navy is visiting the city for the Fleet Week.

I left the hotel just south of the Central Park this morning for a day of sightseeing. I walked down the East River and stopped for a while to admire the old ships at the South Street Seaport. Then I continued to Battery Park at the south end of Manhattan, from where I took a boat trip to see the Ellis Island and the Statue of Liberty. After the trip I had a light lunch before heading up by the Hudson River all the way to Pier 90, where the warship USS WASP was open for visitors. Then an early dinner at a nice Italian place and a return to the hotel.

My feet are killing me, but the tour was definitely worth it. (I have over 300 pictures and about 20 minutes of video to process...) Too bad I'll be leaving the city already tomorrow. Next time I'll bring my girlfriend along and we'll spend a whole week here.

I guess I won't go clubhopping tonight with these feet...

Thursday, May 17, 2007

The cause of an IOException

I just had to follow a stack trace through a complex codebase with multiple layers. The exception chaining mechanism introduced in Java 1.4 made the task easy up to the point where the last exception in the chain was an IOException thrown by code like this:

try {
....
} catch (Exception e) {
throw new IOException("...");
}


What a dead end! The problem is that the IOException constructors that allow exception chaining were only added in Java 6. Here's a workaround that would have saved me a lot of extra effort:

try {
....
} catch (Exception e) {
IOException ioe = new IOException("...");
ioe.initCause(e);
throw ioe;
}