From 90c4b7a64aa0b17a06c70bb56fe27b8c3d3e2997 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 10 Sep 2024 09:56:35 +0200 Subject: [PATCH] IDEMPIERE-6230 ConcurrentModificationException on MTable (#2453) --- .../src/org/compiere/model/MTable.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MTable.java b/org.adempiere.base/src/org/compiere/model/MTable.java index 00500f8172..eda21abbc1 100644 --- a/org.adempiere.base/src/org/compiere/model/MTable.java +++ b/org.adempiere.base/src/org/compiere/model/MTable.java @@ -27,6 +27,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; import org.adempiere.base.IModelFactory; @@ -332,8 +334,8 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport this(ctx, -1, trxName); copyPO(copy); this.m_columns = copy.m_columns != null ? Arrays.stream(copy.m_columns).map(e -> {return new MColumn(ctx, e, trxName);}).toArray(MColumn[]::new): null; - this.m_columnNameMap = copy.m_columnNameMap != null ? new HashMap(copy.m_columnNameMap) : null; - this.m_columnIdMap = copy.m_columnIdMap != null ? new HashMap(copy.m_columnIdMap) : null; + this.m_columnNameMap = copy.m_columnNameMap != null ? new ConcurrentHashMap(copy.m_columnNameMap) : null; + this.m_columnIdMap = copy.m_columnIdMap != null ? new ConcurrentHashMap(copy.m_columnIdMap) : null; this.m_viewComponents = copy.m_viewComponents != null ? Arrays.stream(copy.m_viewComponents).map(e -> {return new MViewComponent(ctx, e, trxName);}).toArray(MViewComponent[]::new) : null; } @@ -342,9 +344,9 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport /** Key Columns */ private String[] m_KeyColumns = null; /** column name to column index map **/ - private Map m_columnNameMap; + private ConcurrentMap m_columnNameMap; /** ad_column_id to column index map **/ - private Map m_columnIdMap; + private ConcurrentMap m_columnIdMap; /** View Components */ private MViewComponent[] m_viewComponents = null; @@ -357,8 +359,8 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport { if (m_columns != null && !requery) return m_columns; - m_columnNameMap = new HashMap(); - m_columnIdMap = new HashMap(); + m_columnNameMap = new ConcurrentHashMap(); + m_columnIdMap = new ConcurrentHashMap(); String sql = "SELECT * FROM AD_Column WHERE AD_Table_ID=? AND IsActive='Y' ORDER BY ColumnName"; ArrayList list = new ArrayList(); PreparedStatement pstmt = null;