cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] branch master updated: CAY-2661 NPE on DB Import screen logging unexpected tree node case
Date Mon, 08 Jun 2020 10:57:58 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new bfd7b35  CAY-2661 NPE on DB Import screen   logging unexpected tree node case
bfd7b35 is described below

commit bfd7b356fe2aee09b6fc34cf520f29ccb4f58a62
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Mon Jun 8 13:57:50 2020 +0300

    CAY-2661 NPE on DB Import screen
      logging unexpected tree node case
---
 .../modeler/action/dbimport/TreeManipulationAction.java       | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/dbimport/TreeManipulationAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/dbimport/TreeManipulationAction.java
index 5b6c7d0..fbbc478 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/dbimport/TreeManipulationAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/dbimport/TreeManipulationAction.java
@@ -34,6 +34,8 @@ import org.apache.cayenne.modeler.editor.dbimport.DbImportModel;
 import org.apache.cayenne.modeler.editor.dbimport.DbImportTree;
 import org.apache.cayenne.modeler.undo.DbImportTreeUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.swing.JTree;
 import javax.swing.tree.TreePath;
@@ -49,6 +51,8 @@ import java.util.Map;
  */
 public abstract class TreeManipulationAction extends CayenneAction {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TreeManipulationAction.class);
+
     static final String EMPTY_NAME = "";
 
     protected DbImportTree tree;
@@ -154,7 +158,12 @@ public abstract class TreeManipulationAction extends CayenneAction {
             return false;
         }
         Class<?> selectedObjectClass = node.getUserObject().getClass();
-        return levels.get(selectedObjectClass).contains(insertableNodeClass);
+        List<Class<?>> classes = levels.get(selectedObjectClass);
+        if(classes == null) {
+            LOGGER.warn("Trying to insert node of the unknown class '" + selectedObjectClass.getName()
+ "' to the dbimport tree.");
+            return false;
+        }
+        return classes.contains(insertableNodeClass);
     }
 
     boolean canInsert() {


Mime
View raw message