protected T checkReturnValue ( T instance ) { if ( instance == null && ! isDependent ( ) ) { throw BeanLogger . LOG . nullNotAllowedFromProducer ( getProducer ( ) , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) ) ; } if ( instance == null ) { InjectionPoint injectionPoint = beanManager . getServices ( ) . get ( CurrentInjectionPoint . class ) . peek ( ) ; if ( injectionPoint != null ) { Class < ? > injectionPointRawType = Reflections . getRawType ( injectionPoint . getType ( ) ) ; if ( injectionPointRawType . isPrimitive ( ) ) { return cast ( Defaults . getJlsDefaultValue ( injectionPointRawType ) ) ; } } } if ( instance != null && ! ( instance instanceof Serializable ) ) { if ( beanManager . isPassivatingScope ( getScope ( ) ) ) { throw BeanLogger . LOG . nonSerializableProductError ( getProducer ( ) , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) ) ; } InjectionPoint injectionPoint = beanManager . getServices ( ) . get ( CurrentInjectionPoint . class ) . peek ( ) ; if ( injectionPoint != null && injectionPoint . getBean ( ) != null && Beans . isPassivatingScope ( injectionPoint . getBean ( ) , beanManager ) ) { // Transient field is passivation capable injection point if ( ! ( injectionPoint . getMember ( ) instanceof Field ) || ! injectionPoint . isTransient ( ) ) { throw BeanLogger . LOG . unserializableProductInjectionError ( this , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) , injectionPoint , Formats . formatAsStackTraceElement ( injectionPoint . getMember ( ) ) ) ; } } } return instance ; }
Validates the return value