Super-sweet. Java 1.4.2 apparently has some kind of awesome bug in its MemoryCacheImageStream. Let's work around that by falling back to the Image IO reading that's gonna bork in sandbox land. Guess anything in a sandbox is gonna require Java 1.5 unless we find a different way around this.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@376 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2007-12-13 00:48:34 +00:00
parent 807165e6fc
commit a06eddcd95
@@ -44,6 +44,7 @@ import java.util.StringTokenizer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.imageio.IIOException;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
@@ -743,22 +744,29 @@ public class ResourceManager
image = ImageIO.read(iis);
} else {
// if we don't already have an image input stream, create a memory cache image input
// stream to avoid causing freakout if we're used in a sandbox because ImageIO
// otherwise use FileCacheImageInputStream which tries to create a temp file
MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(iis);
image = ImageIO.read(mciis);
try {
// this doesn't close the underlying stream
mciis.close();
} catch (IOException ioe) {
// ImageInputStreamImpl.close() throws an IOException if it's already closed;
// there's no way to find out if it's already closed or not, so we have to check
// the exception message to determine if this is actually warning worthy
if (!"closed".equals(ioe.getMessage())) {
Log.warning("Failure closing image input '" + iis + "'.");
Log.logStackTrace(ioe);
// if we don't already have an image input stream, create a memory cache image input
// stream to avoid causing freakout if we're used in a sandbox because ImageIO
// otherwise use FileCacheImageInputStream which tries to create a temp file
MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(iis);
image = ImageIO.read(mciis);
try {
// this doesn't close the underlying stream
mciis.close();
} catch (IOException ioe) {
// ImageInputStreamImpl.close() throws an IOException if it's already closed;
// there's no way to find out if it's already closed or not, so we have to check
// the exception message to determine if this is actually warning worthy
if (!"closed".equals(ioe.getMessage())) {
Log.warning("Failure closing image input '" + iis + "'.");
Log.logStackTrace(ioe);
}
}
} catch (IIOException iioe) {
// Fall back to the old way of doing things.
// It would appear that Java 1.4.2 explodes trying to use the
// MemoryCacheImageInputStream to load its images.
image = ImageIO.read(iis);
}
}