Hotfixing Java frameworks

I’m currently working on a web application that uses the Apache Wicket web framework. While implementing a new feature related to file uploads, I stumbled about a problem that turned out to be a known issue.

The bug was already fixed in Wicket’s trunk, though not yet released. The scheduled version for the release is 1.4RC2, which doesn’t help either, as I’m still working with Wicket 1.3.5 (the current stable release).

I had to somehow fix this, and I’d like to present how I got it working until we can update to 1.4: The ticket also included a patch to MockHttpServletRequest, and I needed exactly that patch. The getInputStream method isn’t final, but I couldn’t just subclass, as the code instantiating MockHttpServletRequest is quite involved. So instead, I copied the class into my project, applying the patch there. The Java classloader loads my modified version instead of the one provided by Wicket’s jar file, and the issue is resolved.

-Jörn