From 93aea33cf50289240835fbcccc4365c7800536d9 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sun, 24 Mar 2024 11:15:31 -0400 Subject: [PATCH 1/4] Fix #5414 only http/2-push real faces resource urls coming from resource components/annotations and thus not just any url which happens to be passed through encodeResourceURL --- .../faces/context/ExternalContextImpl.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java b/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java index 935754bf91..d75b6f2032 100644 --- a/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java +++ b/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java @@ -42,16 +42,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.sun.faces.RIConstants; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.context.flash.ELFlash; -import com.sun.faces.renderkit.html_basic.ScriptRenderer; -import com.sun.faces.renderkit.html_basic.StylesheetRenderer; -import com.sun.faces.util.FacesLogger; -import com.sun.faces.util.MessageUtils; -import com.sun.faces.util.TypedCollections; -import com.sun.faces.util.Util; - import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; import jakarta.faces.application.ProjectStage; @@ -74,6 +64,16 @@ import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.PushBuilder; +import com.sun.faces.RIConstants; +import com.sun.faces.config.WebConfiguration; +import com.sun.faces.context.flash.ELFlash; +import com.sun.faces.renderkit.html_basic.ScriptRenderer; +import com.sun.faces.renderkit.html_basic.StylesheetRenderer; +import com.sun.faces.util.FacesLogger; +import com.sun.faces.util.MessageUtils; +import com.sun.faces.util.TypedCollections; +import com.sun.faces.util.Util; + /** *

* This implementation of {@link ExternalContext} is specific to the servlet implementation. @@ -576,10 +576,10 @@ public String encodeResourceURL(String url) { throw new NullPointerException(getExceptionMessageString(NULL_PARAMETERS_ERROR_MESSAGE_ID, "url")); } - String result = ((HttpServletResponse) response).encodeURL(url); - pushIfPossibleAndNecessary(result); + String encodedURL = ((HttpServletResponse) response).encodeURL(url); + pushIfPossibleAndNecessary(encodedURL); - return result; + return encodedURL; } /** @@ -1032,26 +1032,25 @@ public void release() { flash = null; } - private void pushIfPossibleAndNecessary(String result) { + @SuppressWarnings("unchecked") + private void pushIfPossibleAndNecessary(String encodedURL) { FacesContext context = FacesContext.getCurrentInstance(); - // 1. Don't bother trying to push if we've already pushed this URL for this request - @SuppressWarnings("unchecked") - Set resourceUrls = (Set) context.getAttributes().computeIfAbsent(PUSH_RESOURCE_URLS_KEY_NAME, - k -> new HashSet<>()); + if (!context.getApplication().getResourceHandler().isResourceURL(encodedURL)) { + return; + } + + Set resourceUrls = (Set) context.getAttributes().computeIfAbsent(PUSH_RESOURCE_URLS_KEY_NAME, k -> new HashSet<>()); - if (resourceUrls.contains(result)) { + if (!resourceUrls.add(encodedURL)) { return; } - resourceUrls.add(result); - // 2. At this point we know we haven't pushed this URL for this request before PushBuilder pushBuilder = getPushBuilder(context); + if (pushBuilder != null) { - // and now we also know there was no If-Modified-Since header - pushBuilder.path(result).push(); + pushBuilder.path(encodedURL).push(); } - } private PushBuilder getPushBuilder(FacesContext context) { From 3d37a1b5bbdc5be75898e771c1fa650e016ed69e Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sun, 24 Mar 2024 11:23:23 -0400 Subject: [PATCH 2/4] Fix #5420 typo in com.sun.faces.numberOfConcerrentFlashUsers --- impl/src/main/java/com/sun/faces/config/WebConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/config/WebConfiguration.java b/impl/src/main/java/com/sun/faces/config/WebConfiguration.java index 1c4379aa72..e1fea6239a 100644 --- a/impl/src/main/java/com/sun/faces/config/WebConfiguration.java +++ b/impl/src/main/java/com/sun/faces/config/WebConfiguration.java @@ -759,7 +759,8 @@ public enum WebContextInitParameter { NumberOfViews("com.sun.faces.numberOfViewsInSession", "15"), NumberOfLogicalViews("com.sun.faces.numberOfLogicalViews", "15"), NumberOfActiveViewMaps("com.sun.faces.numberOfActiveViewMaps", "25"), - NumberOfConcurrentFlashUsers("com.sun.faces.numberOfConcerrentFlashUsers", "5000"), + NumberOfConcurrentFlashUsers("com.sun.faces.numberOfConcurrentFlashUsers", "5000"), + NumberOfConcerrentFlashUsers("com.sun.faces.numberOfConcerrentFlashUsers", "5000", true, NumberOfConcurrentFlashUsers), NumberOfFlashesBetweenFlashReapings("com.sun.faces.numberOfFlashesBetweenFlashReapings", "5000"), InjectionProviderClass("com.sun.faces.injectionProvider", ""), SerializationProviderClass("com.sun.faces.serializationProvider", ""), From acbdf4cb08c2bbf0ff9cc71468f360d3ebe3c603 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Tue, 26 Mar 2024 06:24:23 -0400 Subject: [PATCH 3/4] Fix #5427 UISelectMany collectionType ignored when VE resolves to non-Collection --- .../com/sun/faces/renderkit/html_basic/MenuRenderer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/renderkit/html_basic/MenuRenderer.java b/impl/src/main/java/com/sun/faces/renderkit/html_basic/MenuRenderer.java index 9477b9ae30..2e5b8152cb 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/html_basic/MenuRenderer.java +++ b/impl/src/main/java/com/sun/faces/renderkit/html_basic/MenuRenderer.java @@ -223,7 +223,12 @@ protected Object convertSelectManyValuesForModel(FacesContext context, UISelectM } if (Object.class.equals(modelType)) { - return convertSelectManyValuesForArray(context, uiSelectMany, modelType, newValues); + if (uiSelectMany.getAttributes().get("collectionType") != null) { + return convertSelectManyValuesForCollection(context, uiSelectMany, null, newValues); + } + else { + return convertSelectManyValuesForArray(context, uiSelectMany, modelType, newValues); + } } throw new FacesException("Target model Type is no a Collection or Array"); From cea3398cd97628d3bef709b20fdbaa3add0c26b3 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Mon, 12 Feb 2024 06:56:32 -0400 Subject: [PATCH 4/4] Default encoding should be prechecked https://github.com/eclipse-ee4j/mojarra/issues/5383 --- impl/src/main/java/com/sun/faces/util/Util.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/util/Util.java b/impl/src/main/java/com/sun/faces/util/Util.java index 5289d39f71..ca481492aa 100644 --- a/impl/src/main/java/com/sun/faces/util/Util.java +++ b/impl/src/main/java/com/sun/faces/util/Util.java @@ -1677,7 +1677,9 @@ public static String getResponseEncoding(FacesContext context, Optional if (encoding == null) { // 5. If still none found then fall back to specified default. - encoding = defaultEncoding.get(); + if (defaultEncoding.isPresent()) { + encoding = defaultEncoding.get(); + } if (encoding != null && !encoding.isBlank()) { if (LOGGER.isLoggable(FINEST)) {