@@ -240,6 +240,10 @@ Auto-fix boundaries:
240240 - redundant ` if (value != null) ` guards around ` AttributesBuilder.put() ` calls —
241241 ` put ` is a no-op for null values, so remove the conditional and pass the value
242242 directly (same for span, log, and metrics attribute setters).
243+ Apply this only when the guarded value can be passed through directly to the
244+ attribute setter. If the null check is guarding a dereference or other derived
245+ computation, keep the explicit guard instead of rewriting it into a ternary
246+ expression just to pass ` null ` to ` put() ` .
243247 ** Exception** : when the ` AttributeKey ` is typed as ` Long ` and the source value is
244248 ` Integer ` , the generic overload cannot match (` Integer ≠ Long ` ), so Java resolves
245249 to the ` int ` convenience overload ` put(AttributeKey<Long>, int) ` via auto-unboxing.
@@ -248,6 +252,8 @@ Auto-fix boundaries:
248252 When the value type ** matches** the ` AttributeKey ` type parameter (e.g.,
249253 ` Boolean ` → ` AttributeKey<Boolean> ` , ` Long ` → ` AttributeKey<Long> ` ), the generic
250254 ` @Nullable T ` overload is selected directly, null is safe, and the guard is redundant.
255+ For example, keep ` if (view != null) { attributes.put(KEY, view.getClass().getName()); } `
256+ as-is; do not rewrite it to ` attributes.put(KEY, view == null ? null : view.getClass().getName()) ` .
251257 - defensive ` if (param == null) ` checks on parameters not annotated ` @Nullable ` —
252258 these contradict the framework's nullability contract; remove the guard. Conversely,
253259 add ` @Nullable ` to a parameter only when ` null ` is actually passed by callers or an
0 commit comments