You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "htynkn (GitHub)" <gi...@apache.org> on 2019/12/31 03:47:57 UTC
[GitHub] [dubbo] htynkn opened issue #5564: potential code issue -
synchronization on boxed types or strings
- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [x] 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: 2.7.6-SNAPSHOT
``` java
synchronized (parameterClassName.intern()) {
CtClass ctClass = null;
try {
```
https://github.com/apache/dubbo/blob/master/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java#L135
> Code should not synchronize on a variable or field of a boxed type (for example Integer, Boolean) or of type String since it is likely to contain an object that is used throughout the program. For example, Boolean.TRUE holds a single instance that will be used in many places throughout the program: whenever true is autoboxed or a call to Boolean.valueOf is made with true as an argument the same instance of Boolean is returned. It is therefore likely that two classes synchronizing on a field of type Boolean will end up synchronizing on the same object. This may lead to deadlock or threads being blocked unnecessarily.
### References
https://wiki.sei.cmu.edu/confluence/display/java/LCK01-J.+Do+not+synchronize+on+objects+that+may+be+reused
https://cwe.mitre.org/data/definitions/662.html
[ Full content available at: https://github.com/apache/dubbo/issues/5564 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo] htynkn commented on issue #5564: potential code
issue - synchronization on strings
Posted by "htynkn (GitHub)" <gi...@apache.org>.
reported by auto tool. need more analyze
[ Full content available at: https://github.com/apache/dubbo/issues/5564 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo] htynkn closed issue #5564: potential code issue -
synchronization on strings
Posted by "htynkn (GitHub)" <gi...@apache.org>.
[ issue closed by htynkn ]
[ Full content available at: https://github.com/apache/dubbo/issues/5564 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [dubbo] htynkn commented on issue #5564: potential code
issue - synchronization on strings
Posted by "htynkn (GitHub)" <gi...@apache.org>.
invalid issue. close
[ Full content available at: https://github.com/apache/dubbo/issues/5564 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org