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:
@@ -44,6 +44,7 @@ import java.util.StringTokenizer;
|
|||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
|
import javax.imageio.IIOException;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import javax.imageio.stream.MemoryCacheImageInputStream;
|
import javax.imageio.stream.MemoryCacheImageInputStream;
|
||||||
@@ -743,22 +744,29 @@ public class ResourceManager
|
|||||||
image = ImageIO.read(iis);
|
image = ImageIO.read(iis);
|
||||||
|
|
||||||
} else {
|
} 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 {
|
try {
|
||||||
// this doesn't close the underlying stream
|
// if we don't already have an image input stream, create a memory cache image input
|
||||||
mciis.close();
|
// stream to avoid causing freakout if we're used in a sandbox because ImageIO
|
||||||
} catch (IOException ioe) {
|
// otherwise use FileCacheImageInputStream which tries to create a temp file
|
||||||
// ImageInputStreamImpl.close() throws an IOException if it's already closed;
|
MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(iis);
|
||||||
// there's no way to find out if it's already closed or not, so we have to check
|
image = ImageIO.read(mciis);
|
||||||
// the exception message to determine if this is actually warning worthy
|
try {
|
||||||
if (!"closed".equals(ioe.getMessage())) {
|
// this doesn't close the underlying stream
|
||||||
Log.warning("Failure closing image input '" + iis + "'.");
|
mciis.close();
|
||||||
Log.logStackTrace(ioe);
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user