[spring-extensions] branch maint-6 updated: JSE-50 4.2.1 throws an unhandled exception when Locale set to C.UTF-8

Rod Widdowson rdw at steadingsoftware.com
Mon Oct 24 15:37:50 UTC 2022


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

rdw pushed a commit to branch maint-6
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=1fb2fd80bc8ad14c6fc063f6c0bbfafee2de8064

The following commit(s) were added to refs/heads/maint-6 by this push:
     new 1fb2fd8  JSE-50 4.2.1 throws an unhandled exception when Locale set to C.UTF-8
1fb2fd8 is described below

commit 1fb2fd80bc8ad14c6fc063f6c0bbfafee2de8064
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Oct 24 16:37:13 2022 +0100

    JSE-50 4.2.1 throws an unhandled exception when Locale set to C.UTF-8
    
    https://shibboleth.atlassian.net/browse/JSE-50
    
    Catch the error and log it instead.
---
 .../java/net/shibboleth/ext/spring/util/SpringSupport.java   | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java b/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
index dfbff9b..362a073 100644
--- a/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
+++ b/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
@@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Locale;
 import java.util.Locale.LanguageRange;
 
 import javax.annotation.Nonnull;
@@ -336,7 +337,16 @@ public final class SpringSupport {
         final List<LanguageRange> fromBrowser = HttpServletSupport.getLanguageRange(request);
         final List<LanguageRange> outList = new ArrayList<>(1+fromBrowser.size());
 
-        outList.add(new LanguageRange(RequestContextUtils.getLocale(request).getLanguage()));
+        final Locale locale =  RequestContextUtils.getLocale(request);
+        if (locale == null) {
+            LOG.error("Spring returned a null locale");
+        } else {
+            try {
+                outList.add(new LanguageRange(locale.getLanguage()));
+            } catch (final Throwable t) {
+                LOG.error("Could not create LanguageRange for {}, Ignoring", locale, t);
+            }
+        }
         outList.addAll(fromBrowser);
         return List.copyOf(outList);        
     }

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


More information about the commits mailing list