You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "hermeshephaestus (GitHub)" <gi...@apache.org> on 2019/12/26 16:46:50 UTC

[GitHub] [dubbo] hermeshephaestus opened issue #5543: apache-dubbo-2.7.4.1 AbstractInterfaceConfig#useRegistryForConfigIfNecessary NullPointerException

- [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: apache-dubbo-2.7.4.1
* Operating System version: mac os
* Java version: jdk1.8.0_211

### Steps to reproduce this issue

1. when running demo dubbo-demo-xml-provider a null pointer appears


```
  [27/12/19 00:41:45:876 CST] main  INFO config.AbstractConfig:  [DUBBO] The service ready on spring started. service: org.apache.dubbo.demo.DemoService, dubbo version: , current host: 192.168.0.100
Exception in thread "main" java.lang.NullPointerException
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$null$7(AbstractInterfaceConfig.java:632)
	at java.util.Optional.orElseGet(Optional.java:267)
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$useRegistryForConfigIfNecessary$8(AbstractInterfaceConfig.java:620)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.apache.dubbo.config.AbstractInterfaceConfig.useRegistryForConfigIfNecessary(AbstractInterfaceConfig.java:618)
	at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:208)
	at org.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:303)
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:370)
	at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:336)
	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:114)
	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:60)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at org.apache.dubbo.demo.provider.Application.main(Application.java:30)
[27/12/19 00:41:45:950 CST] Thread-0  INFO support.ClassPathXmlApplicationContext: Closing org.springframework.context.support.ClassPathXmlApplicationContext@2d363fb3: startup date [Fri Dec 27 00:41:44 CST 2019]; root of context hierarchy
[27/12/19 00:41:45:955 CST] Thread-0  INFO support.AbstractRegistryFactory:  [DUBBO] Close all registries [], dubbo version: , current host: 192.168.0.100

```


[ Full content available at: https://github.com/apache/dubbo/issues/5543 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [dubbo] hermeshephaestus commented on issue #5543: apache-dubbo-2.7.4.1 AbstractInterfaceConfig#useRegistryForConfigIfNecessary NullPointerException

Posted by "hermeshephaestus (GitHub)" <gi...@apache.org>.
solution: 

    private void useRegistryForConfigIfNecessary() {
        registries.stream().filter(RegistryConfig::isZookeeperProtocol).findFirst().ifPresent(rc -> {
            // we use the loading status of DynamicConfiguration to decide whether ConfigCenter has been initiated.
            Environment.getInstance().getDynamicConfiguration().orElseGet(() -> {
                ConfigManager configManager = ConfigManager.getInstance();
                ConfigCenterConfig cc = configManager.getConfigCenter().orElse(new ConfigCenterConfig());
                if (rc.getParameters() != null) {
                    Map<String, String> configParams = cc.getParameters() == null ? new HashMap<>() : cc.getParameters();
                    configParams.putAll(rc.getParameters());
                    cc.setParameters(configParams);
                }
                
                
                if (cc.getParameters() != null) {
                    cc.getParameters().put(org.apache.dubbo.remoting.Constants.CLIENT_KEY,rc.getClient());
                }

//                cc.getParameters().put(org.apache.dubbo.remoting.Constants.CLIENT_KEY,rc.getClient());

                cc.setProtocol(rc.getProtocol());
                cc.setAddress(rc.getAddress());
                cc.setUsername(rc.getUsername());
                cc.setPassword(rc.getPassword());
                cc.setHighestPriority(false);
                setConfigCenter(cc);
                startConfigCenter();
                return null;
            });
        });
    }

[ Full content available at: https://github.com/apache/dubbo/issues/5543 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org