[
https://issues.apache.org/jira/browse/ARTEMIS-5535?focusedWorklogId=972662&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-972662
]
ASF GitHub Bot logged work on ARTEMIS-5535:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Jun/25 20:26
Start Date: 11/Jun/25 20:26
Worklog Time Spent: 10m
Work Description: tabish121 commented on code in PR #5772:
URL: https://github.com/apache/activemq-artemis/pull/5772#discussion_r2140997895
##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java:
##########
@@ -499,8 +500,7 @@ public void handlePacket(final Packet packet) {
private void handleDisconnect(SimpleString nodeID, DisconnectReason
reason, SimpleString targetNodeID, TransportConfiguration tagetConnector) {
if (topologyResponseHandler != null) {
- topologyResponseHandler.nodeDisconnected(conn, nodeID == null ?
null : nodeID.toString(), reason,
- targetNodeID == null ? null : targetNodeID.toString(),
tagetConnector);
+ topologyResponseHandler.nodeDisconnected(conn,
Objects.toString(nodeID), reason, Objects.toString(targetNodeID),
tagetConnector);
Review Comment:
Since `Object.toString(x)` returns "null" and not `null` in the case the
value is `null` I'm worried there might be some behavioral changes here that
are not intended. In this case if `nodeID` is null the method will be called
with `nodeID` set to "null" which might not be what was intended, I'd guess
other cases in this PR might see similar side effects.
Issue Time Tracking
-------------------
Worklog Id: (was: 972662)
Time Spent: 20m (was: 10m)
> Use Objects.toString() instead of ternary operator
> --------------------------------------------------
>
> Key: ARTEMIS-5535
> URL: https://issues.apache.org/jira/browse/ARTEMIS-5535
> Project: ActiveMQ Artemis
> Issue Type: Task
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> There are lots of places across the code-base which do a check like this:
> {code:java}
> foo != null ? foo.toString() : null{code}
> or
> {code:java}
> foo == null ? null : foo.toString(){code}
> These can be replaced, e.g.:
> {code:java}
> Objects.toString(foo){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