You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "NikoTung (via GitHub)" <gi...@apache.org> on 2023/04/18 09:42:18 UTC

[GitHub] [dubbo] NikoTung opened a new issue, #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

NikoTung opened a new issue, #12122:
URL: https://github.com/apache/dubbo/issues/12122

   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.2.0
   * Operating System version: Mac OS
   * Java version: 17
   
   ### Steps to reproduce this issue
   
   I created a [demo](https://github.com/NikoTung/dubbo3-issue) to reproduce the issue.
   
   While I tried to fix this issue  #12078 , I found a `NullPointException` when the consumer start up and request to `org.apache.dubbo.registry.client.metadata.MetadataServiceDelegation#getMetadataInfo` service in the custom filter which injected a Spring bean successfully. This `NullPointException` only happen when request to the `MetadataService`, the other requests don't affect. It since likes there are two custom filter instances created for the same type.
   
   And I also found the consumer doesn't register to nacos with the following config, can't find the consumer instance on the nacos console.
   
   ```
     dubbo:
     application:
       name: service-consumer-dubbo
       register-mode: instance
       service-discovery:
         migration: FORCE_APPLICATION
       parameters:
         register-consumer-url: true
       qos-enable: false
       register-consumer: true
   ```
   
   
   ### Expected Behavior
   
   * No exception for the MetadataService request.
   * Dubbo consumer register to Nacos
   
   ### Actual Behavior
   
   * NullPointException occurred in custom filter injected with Spring bean for `MetadataService`.
   * Can't find Dubbo consumer in Nacos console.
   
   
   


-- 
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@dubbo.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1537432589

   > Or it's not a good idea to inject Spring bean in Dubbo3 via a `setter` method?
   
   It would be better to create a `Factory` class for yourself.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1539615916

   For the question "Dubbo consumer not register to Nacos", can you @AlbumenJ help to check. Here is the configuration:
   ```
    dubbo:
     application:
       name: service-consumer-dubbo
       register-mode: instance
       service-discovery:
         migration: FORCE_APPLICATION
       parameters:
         register-consumer-url: true
       qos-enable: false
       register-consumer: true
     registry:
       address: nacos://127.0.0.1:8848
       parameters:
         register-consumer-url: true
   ```
   > Dubbo3.0.0版本以后,增加了是否注册消费者的参数,如果需要将消费者注册到nacos注册中心上,需要将参数(register-consumer-url)设置为true,默认是false。
   
   From the [docs](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/registry/nacos/).
   I specified the `register-consumer-url` to `true`, but still can't find the consumer in Nacos console.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1541425481

   In application service discovery mode, consumer node is no longer supported.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung closed issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung closed issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter 
URL: https://github.com/apache/dubbo/issues/12122


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1515828303

   Do you mean that you want to inject `MetadataService` into your bean?


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1539585199

   Thanks. I think it would be great to write this in docs,like:
   * Injecting a Spring bean is not suggested.
   * Recommend to use a Factory class because ...
   * ...


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1521111551

   There are two Filter instance for MetadataService (Internal Services) and user-define services. Filter for internal serivces is useless and you can ignore it.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1516586229

   No, I didn't want to do anything with `MetadataService`. I write a custom filter injected a Spring bean on provider side and the provider starts up normally, the bean was successfully injected to the filter (not null). Also I have a consumer, during start-up this consumer will make a `org.apache.dubbo.registry.client.metadata.MetadataServiceDelegation#getMetadataInfo` request to the provider, I think this is by-design to get provider meta data. When the request come to the provider, it will first invoke the custom filter. The problem is  that the Spring bean in the invoked custom filter is `null`, it only be `null` when the consumer request `org.apache.dubbo.registry.client.metadata.MetadataServiceDelegation#getMetadataInfo`. When I try to request our business interface this custom filter work as expected, no `NullPointException`.  Very time the consumer start up, it can reproduce. This is why I guest that the  custom filter instanced twice.
   
   @AlbumenJ You may check my demo [here](https://github.com/NikoTung/dubbo3-issue).
   
    


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1521176487

   Thanks, now I know that the user-define Filter would be instanced twice, for Internal Services and User-define Services. But I think the Filter should work exactly in both Internal Service and User-define Services, in my case, the Filter instance for Internal Service(MetadataService) was not injected a Spring bean via `public void setBeanToInject(BeanToInject beanToInject)` method which caused a `NullPointException`.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1521239087

   The reason is that spring context is on Dubbo module model level.


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] NikoTung commented on issue #12122: NullPointException when requesting MetadataService on a injected Spring bean custom filter

Posted by "NikoTung (via GitHub)" <gi...@apache.org>.
NikoTung commented on issue #12122:
URL: https://github.com/apache/dubbo/issues/12122#issuecomment-1536921268

   Ok. So now my question is how can I avoid or fix this `NullPointException`? Or it's not a good idea to inject Spring bean in Dubbo3 via a `setter` method?


-- 
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@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org