You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2020/03/15 17:26:35 UTC

[logging-log4j2] 01/07: Use better exception type

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch mean-bean-machine
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 3a6fee33f05eca2af2cecea27a16579c31a914d7
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sat Mar 14 13:32:15 2020 -0500

    Use better exception type
    
    Signed-off-by: Matt Sicker <bo...@gmail.com>
---
 .../plugins/defaults/bean/DefaultInjectionTargetFactory.java      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInjectionTargetFactory.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInjectionTargetFactory.java
index d048a14..30c30ec 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInjectionTargetFactory.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInjectionTargetFactory.java
@@ -20,7 +20,7 @@ package org.apache.logging.log4j.plugins.defaults.bean;
 import org.apache.logging.log4j.plugins.api.Inject;
 import org.apache.logging.log4j.plugins.api.PostConstruct;
 import org.apache.logging.log4j.plugins.api.PreDestroy;
-import org.apache.logging.log4j.plugins.spi.InjectionException;
+import org.apache.logging.log4j.plugins.spi.DefinitionException;
 import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InjectionTarget;
 import org.apache.logging.log4j.plugins.spi.bean.InjectionTargetFactory;
@@ -85,7 +85,7 @@ class DefaultInjectionTargetFactory<T> implements InjectionTargetFactory<T> {
                 .filter(constructor -> constructor.isAnnotationPresent(Inject.class))
                 .collect(Collectors.toList());
         if (injectConstructors.size() > 1) {
-            throw new InjectionException("Found more than one constructor with @Inject for " + type);
+            throw new DefinitionException("Found more than one constructor with @Inject for " + type);
         }
         if (injectConstructors.size() == 1) {
             return injectConstructors.get(0);
@@ -94,7 +94,7 @@ class DefaultInjectionTargetFactory<T> implements InjectionTargetFactory<T> {
                 .filter(constructor -> constructor.getParameters().stream().anyMatch(elementManager::isInjectable))
                 .collect(Collectors.toList());
         if (injectParameterConstructors.size() > 1) {
-            throw new InjectionException("No @Inject constructors found and remaining constructors ambiguous for " + type);
+            throw new DefinitionException("No @Inject constructors found and remaining constructors ambiguous for " + type);
         }
         if (injectParameterConstructors.size() == 1) {
             return injectParameterConstructors.get(0);
@@ -106,6 +106,6 @@ class DefaultInjectionTargetFactory<T> implements InjectionTargetFactory<T> {
             }
         }
         return type.getDefaultConstructor()
-                .orElseThrow(() -> new InjectionException("No candidate constructors found for " + type));
+                .orElseThrow(() -> new DefinitionException("No candidate constructors found for " + type));
     }
 }