You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/17 08:52:42 UTC

[GitHub] [pulsar] Radiancebobo opened a new pull request, #18967: [improvement] checkNotNull when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Radiancebobo opened a new pull request, #18967:
URL: https://github.com/apache/pulsar/pull/18967

   The PR was introduced in bookkeeper's PR:https://github.com/apache/bookkeeper/pull/3706
   


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] Radiancebobo closed pull request #18967: [improvement] Avoid leaks when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
Radiancebobo closed pull request #18967: [improvement] Avoid leaks  when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap
URL: https://github.com/apache/pulsar/pull/18967


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] congbobo184 commented on a diff in pull request #18967: [improvement] checkNotNull when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
congbobo184 commented on code in PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#discussion_r1051555145


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java:
##########
@@ -361,6 +361,9 @@ V get(long key, int keyHash) {
         }
 
         V put(long key, V value, int keyHash, boolean onlyIfAbsent, LongFunction<V> valueProvider) {
+            if (value == null) {
+                requireNonNull(valueProvider.apply(key));

Review Comment:
   Even if modification is required, we should only run `valueProvider.apply(key)` once. reason :
   1. The two calculated values may be different
   2. cost performance
   
   



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] github-actions[bot] commented on pull request #18967: [improvement] checkNotNull when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#issuecomment-1356124323

   @Radiancebobo Please add the following content to your PR description and select a checkbox:
   ```
   - [ ] `doc` <!-- Your PR contains doc changes -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] Radiancebobo commented on a diff in pull request #18967: [improvement] checkNotNull when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
Radiancebobo commented on code in PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#discussion_r1051710823


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java:
##########
@@ -361,6 +361,9 @@ V get(long key, int keyHash) {
         }
 
         V put(long key, V value, int keyHash, boolean onlyIfAbsent, LongFunction<V> valueProvider) {
+            if (value == null) {
+                requireNonNull(valueProvider.apply(key));

Review Comment:
   how about this ?
   ![image](https://user-images.githubusercontent.com/39521534/208330122-e43a8e37-1d48-4bb8-b4bd-7518e3fb71ab.png)
   



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] Radiancebobo commented on a diff in pull request #18967: [improvement] Avoid leaks when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
Radiancebobo commented on code in PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#discussion_r1051860384


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java:
##########
@@ -361,6 +361,9 @@ V get(long key, int keyHash) {
         }
 
         V put(long key, V value, int keyHash, boolean onlyIfAbsent, LongFunction<V> valueProvider) {
+            if (value == null) {
+                requireNonNull(valueProvider.apply(key));

Review Comment:
   I'll discuss it here(https://github.com/apache/bookkeeper/pull/3706) and sync it up after the merge, thank you for your review, @congbobo184 



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] Radiancebobo commented on a diff in pull request #18967: [improvement] Avoid leaks when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
Radiancebobo commented on code in PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#discussion_r1051860384


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java:
##########
@@ -361,6 +361,9 @@ V get(long key, int keyHash) {
         }
 
         V put(long key, V value, int keyHash, boolean onlyIfAbsent, LongFunction<V> valueProvider) {
+            if (value == null) {
+                requireNonNull(valueProvider.apply(key));

Review Comment:
   I'll discuss it here(https://github.com/apache/bookkeeper/pull/3706 ) and sync it up after the merge, thank you for your review, @congbobo184 



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] Radiancebobo commented on a diff in pull request #18967: [improvement] checkNotNull when use computeIfAbsent in ConcurrentLongHashMap and ConcurrentOpenHashMap

Posted by GitBox <gi...@apache.org>.
Radiancebobo commented on code in PR #18967:
URL: https://github.com/apache/pulsar/pull/18967#discussion_r1051711886


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java:
##########
@@ -361,6 +361,9 @@ V get(long key, int keyHash) {
         }
 
         V put(long key, V value, int keyHash, boolean onlyIfAbsent, LongFunction<V> valueProvider) {
+            if (value == null) {
+                requireNonNull(valueProvider.apply(key));

Review Comment:
   > 
   
   yes, we should run valueProvider.apply(key) once.  like above, 



-- 
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: commits-unsubscribe@pulsar.apache.org

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