Alright, I have a problem that is driving me crazy!
I have a web application deployed on Weblogic 12.1.1 -i.e.:Weblogic 12c
At some point, I want to read an image File using:
BufferedImage templateImage = ImageIO.read(new URL(url));
The previous line fails on some images with the following so-stupid message:
For input string: ""
Some advised that I change the HTTP handler for Weblogic using the the following parameter:
-DUseSunHttpHandler=true
and it solved the problem yet I can't implement this solution as it will be very risky.
What made me more crazy is that when I modify the picture using "Paint", adding/removing some dummy colors and/or shapes, it passed!!
(Although not all changes will make it pass).
This is my first question here and I'd really appreciate your help.
P.S.: Problem appears only on "Weblogic 12c", not 11g or anything else.
Edit: below is the Stack Trace:
java.io.IOException: For input string: ""
at weblogic.utils.http.HttpChunkInputStream.initChunk(HttpChunkInputStre
am.java:69)
at weblogic.utils.http.HttpChunkInputStream.skip(HttpChunkInputStream.ja
va:215)
at weblogic.utils.http.HttpChunkInputStream.skipAllChunk(HttpChunkInputS
tream.java:395)
at weblogic.utils.http.HttpChunkInputStream.close(HttpChunkInputStream.j
ava:291)
at weblogic.net.http.KeepAliveStream.close(KeepAliveStream.java:122)
at javax.imageio.ImageIO.read(ImageIO.java:1405)
As I'm almost sure now it's a WebLogic Bug, I rewrote the code to be like:
URL url = new URL("url")
File file = new File("New File Path");
InputStream inputStream = url.openStream();
OutputStream outputStream = new FileOutputStream(file);
try {
IOUtils.copy(inputStream, outputStream);
} finally {
outputStream.close();
inputStream.close();
}
BufferedImage actualImage = ImageIO.read(file);
The key difference in the new code is that it passes the read() method a [File] instance instead of a [URL] instance.