[ofbiz-framework] branch trunk updated: Fixed: Possible NPE in DatabaseUtil.getColumnInfo(...) (OFBIZ-11385)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Fixed: Possible NPE in DatabaseUtil.getColumnInfo(...) (OFBIZ-11385)

mbrohl
This is an automated email from the ASF dual-hosted git repository.

mbrohl 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 17864a1  Fixed: Possible NPE in DatabaseUtil.getColumnInfo(...) (OFBIZ-11385)
17864a1 is described below

commit 17864a11e94f783338d04829e83f0d15cd713346
Author: Benjamin Jugl <[hidden email]>
AuthorDate: Fri Jan 22 16:32:40 2021 +0100

    Fixed: Possible NPE in DatabaseUtil.getColumnInfo(...) (OFBIZ-11385)
---
 .../org/apache/ofbiz/entity/jdbc/DatabaseUtil.java | 29 +++++++++++-----------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java
index 74324e0..099acbc 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java
@@ -857,21 +857,20 @@ public class DatabaseUtil {
         // get ALL tables from this database
         TreeSet<String> tableNames = this.getTableNames(messages);
 
-        // get ALL column info, put into hashmap by table name
-        Map<String, Map<String, ColumnCheckInfo>> colInfo = getColumnInfo(tableNames, true, messages, executor);
-
-        // go through each table and make a ModelEntity object, add to list
-        // for each entity make corresponding ModelField objects
-        // then print out XML for the entities/fields
         List<ModelEntity> newEntList = new LinkedList<>();
-
-        boolean isCaseSensitive = getIsCaseSensitive(messages);
-
-        // iterate over the table names is alphabetical order
-        for (String tableName : new TreeSet<>(colInfo.keySet())) {
-            Map<String, ColumnCheckInfo> colMap = colInfo.get(tableName);
-            ModelEntity newEntity = new ModelEntity(tableName, colMap, modelFieldTypeReader, isCaseSensitive);
-            newEntList.add(newEntity);
+        if (UtilValidate.isNotEmpty(tableNames)) {
+            // get ALL column info, put into hashmap by table name
+            Map<String, Map<String, ColumnCheckInfo>> colInfo = getColumnInfo(tableNames, true, messages, executor);
+            // go through each table and make a ModelEntity object, add to list
+            // for each entity make corresponding ModelField objects
+            // then print out XML for the entities/fields
+            boolean isCaseSensitive = getIsCaseSensitive(messages);
+            // iterate over the table names is alphabetical order
+            for (String tableName : new TreeSet<>(colInfo.keySet())) {
+                Map<String, ColumnCheckInfo> colMap = colInfo.get(tableName);
+                ModelEntity newEntity = new ModelEntity(tableName, colMap, modelFieldTypeReader, isCaseSensitive);
+                newEntList.add(newEntity);
+            }
         }
 
         executor.shutdown();
@@ -1109,7 +1108,7 @@ public class DatabaseUtil {
     private Map<String, Map<String, ColumnCheckInfo>> getColumnInfo(Set<String> tableNames, boolean getPks, Collection<String> messages,
                                                                     ExecutorService executor) {
         // if there are no tableNames, don't even try to get the columns
-        if (tableNames.isEmpty()) {
+        if (UtilValidate.isEmpty(tableNames)) {
             return new HashMap<>();
         }