This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 5dd66dd617 Remove the this-escape warning in the null entity sentinels
5dd66dd617 is described below
commit 5dd66dd617a1fc7435e893a209d9b7ca97827394
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Nov 1 09:09:31 2026 +0530
Remove the this-escape warning in the null entity sentinels
NullGenericEntity and NullGenericValue are now final with private
constructors, and both make the sentinel immutable in their constructor.
GenericValue.NULL_VALUE used to stay mutable until the first primary key cache
miss, after which every miss called setImmutable() on the shared object from
its own thread without synchronization; it is now immutable from class
initialization, so those later calls only read the flag. The engine compares
the sentinels by identity, so a subclass insta [...]
---
.../src/main/java/org/apache/ofbiz/entity/GenericEntity.java | 5 +++--
.../entity/src/main/java/org/apache/ofbiz/entity/GenericValue.java | 7 ++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
index fe41d13f43..5148ca0825 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
@@ -1860,8 +1860,9 @@ public class GenericEntity implements Map<String,
Object>, LocalizedMap<Object>,
public interface NULL {
}
- public static class NullGenericEntity extends GenericEntity implements
NULL {
- protected NullGenericEntity() {
+ /** The class of {@link #NULL_ENTITY}, which is shared between threads and
therefore immutable from construction. */
+ public static final class NullGenericEntity extends GenericEntity
implements NULL {
+ private NullGenericEntity() {
this.setImmutable();
}
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericValue.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericValue.java
index 83183f437d..d71095fc41 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericValue.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericValue.java
@@ -254,7 +254,12 @@ public class GenericValue extends GenericEntity {
return GenericValue.create(this);
}
- protected static class NullGenericValue extends GenericValue implements
NULL {
+ /** The class of {@link #NULL_VALUE}, which is shared between threads and
therefore immutable from construction. */
+ protected static final class NullGenericValue extends GenericValue
implements NULL {
+ private NullGenericValue() {
+ this.setImmutable();
+ }
+
/** get entity name */
@Override
public String getEntityName() {