This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 5dfd795163d Refactor: Use orElseGet() for lazy evaluation in 
ShardingSphereYamlRepresenter (#37292)
5dfd795163d is described below

commit 5dfd795163d34adadc31a40782692075d60531d0
Author: Sabah shaikh <[email protected]>
AuthorDate: Tue Dec 9 09:21:23 2025 +0530

    Refactor: Use orElseGet() for lazy evaluation in 
ShardingSphereYamlRepresenter (#37292)
    
    - Replace orElse() with orElseGet() to avoid eager evaluation
    - Prevents unnecessary instantiation of DefaultYamlTupleProcessor
    - Aligns with Java Optional best practices
---
 .../infra/util/yaml/representer/ShardingSphereYamlRepresenter.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/ShardingSphereYamlRepresenter.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/ShardingSphereYamlRepresenter.java
index 8972751a9e2..1d161881672 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/ShardingSphereYamlRepresenter.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/ShardingSphereYamlRepresenter.java
@@ -51,7 +51,7 @@ public final class ShardingSphereYamlRepresenter extends 
Representer {
     protected NodeTuple representJavaBeanProperty(final Object javaBean, final 
Property property, final Object propertyValue, final Tag customTag) {
         NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, 
property, propertyValue, customTag);
         return 
TypedSPILoader.findService(ShardingSphereYamlTupleProcessor.class, 
property.getName())
-                .map(optional -> optional.process(nodeTuple)).orElse(new 
DefaultYamlTupleProcessor().process(nodeTuple));
+                .map(processor -> processor.process(nodeTuple)).orElseGet(() 
-> new DefaultYamlTupleProcessor().process(nodeTuple));
     }
     
     @SuppressWarnings({"rawtypes", "unchecked"})

Reply via email to