Repository: quarkusio/quarkus
Issue: CDI beans with array type result in warning.

Adding a producer like:

    @Produces
    String[] produce() {
        return new String[0];
    }

results in:

2020-02-25 16:47:35,774 WARN  [io.qua.arc.pro.BeanArchives] (build-14) Failed to index [Ljava.lang.String;: Stream closed
2020-02-25 16:47:35,774 INFO  [io.qua.arc.pro.IndexClassLookupUtils] (build-14) Class for name: [Ljava.lang.String; was not found in Jandex index. Please ensure the class is part of the index.

Changed files:
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanInfo.java
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/IndexClassLookupUtils.java
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java

diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
index f623a2f012c..971c29136be 100644
--- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
+++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
@@ -1,7 +1,5 @@
 package io.quarkus.arc.processor;
 
-import static io.quarkus.arc.processor.IndexClassLookupUtils.getClassByNameNoLogging;
-
 import io.quarkus.arc.impl.ActivateRequestContextInterceptor;
 import io.quarkus.arc.impl.InjectableRequestContextController;
 import java.io.IOException;
@@ -102,7 +100,7 @@ public Collection<ClassInfo> getKnownClasses() {
 
         @Override
         public ClassInfo getClassByName(DotName className) {
-            ClassInfo classInfo = getClassByNameNoLogging(index, className);
+            ClassInfo classInfo = IndexClassLookupUtils.getClassByName(index, className, false);
             if (classInfo == null) {
                 classInfo = additionalClasses.computeIfAbsent(className, this::computeAdditional).orElse(null);
             }
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanInfo.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanInfo.java
index a697e6bef6b..b698a03cb61 100644
--- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanInfo.java
+++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanInfo.java
@@ -384,7 +384,7 @@ void validate(List<Throwable> errors, List<BeanDeploymentValidator> validators)
 
         } else if (isProducerField() || isProducerMethod()) {
             ClassInfo returnTypeClass = getClassByName(beanDeployment.getIndex(),
-                    (isProducerMethod() ? target.get().asMethod().returnType() : target.get().asField().type()).name());
+                    isProducerMethod() ? target.get().asMethod().returnType() : target.get().asField().type());
             // can be null for primitive types
             if (returnTypeClass != null && scope.isNormal() && !Modifier.isInterface(returnTypeClass.flags())) {
                 String methodOrField = isProducerMethod() ? "method" : "field";
@@ -594,19 +594,9 @@ private ClassInfo initImplClazz(AnnotationTarget target, BeanDeployment beanDepl
             case CLASS:
                 return target.asClass();
             case FIELD:
-                Type fieldType = target.asField().type();
-                if (fieldType.kind() != org.jboss.jandex.Type.Kind.PRIMITIVE
-                        && fieldType.kind() != org.jboss.jandex.Type.Kind.ARRAY) {
-                    return getClassByName(beanDeployment.getIndex(), fieldType.name());
-                }
-                break;
+                return getClassByName(beanDeployment.getIndex(), target.asField().type());
             case METHOD:
-                Type returnType = target.asMethod().returnType();
-                if (returnType.kind() != org.jboss.jandex.Type.Kind.PRIMITIVE
-                        && returnType.kind() != org.jboss.jandex.Type.Kind.ARRAY) {
-                    return getClassByName(beanDeployment.getIndex(), returnType.name());
-                }
-                break;
+                return getClassByName(beanDeployment.getIndex(), target.asMethod().returnType());
             default:
                 break;
         }
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java
index 5c6673157c7..6c8cab810d8 100644
--- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java
+++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ClientProxyGenerator.java
@@ -231,11 +231,11 @@ Collection<MethodInfo> getDelegatingMethods(BeanInfo bean) {
                     methods);
         } else if (bean.isProducerMethod()) {
             MethodInfo producerMethod = bean.getTarget().get().asMethod();
-            ClassInfo returnTypeClass = getClassByName(bean.getDeployment().getIndex(), producerMethod.returnType().name());
+            ClassInfo returnTypeClass = getClassByName(bean.getDeployment().getIndex(), producerMethod.returnType());
             Methods.addDelegatingMethods(bean.getDeployment().getIndex(), returnTypeClass, methods);
         } else if (bean.isProducerField()) {
             FieldInfo producerField = bean.getTarget().get().asField();
-            ClassInfo fieldClass = getClassByName(bean.getDeployment().getIndex(), producerField.type().name());
+            ClassInfo fieldClass = getClassByName(bean.getDeployment().getIndex(), producerField.type());
             Methods.addDelegatingMethods(bean.getDeployment().getIndex(), fieldClass, methods);
         } else if (bean.isSynthetic()) {
             Methods.addDelegatingMethods(bean.getDeployment().getIndex(), bean.getImplClazz(), methods);
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/IndexClassLookupUtils.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/IndexClassLookupUtils.java
index b05604d0386..a44669943ed 100644
--- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/IndexClassLookupUtils.java
+++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/IndexClassLookupUtils.java
@@ -1,10 +1,12 @@
 package io.quarkus.arc.processor;
 
-import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import org.jboss.jandex.ClassInfo;
 import org.jboss.jandex.DotName;
 import org.jboss.jandex.IndexView;
+import org.jboss.jandex.Type;
+import org.jboss.jandex.Type.Kind;
 import org.jboss.logging.Logger;
 
 final class IndexClassLookupUtils {
@@ -12,23 +14,29 @@ final class IndexClassLookupUtils {
     private static final Logger LOGGER = Logger.getLogger(IndexClassLookupUtils.class);
 
     // set of already encountered and logged DotNames that are missing in the index
-    private static Set<DotName> alreadyKnown = new HashSet<>();
+    private static final Set<DotName> alreadyKnown = ConcurrentHashMap.newKeySet();
 
     private IndexClassLookupUtils() {
     }
 
-    static ClassInfo getClassByName(IndexView index, DotName dotName) {
-        return lookupClassInIndex(index, dotName, true);
-    }
-
     /**
-     * Used by {@code BeanArchives.IndexWrapper#getClassByName()} while gathering additional classes for indexing
+     * 
+     * @param index
+     * @param type
+     * @return the class for the given type or {@code null} for primitives, arrays and
      */
-    static ClassInfo getClassByNameNoLogging(IndexView index, DotName dotName) {
-        return lookupClassInIndex(index, dotName, false);
+    static ClassInfo getClassByName(IndexView index, Type type) {
+        if (type != null && (type.kind() == Kind.CLASS || type.kind() == Kind.PARAMETERIZED_TYPE)) {
+            return getClassByName(index, type.name());
+        }
+        return null;
+    }
+
+    static ClassInfo getClassByName(IndexView index, DotName dotName) {
+        return getClassByName(index, dotName, true);
     }
 
-    private static ClassInfo lookupClassInIndex(IndexView index, DotName dotName, boolean withLogging) {
+    static ClassInfo getClassByName(IndexView index, DotName dotName, boolean withLogging) {
         if (dotName == null) {
             throw new IllegalArgumentException("Cannot lookup class, provided DotName was null.");
         }
@@ -38,8 +46,8 @@ private static ClassInfo lookupClassInIndex(IndexView index, DotName dotName, bo
         ClassInfo info = index.getClassByName(dotName);
         if (info == null && withLogging && !alreadyKnown.contains(dotName)) {
             // class not in index, log info as this may cause the application to blow up or behave weirdly
-            LOGGER.info("Class for name: " + dotName + " was not found in Jandex index. Please ensure the class " +
-                    "is part of the index.");
+            LOGGER.infof("Class for name: %s was not found in Jandex index. Please ensure the class " +
+                    "is part of the index.", dotName);
             alreadyKnown.add(dotName);
         }
         return info;
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java
index 8ab6741353e..d092300cf03 100644
--- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java
+++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java
@@ -170,7 +170,7 @@ static Set<Type> getProducerMethodTypeClosure(MethodInfo producerMethod, BeanDep
             types.add(OBJECT_TYPE);
             return types;
         } else {
-            ClassInfo returnTypeClassInfo = getClassByName(beanDeployment.getIndex(), returnType.name());
+            ClassInfo returnTypeClassInfo = getClassByName(beanDeployment.getIndex(), returnType);
             if (returnTypeClassInfo == null) {
                 throw new IllegalArgumentException(
                         "Producer method return type not found in index: " + producerMethod.returnType().name());
@@ -197,7 +197,7 @@ static Set<Type> getProducerFieldTypeClosure(FieldInfo producerField, BeanDeploy
             types.add(fieldType);
             types.add(OBJECT_TYPE);
         } else {
-            ClassInfo fieldClassInfo = getClassByName(beanDeployment.getIndex(), producerField.type().name());
+            ClassInfo fieldClassInfo = getClassByName(beanDeployment.getIndex(), producerField.type());
             if (fieldClassInfo == null) {
                 throw new IllegalArgumentException("Producer field type not found in index: " + producerField.type().name());
             }