Skip to content

Commit

Permalink
Merge #5414, #5420 and #5427 from 4.0 into 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Mar 30, 2024
2 parents 273b9ea + 0cd4025 commit ab98cc3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
Expand Up @@ -758,7 +758,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", ""),
Expand Down
49 changes: 24 additions & 25 deletions impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java
Expand Up @@ -40,17 +40,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.CollectionsUtils;
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;
Expand All @@ -73,6 +62,17 @@
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.CollectionsUtils;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.TypedCollections;
import com.sun.faces.util.Util;

/**
* <p>
* This implementation of {@link ExternalContext} is specific to the servlet implementation.
Expand Down Expand Up @@ -554,10 +554,10 @@ public String encodeActionURL(String url) {
public String encodeResourceURL(String url) {
Util.notNull("url", url);

String result = ((HttpServletResponse) response).encodeURL(url);
pushIfPossibleAndNecessary(result);
String encodedURL = ((HttpServletResponse) response).encodeURL(url);
pushIfPossibleAndNecessary(encodedURL);

return result;
return encodedURL;
}

/**
Expand Down Expand Up @@ -1022,26 +1022,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<String> resourceUrls = (Set<String>) context.getAttributes().computeIfAbsent(PUSH_RESOURCE_URLS_KEY_NAME,
k -> new HashSet<>());
if (!context.getApplication().getResourceHandler().isResourceURL(encodedURL)) {
return;
}

Set<String> resourceUrls = (Set<String>) 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) {
Expand Down
Expand Up @@ -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");
Expand Down

0 comments on commit ab98cc3

Please sign in to comment.