You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/05/16 00:48:18 UTC

[GitHub] [shardingsphere] kezhenxu94 opened a new pull request #5634: Defect more when concurrently registering services

kezhenxu94 opened a new pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634


   This pull request follows up #5618.
   
   `ConcurrentHashMap` is thread safe, but `get-and-check-and-put` are composite operations and are thus not atomic, this patch replaces the former with `computeIfAbsent`, which is atomic now.
   
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] coveralls edited a comment on pull request #5634: Defect more when concurrently registering services

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634#issuecomment-629567495


   ## Pull Request Test Coverage Report for [Build 11794](https://coveralls.io/builds/30828300)
   
   * **2** of **2**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
   * No unchanged relevant lines lost coverage.
   * Overall coverage decreased (**-0.006%**) to **59.502%**
   
   ---
   
   
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/30828300/badge)](https://coveralls.io/builds/30828300) |
   | :-- | --: |
   | Change from base [Build 11791](https://coveralls.io/builds/30826689): |  -0.006% |
   | Covered Lines: | 12073 |
   | Relevant Lines: | 20290 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] cherrylzhao commented on a change in pull request #5634: Defect more when concurrently registering services

Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on a change in pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634#discussion_r426106879



##########
File path: shardingsphere-spi/src/main/java/org/apache/shardingsphere/sharding/spi/ShardingSphereServiceLoader.java
##########
@@ -51,17 +51,12 @@
             registerServiceClass(service, each);
         }
     }
-    
-    @SuppressWarnings("unchecked")
+
     private static <T> void registerServiceClass(final Class<T> service, final T instance) {
-        Collection<Class<?>> serviceClasses = SERVICE_MAP.get(service);
-        if (null == serviceClasses) {
-            serviceClasses = new LinkedHashSet<>();
-        }
+        Collection<Class<?>> serviceClasses = SERVICE_MAP.computeIfAbsent(service, unused -> new LinkedHashSet<>());
         serviceClasses.add(instance.getClass());
-        SERVICE_MAP.put(service, serviceClasses);
     }
-    
+

Review comment:
       should keep incident in new line

##########
File path: shardingsphere-spi/src/main/java/org/apache/shardingsphere/sharding/spi/ShardingSphereServiceLoader.java
##########
@@ -73,7 +68,7 @@
     public static <T> Collection<T> newServiceInstances(final Class<T> service) {
         return SERVICE_MAP.containsKey(service) ? SERVICE_MAP.get(service).stream().map(each -> (T) newServiceInstance(each)).collect(Collectors.toList()) : Collections.emptyList();
     }
-    
+

Review comment:
       should keep incident in new line




----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] codecov-io commented on pull request #5634: Defect more when concurrently registering services

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634#issuecomment-629567074


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=h1) Report
   > Merging [#5634](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/459cdda63de638b3778ae3c920a06acb9586ab31&el=desc) will **decrease** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/5634/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #5634      +/-   ##
   ============================================
   - Coverage     56.09%   56.09%   -0.01%     
     Complexity      434      434              
   ============================================
     Files          1143     1143              
     Lines         20293    20290       -3     
     Branches       3681     3680       -1     
   ============================================
   - Hits          11383    11381       -2     
     Misses         8232     8232              
   + Partials        678      677       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...here/sharding/spi/ShardingSphereServiceLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/5634/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9zcGkvU2hhcmRpbmdTcGhlcmVTZXJ2aWNlTG9hZGVyLmphdmE=) | `71.42% <100.00%> (+0.84%)` | `0.00 <0.00> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=footer). Last update [459cdda...8288d46](https://codecov.io/gh/apache/shardingsphere/pull/5634?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] coveralls commented on pull request #5634: Defect more when concurrently registering services

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634#issuecomment-629567495


   ## Pull Request Test Coverage Report for [Build 11793](https://coveralls.io/builds/30827646)
   
   * **2** of **2**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
   * No unchanged relevant lines lost coverage.
   * Overall coverage decreased (**-0.006%**) to **59.502%**
   
   ---
   
   
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/30827646/badge)](https://coveralls.io/builds/30827646) |
   | :-- | --: |
   | Change from base [Build 11791](https://coveralls.io/builds/30826689): |  -0.006% |
   | Covered Lines: | 12073 |
   | Relevant Lines: | 20290 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] cherrylzhao merged pull request #5634: Defect more when concurrently registering services

Posted by GitBox <gi...@apache.org>.
cherrylzhao merged pull request #5634:
URL: https://github.com/apache/shardingsphere/pull/5634


   


----------------------------------------------------------------
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.

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