[java-identity-provider] branch maint-4 updated: IDP-2027 - Flow exception handling is breaking under Eclipse

Scott Cantor cantor.2 at osu.edu
Fri Oct 21 17:53:16 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-4
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=451228da65c6b8578193d765c335b3eb74d72b67

The following commit(s) were added to refs/heads/maint-4 by this push:
     new 451228da6 IDP-2027 - Flow exception handling is breaking under Eclipse
451228da6 is described below

commit 451228da65c6b8578193d765c335b3eb74d72b67
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Oct 21 13:53:13 2022 -0400

    IDP-2027 - Flow exception handling is breaking under Eclipse
    
    https://shibboleth.atlassian.net/browse/IDP-2027
---
 .../net/shibboleth/idp/conf/global-system.xml      |  3 ++
 .../idp/flows/admin/admin-abstract-flow.xml        |  2 +-
 .../idp/flows/authn/authn-abstract-flow.xml        |  6 ++-
 .../idp/flows/c14n/subject-c14n-abstract-flow.xml  |  6 ++-
 .../shibboleth/idp/flows/cas/cas-abstract-flow.xml |  3 +-
 .../client-storage/client-storage-read-flow.xml    |  4 +-
 .../client-storage/client-storage-write-flow.xml   |  4 +-
 .../flows/intercept/intercept-abstract-flow.xml    |  6 ++-
 .../shibboleth/idp/flows/logout/logout-flow.xml    |  3 +-
 .../idp/flows/logout/logout-propagation-flow.xml   |  3 +-
 .../flows/saml/logout/saml2-logoutprop-flow.xml    |  3 +-
 .../idp/flows/saml/saml-abstract-flow.xml          |  2 +-
 .../idp/profile/LogRuntimeException.java           | 43 ++++++++++++++++++++++
 13 files changed, 77 insertions(+), 11 deletions(-)

diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
index 82c7311b8..870c9c152 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
@@ -334,6 +334,9 @@
         p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:fieldReplacements="#{getObject('shibboleth.AuditFieldReplacementMap')}" />
 
+    <!-- Bean used internally to flows to log uncaught exceptions. -->
+    <bean id="LogRuntimeException" class="net.shibboleth.idp.profile.LogRuntimeException" />
+
     <!-- Default attribute mapping support for registry service, exposed here for extension use. -->
 
     <bean id="shibboleth.RegistryNamingFunction" abstract="true"
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
index 27b096cb3..dc051348e 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
@@ -102,7 +102,7 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
         <transition to="HandleError" />
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
index 8a6784d0d..5fa91b3d2 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
@@ -53,7 +53,11 @@
     </subflow-state>
   
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.authn').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.authn', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
index fcf7739fb..9701b875a 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
@@ -23,7 +23,11 @@
     <end-state id="SubjectCanonicalizationError" />
 
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.authn').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.authn', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
index 2fe6644b5..f5205d0dc 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
@@ -9,9 +9,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.cas').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.cas', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="HandleError" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
index 95b06b503..897a30c97 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
@@ -33,9 +33,11 @@
     <!-- Passthrough state if an exception is thrown. -->
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
+        <transition to="RuntimeException" />
     </action-state>
 
     <!-- Successful completion of subflow. -->
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
index 5ed87eead..da6c94993 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
@@ -40,9 +40,11 @@
     <!-- Passthrough state if an exception is thrown. -->
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
+        <transition to="RuntimeException" />
     </action-state>
 
     <!-- Successful completion of subflow. -->
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
index c417975ab..c2c9eb1db 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
@@ -28,7 +28,11 @@
     <end-state id="UpdateSecurityParameters" />
 
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile.interceptor').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile.interceptor', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
index 293f538be..a2990eae9 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
@@ -154,9 +154,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="HandleErrorWithView" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
index 73d4abe95..ae6f007c2 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
@@ -63,9 +63,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="LogoutFailed" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
index d3f8d308b..3f8173b44 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
@@ -92,9 +92,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.saml.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.saml.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="proceed" />
     </action-state>
     
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
index 8092c6141..81214b6b6 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
@@ -143,7 +143,7 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.saml.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.saml.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
         <transition to="HandleError" />
diff --git a/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java
new file mode 100644
index 000000000..a264025e3
--- /dev/null
+++ b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.profile;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dedicated bean used to log flow exceptions, to get around issues with Spring Expressions
+ * referencing class objects under certain conditions that are so far not understood.
+ */
+public class LogRuntimeException {
+ 
+    /**
+     * Log a message about the caught exception to a particular category.
+     * 
+     * @param category category to log under
+     * @param e exception to log
+     */
+    public void log(@Nonnull @NotEmpty final String category, @Nonnull final Exception e) {
+        LoggerFactory.getLogger(category).error("Uncaught runtime exception",
+                e.getCause() != null ? e.getCause() : e);
+    }
+
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list