This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit ea47d47ea8ab89a8ab84488cac0d0ce030c28efd Author: Gary Gregory <[email protected]> AuthorDate: Thu Jan 9 13:13:08 2025 -0500 Fix Spotbugs SE_TRANSIENT_FIELD_NOT_RESTORED issues [ERROR] Medium: The field org.apache.commons.lang3.builder.DiffBuilder$SDiff.leftSupplier is transient but isn't set by deserialization [org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java SE_TRANSIENT_FIELD_NOT_RESTORED [ERROR] Medium: The field org.apache.commons.lang3.builder.DiffBuilder$SDiff.rightSupplier is transient but isn't set by deserialization [org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java SE_TRANSIENT_FIELD_NOT_RESTORED --- src/changes/changes.xml | 2 ++ .../java/org/apache/commons/lang3/builder/DiffBuilder.java | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6178d93e3..94072e2bd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -75,6 +75,8 @@ The <action> type attribute can be add,update,fix,remove. <action issue="LANG-1759" type="fix" dev="ggregory" due-to="Maxim Butov, Gary Gregory">SerializationUtils.clone(Object) throws ClassCastException when called with a Serializable lambda.</action> <action issue="LANG-1759" type="fix" dev="ggregory" due-to="IBue, Gary Gregory, Piotr P. Karwasz">[StringUtils::indexOfAnyBut] redesign due to inconsistent/faulty behavior regarding UTF-16 surrogates #1327.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Undeprecate ObjectUtils.toString(Object).</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Spotbugs [ERROR] Medium: The field org.apache.commons.lang3.builder.DiffBuilder$SDiff.leftSupplier is transient but isn't set by deserialization [org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java SE_TRANSIENT_FIELD_NOT_RESTORED.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Spotbugs [ERROR] Medium: The field org.apache.commons.lang3.builder.DiffBuilder$SDiff.rightSupplier is transient but isn't set by deserialization [org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java SE_TRANSIENT_FIELD_NOT_RESTORED.</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Add Strings and refactor StringUtils.</action> <action issue="LANG-1747" type="add" dev="ggregory" due-to="Oliver B. Fischer, Gary Gregory">Add StopWatch.run([Failable]Runnable) and get([Failable]Supplier).</action> diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java index 2424e6307..ab358e266 100644 --- a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java @@ -16,6 +16,7 @@ */ package org.apache.commons.lang3.builder; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -163,13 +164,13 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> { } } - private static final class SDiff<T> extends Diff<T> { + private static final class SDiff<T, S extends Supplier<T> & Serializable> extends Diff<T> { private static final long serialVersionUID = 1L; - private final transient Supplier<T> leftSupplier; - private final transient Supplier<T> rightSupplier; + private final transient S leftSupplier; + private final transient S rightSupplier; - private SDiff(final String fieldName, final Supplier<T> leftSupplier, final Supplier<T> rightSupplier, final Class<T> type) { + private SDiff(final String fieldName, final S leftSupplier, final S rightSupplier, final Class<T> type) { super(fieldName, type); this.leftSupplier = Objects.requireNonNull(leftSupplier); this.rightSupplier = Objects.requireNonNull(rightSupplier); @@ -263,7 +264,7 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> { this.equals = testObjectsEquals && Objects.equals(left, right); } - private <F> DiffBuilder<T> add(final String fieldName, final Supplier<F> left, final Supplier<F> right, final Class<F> type) { + private <F, S extends Supplier<F> & Serializable> DiffBuilder<T> add(final String fieldName, final S left, final S right, final Class<F> type) { diffs.add(new SDiff<>(fieldName, left, right, type)); return this; }
