[Minor] Catch trying to instantiate abstract policies

This commit is contained in:
Robert von Burg 2020-09-03 15:48:00 +02:00
parent 9b9178a87b
commit d91c630208
1 changed files with 6 additions and 4 deletions

View File

@ -103,11 +103,13 @@ public class DefaultPolicyHandler extends StrolchComponent implements PolicyHand
DBC.PRE.assertNotNull("tx must not be null!", tx);
try {
Class<T> clazz;
if (defaultDef != null && !isPolicyDefAvailable(policyDef))
clazz = defaultDef.accept(this);
else
clazz = policyDef.accept(this);
policyDef = defaultDef;
Class<T> clazz = policyDef.accept(this);
if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers()))
throw new IllegalArgumentException(
"Class " + clazz.getName() + " can not be instantiated as it is not a concrete class!");
@SuppressWarnings("unchecked")
Constructor<T> constructor = (Constructor<T>) getConstructorForPolicy(clazz);