You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/01/12 02:52:47 UTC

[GitHub] [incubator-shenyu] KevinClair commented on a change in pull request #2746: [type: refactor] Add protection when ldapprop is null

KevinClair commented on a change in pull request #2746:
URL: https://github.com/apache/incubator-shenyu/pull/2746#discussion_r782672952



##########
File path: shenyu-admin/src/main/java/org/apache/shenyu/admin/config/LdapConfiguration.java
##########
@@ -47,17 +48,19 @@
     @Bean
     @ConditionalOnMissingBean
     public LdapContextSource contextSource(final LdapProperties ldapProp) {
-        LdapContextSource contextSource = new LdapContextSource();
-        contextSource.setUrl(ldapProp.getUrl());
-        contextSource.setUserDn(ldapProp.getBindDn());
-        contextSource.setPassword(ldapProp.getPassword());
-        contextSource.setPooled(true);
-        Map<String, Object> config = new HashMap<>();
-        config.put("java.naming.ldap.attributes.binary", "objectGUID");
-        config.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(ldapProp.getConnectTimeout()));
-        config.put("com.sun.jndi.ldap.read.timeout", String.valueOf(ldapProp.getReadTimeout()));
-        contextSource.setBaseEnvironmentProperties(config);
-        return contextSource;
+        return Optional.ofNullable(ldapProp).map(item -> {

Review comment:
       why?It has been registerd by `@EnableConfigurationProperties(LdapProperties.class)`




-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org