Copilot commented on code in PR #15721:
URL: https://github.com/apache/dubbo/pull/15721#discussion_r2434382721
##########
dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/reference/ReferenceBeanManager.java:
##########
@@ -192,6 +192,11 @@ public synchronized void initReferenceBean(ReferenceBean
referenceBean) throws E
// cache referenceConfig
referenceConfigMap.put(referenceKey, referenceConfig);
+ // add a null check for moduleModel to be compatible with the
native environment
+ if (moduleModel == null) {
+ moduleModel =
DubboBeanUtils.getModuleModel(applicationContext);
+ }
+
// register ReferenceConfig
moduleModel.getConfigManager().addReference(referenceConfig);
moduleModel.getDeployer().setPending();
Review Comment:
[nitpick] After the fallback, moduleModel may still be null, which would
result in a NullPointerException at lines 201–202. Consider explicitly guarding
and failing fast with a descriptive exception to make the failure mode clear:
Example:
if (moduleModel == null) {
throw new IllegalStateException("ModuleModel is null after fallback; cannot
register ReferenceConfig.");
}
--
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]