fix #9629 handle OptionalDataException earlier in stack and recursive getCause()
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 6 Jul 2021 10:53:24 +0000 (12:53 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 6 Jul 2021 10:54:25 +0000 (12:54 +0200)
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java

index c7b35206a348c20d992da50b2af9cf8c142e3dc4..969b31488e1ef8ec3d196d77f78711b4ce0a8c5b 100644 (file)
@@ -98,6 +98,10 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
                                  || t.getCause() instanceof CdmAuthenticationException
                                  || (t.getMessage() != null && t.getMessage().contains("status code = 403"))){
                         MessagingUtils.informationDialog("Access denied", MessagingUtils.ACCESS_DENIED);
+                    }else if (includesCause(t, OptionalDataException.class)){
+                        MessagingUtils.informationDialog("Error (OptionalDataException)",
+                                MessagingUtils.RESTART_EDITOR_MESSAGE
+                                );
                     }else
 
                        // NOTE : Currently we only allow RuntimeExceptions since
@@ -127,10 +131,6 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
                                     t,
                                     true);
                         }
-                    }else {
-                        if (includesCause(t, OptionalDataException.class)){
-                            MessagingUtils.warn(this.getClass(), MessagingUtils.RESTART_EDITOR_MESSAGE);
-                        }
                     }
                        }
                    }
@@ -142,9 +142,9 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
         private <T extends Exception> boolean includesCause(Throwable t, Class<? extends Throwable> clazz) {
             boolean result = false;
 
-            if (clazz.isAssignableFrom(t.getClass())){
+            if (clazz.isAssignableFrom(t.getClass()) ){
                 return true;
-            }else if (t.getCause() != null){
+            }else if (t.getCause() != null && t.getCause() != t){
                 return includesCause(t.getCause(), clazz);
             }
             return result;