sofastack / sofa-rpc

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.
https://www.sofastack.tech/sofa-rpc/docs/Home
Apache License 2.0
3.81k stars 1.17k forks source link

com.alipay.remoting.DefaultConnectionManager.scan throws NPE #1331

Closed daryl-chen closed 11 months ago

daryl-chen commented 1 year ago

Describe the bug

throws a NPE when DefaultConnectionManage.scan

Actual behavior

2023-05-29 18:03:28,746 ERROR [RpcTaskScanner$1#58] [RpcTaskScannerThread-2-thread-1] Exception caught when scannings. java.lang.NullPointerException: null at com.alipay.remoting.DefaultConnectionManager.scan(DefaultConnectionManager.java:443) at com.alipay.remoting.rpc.RpcTaskScanner$1.run(RpcTaskScanner.java:56) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750)

Steps to reproduce

暂不知道如何复现

Minimal yet complete reproducer code (or GitHub URL to code)

image

Environment

OrezzerO commented 1 year ago

I will take a look at it. BTW, are you using SOFA-RPC community version in production environment ?

OrezzerO commented 1 year ago

I write the following code to indicate that the iterator pattern is not thread safe:

 public static void testConcurrent(){
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
        map.put("a","b");
        Iterator<String> iterator = map.keySet().iterator();
        if (iterator.hasNext()) {
            map.remove("a");
            String next = iterator.next();
            System.out.println(map.get(next));// it prints null
        }

    }

More measures need to be taken to ensure thread safety. I will fix it in sofa-bolt project.

OrezzerO commented 1 year ago

Please upgrade SOAFRPC version or bolt version. This bug is fix at https://github.com/sofastack/sofa-bolt/pull/230 . Bolt version should greater than 1.6.1.

daryl-chen commented 1 year ago

I write the following code to indicate that the iterator pattern is not thread safe:

 public static void testConcurrent(){
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
        map.put("a","b");
        Iterator<String> iterator = map.keySet().iterator();
        if (iterator.hasNext()) {
            map.remove("a");
            String next = iterator.next();
            System.out.println(map.get(next));// it prints null
        }

    }

More measures need to be taken to ensure thread safety. I will fix it in sofa-bolt project.

I will take a look at it. BTW, are you using SOFA-RPC community version in production environment ?

Yes, is there anything special I should pay attention to?

daryl-chen commented 1 year ago

Okay, we'll do the upgrade, Thanks!

OrezzerO commented 1 year ago

If so , you can sign your company name in https://github.com/sofastack/sofa-rpc/issues/375 .

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.