target = ((ManagedReference) componentInstance.getInstanceData(targetKey)).getInstance();
if (target == null) {
throw EeLogger.ROOT_LOGGER.injectionTargetNotFound();
}
}
final ManagedReference reference = factory.getReference();
if (reference == null && optional) {
return context.proceed();
} else if(reference == null) {
throw EeLogger.ROOT_LOGGER.managedReferenceWasNull(field);
}
boolean ok = false;
try {
componentInstance.setInstanceData(valueContextKey, reference);
field.set(target, reference.getInstance());
Object result = context.proceed();
ok = true;
return result;
} finally {
if (!ok) {
componentInstance.setInstanceData(valueContextKey, null);
reference.release();
}
}
}