You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by jl...@apache.org on 2023/01/20 14:18:57 UTC

[openwebbeans] branch master updated: Try/catch so we don't fail if @New is missing

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

jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b8731a32 Try/catch so we don't fail if @New is missing
     new b080f05df Merge pull request #46 from jgallimore/jg-experimental
2b8731a32 is described below

commit 2b8731a32741c3cbeb4740364da954b3830fc55d
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Fri Jan 13 17:18:35 2023 +0000

    Try/catch so we don't fail if @New is missing
---
 .../webbeans/container/InjectionResolver.java      | 32 +++++++++++++---------
 .../resources/openwebbeans/Messages.properties     |  3 +-
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java b/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
index 5a5ec46a4..e2b8df624 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
@@ -571,23 +571,29 @@ public class InjectionResolver
 
     private void findNewBean(Set<Bean<?>> resolvedComponents, Type injectionPointType, Annotation[] qualifiers)
     {
-        if (qualifiers.length == 1 && New.class.equals(qualifiers[0].annotationType()))
+        try
         {
-            // happen in TCKs, shouldn't be the case in real apps
-            New newQualifier = (New)qualifiers[0];
-            Class<?> beanClass;
-            if (newQualifier.value() != New.class)
+            if (qualifiers.length == 1 && New.class.equals(qualifiers[0].annotationType()))
             {
-                beanClass = newQualifier.value();
-            }
-            else
-            {
-                beanClass = GenericsUtil.getRawType(injectionPointType);
-            }
+                // happen in TCKs, shouldn't be the case in real apps
+                New newQualifier = (New) qualifiers[0];
+                Class<?> beanClass;
+                if (newQualifier.value() != New.class)
+                {
+                    beanClass = newQualifier.value();
+                }
+                else
+                {
+                    beanClass = GenericsUtil.getRawType(injectionPointType);
+                }
 
-            resolvedComponents.add(webBeansContext.getWebBeansUtil().createNewComponent(beanClass));
+                resolvedComponents.add(webBeansContext.getWebBeansUtil().createNewComponent(beanClass));
+            }
+        }
+        catch (NoClassDefFoundError e)
+        {
+            logger.log(Level.FINE, "DEBUG_NEW_ANNOTATION_MISSING", e);
         }
-
     }
 
     private Set<Bean<?>> findByBeanType(Set<Bean<?>> allComponents, Type injectionPointType, boolean isDelegate)
diff --git a/webbeans-impl/src/main/resources/openwebbeans/Messages.properties b/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
index 25171fcff..9af063044 100644
--- a/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
+++ b/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
@@ -115,5 +115,6 @@ EXCEPT_0018 = Wrong startup object.
 
 DEBUG_ADD_BYTYPE_CACHE_BEANS = Adding resolved beans with key [{0}] to cache.
 DEBUG_ADD_BYNAME_CACHE_BEANS = Adding resolved EL beans with key [{0}] to cache.
- 
+DEBUG_NEW_ANNOTATION_MISSING = @New annotation missing. This was deprecated in CDI 1.1, and removed in CDI 4.0. Skipping.
+
 #========= END OF TRANSLATED MESSAGES =================================