commit a86225335e40f0178f489d2d4eb094efbf4c6025 Author: Karsten Loesing karsten.loesing@gmx.net Date: Thu Jun 22 14:34:44 2017 +0200
Remove custom ImplementationNotAccessibleException.
Implements #22476. --- CHANGELOG.md | 7 ++++++ .../descriptor/DescriptorSourceFactory.java | 6 ++--- .../ImplementationNotAccessibleException.java | 27 ---------------------- .../descriptor/DescriptorSourceFactoryTest.java | 4 ++-- 4 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 98728b1..fd39b96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Changes in version 2.0.0 - 2017-06-?? + + * Minor changes + - Replace custom ImplementationNotAccessibleException thrown by + DescriptorSourceFactory with generic RuntimeException. + + # Changes in version 1.9.0 - 2017-06-21
* Major changes diff --git a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java index 77d8740..7125ace 100644 --- a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java +++ b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java @@ -176,15 +176,15 @@ public final class DescriptorSourceFactory { clazzName = System.getProperty(type, COLLECTOR_DEFAULT); break; default: - throw new ImplementationNotAccessibleException("Cannot " - + "retrieve class for type " + type + "."); + throw new RuntimeException("Cannot retrieve class for type " + type + + "."); } object = ClassLoader.getSystemClassLoader().loadClass(clazzName) .newInstance(); log.info("Serving implementation {} for {}.", clazzName, type); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { - throw new ImplementationNotAccessibleException("Cannot load class " + throw new RuntimeException("Cannot load class " + clazzName + "for type " + type, ex); } return object; diff --git a/src/main/java/org/torproject/descriptor/ImplementationNotAccessibleException.java b/src/main/java/org/torproject/descriptor/ImplementationNotAccessibleException.java deleted file mode 100644 index a377276..0000000 --- a/src/main/java/org/torproject/descriptor/ImplementationNotAccessibleException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2014--2017 The Tor Project - * See LICENSE for licensing information */ - -package org.torproject.descriptor; - -/** - * Thrown if a descriptor source implementation class cannot be found, - * instantiated, or accessed. - * - * @see DescriptorSourceFactory - * @since 1.0.0 - */ -@SuppressWarnings("serial") -public class ImplementationNotAccessibleException - extends RuntimeException { - - public ImplementationNotAccessibleException(String message, - Throwable ex) { - super(message, ex); - } - - public ImplementationNotAccessibleException(String message) { - super(message); - } - -} - diff --git a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java index 8eee1ef..69d4193 100644 --- a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java +++ b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java @@ -54,7 +54,7 @@ public class DescriptorSourceFactoryTest { } }
- @Test(expected = ImplementationNotAccessibleException.class) + @Test(expected = RuntimeException.class) public void testException() { System.setProperty(COLLECTOR_PROPERTY , "no.implementation.available.X"); @@ -70,7 +70,7 @@ public class DescriptorSourceFactoryTest { retrieve.setAccessible(true); retrieve.invoke(null, "unknown.property"); } catch (InvocationTargetException ite) { - if (ite.getCause() instanceof ImplementationNotAccessibleException) { + if (ite.getCause() instanceof RuntimeException) { return; } else { fail("Cause was " + ite.getCause()
tor-commits@lists.torproject.org