From 8422123487efb655875446eb3dac2050d122806b Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 31 Jan 2024 05:04:22 +0100 Subject: [PATCH] IDEMPIERE-6017 Fix NPE in MoveClient when a column does not exist (#2218) --- .../src/org/compiere/util/Login.java | 2 +- .../src/org/idempiere/process/MoveClient.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index 0274f0cc87..39e9056ef2 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -981,7 +981,7 @@ public class Login at = "P|" + rs.getString(1); else at = "P" + AD_Window_ID + "|" + rs.getString(1); - }else if ("P".equals(PreferenceFor)){ // preference for processs + }else if ("P".equals(PreferenceFor)){ // preference for process // when apply for all window or all process format is "P0|0|m_Attribute; at = "P" + AD_Window_ID + "|" + AD_InfoWindow_ID + "|" + AD_Process_ID + "|" + rs.getString(1); }else if ("I".equals(PreferenceFor)){ // preference for infoWindow diff --git a/org.adempiere.base/src/org/idempiere/process/MoveClient.java b/org.adempiere.base/src/org/idempiere/process/MoveClient.java index 19a856f92f..3015701fd1 100644 --- a/org.adempiere.base/src/org/idempiere/process/MoveClient.java +++ b/org.adempiere.base/src/org/idempiere/process/MoveClient.java @@ -441,6 +441,15 @@ public class MoveClient extends SvrProcess { */ private void validateExternalTable(String tableName) { statusUpdate("Validating table " + tableName); + + // if table is not present in target + // inform blocking as it has client data + MTable localTable = MTable.get(getCtx(), tableName); + if (localTable == null || localTable.getAD_Table_ID() <= 0) { + p_errorList.add("Table " + tableName + " doesn't exist"); + return; + } + // if table doesn't have client data (taking into account include/exclude) in the source DB // add to the list of tables to ignore // ignore and continue with next table @@ -471,14 +480,6 @@ public class MoveClient extends SvrProcess { } } - // if table is not present in target - // inform blocking as it has client data - MTable localTable = MTable.get(getCtx(), tableName); - if (localTable == null || localTable.getAD_Table_ID() <= 0) { - p_errorList.add("Table " + tableName + " doesn't exist"); - return; - } - // for each source column final String sqlRemoteColumnsST = "" + " SELECT AD_Column.ColumnName, AD_Column.AD_Reference_ID, AD_Column.FieldLength"