Commit a8622533 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Remove custom ImplementationNotAccessibleException.

Implements #22476.
parent cad14ead
# 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
......
......@@ -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;
......
/* 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);
}
}
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment