From da89ecd02a9ce2bccf425bff57663c44fb78fb7d Mon Sep 17 00:00:00 2001 From: CoreRasurae <luis.p.mendes@gmail.com> Date: Fri, 27 Apr 2018 23:26:05 +0100 Subject: [PATCH] Fix: Exception handling in OpenCLDevice.configure() --- pom.xml | 2 +- src/main/java/com/aparapi/device/OpenCLDevice.java | 11 +---------- .../aparapi/runtime/OpenCLDeviceConfiguratorTest.java | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 95996ceb..193d91b0 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ <dependency> <groupId>com.aparapi</groupId> <artifactId>aparapi-jni</artifactId> - <version>1.4.0</version> + <version>1.4.1-SNAPSHOT</version> </dependency> <dependency> <groupId>junit</groupId> diff --git a/src/main/java/com/aparapi/device/OpenCLDevice.java b/src/main/java/com/aparapi/device/OpenCLDevice.java index c962ba8f..2eabd970 100644 --- a/src/main/java/com/aparapi/device/OpenCLDevice.java +++ b/src/main/java/com/aparapi/device/OpenCLDevice.java @@ -141,15 +141,6 @@ public class OpenCLDevice extends Device implements Comparable<Device> { this.name = name; } - private static void configuratorWrapper(final IOpenCLDeviceConfigurator configurator, final OpenCLDevice device) { - try { - configurator.configure(device); - } catch (Throwable ex) { - logger.log(Level.WARNING, "Failed to configure device - Id: " + device.deviceId + - ", Name: " + device.getName(), ex); - } - } - /** * Called by the underlying Aparapi OpenCL platform, upon device * detection. @@ -158,7 +149,7 @@ public class OpenCLDevice extends Device implements Comparable<Device> { if (configurator != null && !underConfiguration.get() && underConfiguration.compareAndSet(false, true)) { try { - configuratorWrapper(configurator, this); + configurator.configure(this); } finally { underConfiguration.set(false); } diff --git a/src/test/java/com/aparapi/runtime/OpenCLDeviceConfiguratorTest.java b/src/test/java/com/aparapi/runtime/OpenCLDeviceConfiguratorTest.java index 78fd2c59..a474894a 100644 --- a/src/test/java/com/aparapi/runtime/OpenCLDeviceConfiguratorTest.java +++ b/src/test/java/com/aparapi/runtime/OpenCLDeviceConfiguratorTest.java @@ -222,8 +222,8 @@ public class OpenCLDeviceConfiguratorTest { assertEquals("Number of confgure() calls should be one", 1, callCounter.get()); } - @Test - public void noExceptionConfiguratorTest() { + @Test(expected=IllegalArgumentException.class) + public void exceptionConfiguratorTestFail() { final AtomicBoolean called = new AtomicBoolean(false); OpenCLDevice dev = new OpenCLDevice(null, 101L, Device.TYPE.CPU); IOpenCLDeviceConfigurator configurator = new IOpenCLDeviceConfigurator() { -- GitLab