Copilot commented on code in PR #8140:
URL: https://github.com/apache/incubator-seata/pull/8140#discussion_r3379243960
##########
integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContext.java:
##########
@@ -253,4 +288,177 @@ public String toString() {
.append("]");
return sb.toString();
}
+
+ /**
+ * The tracked action context map.
+ */
+ private static final class TrackedActionContextMap extends
AbstractMap<String, Object> implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final BusinessActionContext owner;
+
+ private final Map<String, Object> delegate;
+
+ private TrackedActionContextMap(BusinessActionContext owner) {
+ this.owner = owner;
+ this.delegate = new HashMap<>(8);
+ }
+
+ private TrackedActionContextMap(BusinessActionContext owner,
Map<String, Object> source) {
+ this.owner = owner;
+ this.delegate = new HashMap<>(source);
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ boolean hadKey = delegate.containsKey(key);
+ Object previousValue = delegate.put(key, value);
+ if (!hadKey || !Objects.equals(previousValue, value)) {
+ owner.markUpdatedOnActionContextMutation();
+ }
+ return previousValue;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends Object> m) {
+ if (m == null || m.isEmpty()) {
+ return;
+ }
+ for (Map.Entry<? extends String, ? extends Object> entry :
m.entrySet()) {
+ put(entry.getKey(), entry.getValue());
+ }
+ }
Review Comment:
`putAll(null)` currently returns silently. This diverges from the `Map`
contract / standard implementations (e.g., `HashMap`), which throw
`NullPointerException` for a null argument, and may hide programming errors.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]