Thursday, June 24, 2010

java urlconnection difference between jdk 1.4 vs 1.5

Recently, I ran in to an issue when trying to do some maintenance on an application that was last compiled using java 1.4 compiler.  After compiling with java 1.5 or 1.6 compiler, the application stopped working.  The part that was failing was when the application is making a URLConnection and posting a bytestream to the URL.  It appears that from the client's perspective it wrote the entire bytestream.  However, when the server is attempting to read the bytestream, it would get a EndOfFile exception.   After scratching my head for a day, I noticed that one of my colleague had the same application working on his machine.  The only difference is the URL he is using has a backslash at the end and mine did not.  I tried changing the url by adding a backslash at the end, and the application starts working.


I have not seen any official documentation regarding this difference in the behavior between the same code compiled by jdk 1.4 and the newer ones.  But, it seem to be the case as few others also experienced similar issue.

I will update this blog entry if I ever find more details on this issue.  Meanwhile, if you run in to this issue, you may want to try adding a backslash to the end of your url.

No comments: