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 b4c630224b Remove this-escape warnings in OrderByList, ModelParam,
MimeMessageWrapper and the recurrence classes
b4c630224b is described below
commit b4c630224b32232d71b48b8198bc4096674e3cca
Author: Mridul Pathak <[email protected]>
AuthorDate: Tue Oct 27 17:15:17 2026 +0530
Remove this-escape warnings in OrderByList, ModelParam, MimeMessageWrapper
and the recurrence classes
These constructors called overridable methods of their own class. Nothing
subclasses them, so this does not change behaviour.
- OrderByList: the String... and Collection constructors parse the items
with a private static helper instead of calling addOrderBy, and the list field
is final. addOrderBy still adds to it.
- ModelParam: the copy constructor assigns defaultValue directly instead of
calling setDefaultValue. optional is still copied from the source.
- MimeMessageWrapper: the constructors and the public setSession and
setMessage share private helpers.
- RecurrenceInfo and RecurrenceRule: the constructor calls a private load
method, which the public init method also calls.
---
.../org/apache/ofbiz/entity/condition/OrderByList.java | 16 +++++++++++++---
.../main/java/org/apache/ofbiz/service/ModelParam.java | 2 +-
.../apache/ofbiz/service/calendar/RecurrenceInfo.java | 5 ++++-
.../apache/ofbiz/service/calendar/RecurrenceRule.java | 6 +++++-
.../apache/ofbiz/service/mail/MimeMessageWrapper.java | 12 ++++++++++--
5 files changed, 33 insertions(+), 8 deletions(-)
diff --git
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java
index 531dbf4148..f282867430 100644
---
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java
+++
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java
@@ -20,6 +20,7 @@
package org.apache.ofbiz.entity.condition;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
@@ -30,17 +31,26 @@ import org.apache.ofbiz.entity.config.model.Datasource;
import org.apache.ofbiz.entity.model.ModelEntity;
public class OrderByList implements Comparator<GenericEntity> {
- private List<OrderByItem> orderByList = new ArrayList<>();
+ private final List<OrderByItem> orderByList;
public OrderByList() {
+ this.orderByList = new ArrayList<>();
}
public OrderByList(String... orderByList) {
- addOrderBy(orderByList);
+ this.orderByList = parse(Arrays.asList(orderByList));
}
public OrderByList(Collection<String> orderByList) {
- addOrderBy(orderByList);
+ this.orderByList = parse(orderByList);
+ }
+
+ private static List<OrderByItem> parse(Collection<String> orderByList) {
+ List<OrderByItem> items = new ArrayList<>(orderByList.size());
+ for (String orderByItem: orderByList) {
+ items.add(OrderByItem.parse(orderByItem));
+ }
+ return items;
}
/**
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
b/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
index 3c37f8f902..7161c490cf 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelParam.java
@@ -114,7 +114,7 @@ public class ModelParam implements Serializable {
this.stringListSuffix = param.stringListSuffix;
this.validators = param.validators;
if (param.defaultValue != null) {
- this.setDefaultValue(param.defaultValue.getOriginal());
+ this.defaultValue =
FlexibleStringExpander.getInstance(param.defaultValue.getOriginal());
}
this.optional = param.optional;
this.overrideOptional = param.overrideOptional;
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceInfo.java
b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceInfo.java
index d64102c6d1..d4b322f0b7 100644
---
a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceInfo.java
+++
b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceInfo.java
@@ -52,12 +52,15 @@ public class RecurrenceInfo {
if (!"RecurrenceInfo".equals(info.getEntityName())) {
throw new RecurrenceInfoException("Invalid RecurrenceInfo Value
object.");
}
- init();
+ load();
}
/** Initializes the rules for this RecurrenceInfo object. */
public void init() throws RecurrenceInfoException {
+ load();
+ }
+ private void load() throws RecurrenceInfoException {
if (info.get("startDateTime") == null) {
throw new RecurrenceInfoException("Recurrence startDateTime cannot
be null.");
}
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
index 6186b08538..38bceed5b1 100644
---
a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
+++
b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/RecurrenceRule.java
@@ -109,7 +109,7 @@ public class RecurrenceRule {
if (!"RecurrenceRule".equals(rule.getEntityName())) {
throw new RecurrenceRuleException("Invalid RecurrenceRule Value
object.");
}
- init();
+ load();
}
/**
@@ -117,6 +117,10 @@ public class RecurrenceRule {
*@throws RecurrenceRuleException
*/
public void init() throws RecurrenceRuleException {
+ load();
+ }
+
+ private void load() throws RecurrenceRuleException {
// Check the validity of the rule
String freq = rule.getString("frequency");
diff --git
a/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
b/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
index 2a4ddf335c..562b661f02 100644
---
a/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
+++
b/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
@@ -58,11 +58,11 @@ public class MimeMessageWrapper implements
java.io.Serializable {
public MimeMessageWrapper(Session session, MimeMessage message) {
this(session);
- this.setMessage(message);
+ storeMessage(message);
}
public MimeMessageWrapper(Session session) {
- this.setSession(session);
+ storeSession(session);
}
/**
@@ -70,6 +70,10 @@ public class MimeMessageWrapper implements
java.io.Serializable {
* @param session the session
*/
public synchronized void setSession(Session session) {
+ storeSession(session);
+ }
+
+ private void storeSession(Session session) {
this.session = session;
this.mailProperties = session.getProperties();
}
@@ -90,6 +94,10 @@ public class MimeMessageWrapper implements
java.io.Serializable {
* @param message the message
*/
public synchronized void setMessage(MimeMessage message) {
+ storeMessage(message);
+ }
+
+ private void storeMessage(MimeMessage message) {
if (message != null) {
// serialize the message
this.message = message;