目前我正在使用库,它可以抛出很多不同的异常(每个方法调用8-10个),并且大多数必须处理,更糟的是每个方法(在任何时候)都可以抛出AuthenticationExpiredException
,我必须重新尝试进行身份验证.例如:
try {
xStream = xSet.createXStream(id, binding, mimeType); //Method call
} catch (AuthenticationExpiredException authenticationExpiredException) {
try {
this.authenticate(); // re-authenticate
xStream = xSet.createXStream(id, binding, mimeType); //Method call again
} catch (XAMException xamException) {
throw new ConnectorException(
"Error occurred during creating new Blob after attempting to re-authenticate",
xamException);
}
} catch (XSystemCorruptException xSystemCorruptException) {
this.entities.clear();
this.closeConnection();
throw new ConnectorException("XSystem was corrupt and connection was closed",
xSystemCorruptException);
} catch (XSetCorruptException xSetCorruptException) {
this.closeEntity(entity);
throw new ConnectorException("XSet for entity: " + …
Run Code Online (Sandbox Code Playgroud) 我在使用多线程环境中的Image IO帮助读取Java图像时遇到问题.只有多个线程尝试读取图像时才会出现问题.
症状从错误的配置文件加载到异常有所不同:
java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles
Run Code Online (Sandbox Code Playgroud)
无论我如何阅读图像,通过ImageIO.read或使用ImageReader.
源数据(图像)完全隔离且不可变.
此问题可能与以下内容有关:https: //bugs.openjdk.java.net/browse/JDK-8041429和 https://bugs.openjdk.java.net/browse/JDK-8032243
问题是有没有其他方法可以使用具有多个线程的ImageIO读取JPEG文件.看起来ImageIO中存在问题,共享我无法控制的图像颜色配置文件的可变状态.我看到的唯一解决方案是在JVM级别完全隔离它,这听起来不错.
我使用的是Oracle JDK 8u25.更改JDK更新版本对问题没有影响(不是主要版本),我不能在不重写大块代码的情况下使用JDK 7.
代码供参考.
ImageInputStream input = new MemoryCacheImageInputStream(inputStream);
Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
if (!readers.hasNext()) {
throw new IllegalArgumentException("No reader for: " + dataUuid.toString());
}
ImageReader reader = readers.next();
try {
reader.setInput(input);
BufferedImage image = reader.read(0, reader.getDefaultReadParam());
Run Code Online (Sandbox Code Playgroud)