ishankhemani commented on code in PR #15889:
URL: https://github.com/apache/dubbo/pull/15889#discussion_r2641899630
##########
dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ReferenceBean.java:
##########
@@ -217,7 +217,17 @@ public T getObject() {
@Override
public Class<?> getObjectType() {
- return getInterfaceClass();
+ if (this.interfaceClass != null) {
+ return this.interfaceClass;
+ }
+ if (this.interfaceName != null) {
+ try {
+ return ClassUtils.forName(this.interfaceName,
this.beanClassLoader);
+ } catch (ClassNotFoundException ignored) {
+ // ignore
+ }
+ }
+ return Object.class;
Review Comment:
Good question, thanks for pointing this out.
Here we intentionally return Object.class instead of throwing an exception
because
ReferenceBean#getObjectType() is used by Spring during type prediction and
bean
matching phases.
Throwing an exception at this stage can cause early bean creation failures
(e.g. BeanNotOfRequiredTypeException) and break context initialization.
Returning Object.class allows Spring to continue initialization safely, while
the actual type is resolved later when the reference is fully initialized.
This behavior is consistent with Spring’s recommendation for FactoryBean
implementations when the target type cannot be determined eagerly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]