[
https://issues.apache.org/jira/browse/ARTEMIS-5534?focusedWorklogId=972660&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-972660
]
ASF GitHub Bot logged work on ARTEMIS-5534:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Jun/25 20:18
Start Date: 11/Jun/25 20:18
Worklog Time Spent: 10m
Work Description: jbertram commented on code in PR #5771:
URL: https://github.com/apache/activemq-artemis/pull/5771#discussion_r2140985805
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java:
##########
@@ -289,12 +290,12 @@ V put(long key, V value, int keyHash, boolean
onlyIfAbsent, LongFunction<V> valu
if (storedKey == key) {
if (storedValue == EmptyValue) {
- values[bucket] = value != null ? value : (valueProvider
!= null ? valueProvider.apply(key) : null);
+ values[bucket] = Objects.requireNonNullElse(value,
(valueProvider != null ? valueProvider.apply(key) : null));
Review Comment:
When I first pushed I didn't realize that the default couldn't be `null`.
:laughing:
Issue Time Tracking
-------------------
Worklog Id: (was: 972660)
Time Spent: 40m (was: 0.5h)
> Use Objects.requireNonNullElse() where sensible
> -----------------------------------------------
>
> Key: ARTEMIS-5534
> URL: https://issues.apache.org/jira/browse/ARTEMIS-5534
> Project: ActiveMQ Artemis
> Issue Type: Task
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> There are lots of places across the code-base which do a check like this:
> {code:java}
> foo != null ? foo : bar{code}
> or
> {code:java}
> foo == null ? bar : foo{code}
> These can be replaced, e.g.:
> {code:java}
> Objects.requireNonNullElse(foo, bar){code}
> This code is more clear and will make the code-base more consistent overall.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact