Skip to content

Commit

Permalink
WELD-766, WELD-761
Browse files Browse the repository at this point in the history
* Improve NPE -> ISE
* Add validation to createInjectionTarget() to 
  give upfront errors
  • Loading branch information
pmuir committed Nov 25, 2010
1 parent 77915c8 commit eb0f202
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -716,6 +716,14 @@ public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> cre
*/
public Object getReference(InjectionPoint injectionPoint, Bean<?> resolvedBean, CreationalContext<?> creationalContext)
{
if (resolvedBean == null)
{
throw new IllegalArgumentException(NULL_BEAN_ARGUMENT);
}
if (creationalContext == null)
{
throw new IllegalArgumentException(NULL_CREATIONAL_CONTEXT_ARGUMENT);
}
boolean registerInjectionPoint = (injectionPoint != null && !injectionPoint.getType().equals(InjectionPoint.class));
boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate();
try
Expand Down
Expand Up @@ -28,6 +28,7 @@
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;

import org.jboss.weld.bootstrap.Validator;
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.exceptions.IllegalStateException;
import org.jboss.weld.exceptions.WeldException;
Expand Down Expand Up @@ -95,6 +96,11 @@ public SimpleInjectionTarget(WeldClass<T> type, BeanManagerImpl beanManager)
throw new DefinitionException(INJECTION_ON_NON_CONTEXTUAL, type, ip);
}
}
Validator validator = new Validator();
for (InjectionPoint ij : this.injectionPoints)
{
validator.validateInjectionPoint(ij, beanManager);
}
}

public T produce(CreationalContext<T> ctx)
Expand Down

0 comments on commit eb0f202

Please sign in to comment.