Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when start provider #5216

Closed
luyuanwan opened this issue Oct 22, 2019 · 5 comments
Closed

NullPointerException when start provider #5216

luyuanwan opened this issue Oct 22, 2019 · 5 comments

Comments

@luyuanwan
Copy link
Contributor

luyuanwan commented Oct 22, 2019

  • [*] I have searched the issues of this repository and believe that this is not a duplicate.
  • [*] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.5-SNAPSHOT
  • Dubbo branch: master
  • Operating System version: macOS Catalina
  • Java version: jdk-11.0.5

Steps to reproduce this issue

  1. start zookeeper in localhost and port is 2181
  2. write provider-side code
  3. start provider, the provider-side code looks like this
public class Application {

	private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");

	public static void main(String[] args) throws Exception {
		ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
		service.setApplication(new ApplicationConfig("first-dubbo-provider"));
		service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
		service.setInterface(DemoService.class);
		service.setRef(new DemoServiceImpl());
		service.export();

		System.out.println("dubbo service started");
		new CountDownLatch(1).await();
	}
}

Actual Result

But I got an exception.

Exception in thread "main" java.lang.NullPointerException
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$useRegistryForConfigIfNecessary$7(AbstractInterfaceConfig.java:628)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$useRegistryForConfigIfNecessary$8(AbstractInterfaceConfig.java:620)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	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 com.example.studydubboProvider.Application.main(Application.java:22)

Is this an issue?

@lkj41110
Copy link
Contributor

#5186

@luyuanwan
Copy link
Contributor Author

luyuanwan commented Oct 23, 2019

@lkj41110 NO , I found it is client is null, not Parameters

Look at this code :

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

If cc.getParameters() is NULL, it will throw an NullPointerException. if rc.getClient() is NULL, it will also throw an NullPointerException. #5186 fix the bug the previous one ONLY!

@lkj41110
Copy link
Contributor

lkj41110 commented Oct 23, 2019

Map.put(key,null) dont throw an NullPointerException.
I try to run your code in 2.7.4.1(fix this bug), and found no problem.You can recheck it.

@luyuanwan
Copy link
Contributor Author

luyuanwan commented Oct 23, 2019

@lkj41110 OK ,I will recheck it. Your dubbo version is 2.7.4.1, mine is 2.7.5-SNAPSHOT(branch master).Thanks anyway.

@chickenlj
Copy link
Contributor

Please follow the release progress posted in this issue: #5219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants