From e87d7d31d898ea487144b62a63fa3b41e3406061 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 14 Oct 2023 08:01:52 -0400 Subject: [PATCH] contracts/resources param can now be Path again after #5329 done --- .../application/resource/WebappResourceHelper.java | 4 ++-- .../java/jakarta/faces/annotation/FacesConfig.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java b/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java index 965cb61c0e..3dd8054e1f 100644 --- a/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java +++ b/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java @@ -64,8 +64,8 @@ public WebappResourceHelper() { WebConfiguration webconfig = WebConfiguration.getInstance(); FacesContext context = FacesContext.getCurrentInstance(); cacheTimestamp = webconfig.isOptionEnabled(CacheResourceModificationTimestamp); - BASE_RESOURCE_PATH = ensureLeadingSlash(ContextParam.WEBAPP_RESOURCES_DIRECTORY.getValue(context)); - BASE_CONTRACTS_PATH = ensureLeadingSlash(ContextParam.WEBAPP_CONTRACTS_DIRECTORY.getValue(context)); + BASE_RESOURCE_PATH = ensureLeadingSlash(ContextParam.WEBAPP_RESOURCES_DIRECTORY.getValue(context).toString()); + BASE_CONTRACTS_PATH = ensureLeadingSlash(ContextParam.WEBAPP_CONTRACTS_DIRECTORY.getValue(context).toString()); } diff --git a/impl/src/main/java/jakarta/faces/annotation/FacesConfig.java b/impl/src/main/java/jakarta/faces/annotation/FacesConfig.java index c0d7d1f7cc..702a462849 100644 --- a/impl/src/main/java/jakarta/faces/annotation/FacesConfig.java +++ b/impl/src/main/java/jakarta/faces/annotation/FacesConfig.java @@ -376,14 +376,14 @@ public static enum ContextParam { VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS(UIViewRoot.VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAME, Boolean.class, false), /** - * Returns {@value ResourceHandler#WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME} as {@link String} with default of {@value ResourceHandler#WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE}. + * Returns {@value ResourceHandler#WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME} as {@link Path} with default of {@value ResourceHandler#WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE}. */ - WEBAPP_CONTRACTS_DIRECTORY(ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, String.class, ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE), + WEBAPP_CONTRACTS_DIRECTORY(ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, Path.class, Paths.get("/", ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE)), /** - * Returns {@value ResourceHandler#WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME} as {@link String} with default of {@value ResourceHandler#WEBAPP_RESOURCES_DIRECTORY_DEFAULT_VALUE}. + * Returns {@value ResourceHandler#WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME} as {@link Path} with default of {@value ResourceHandler#WEBAPP_RESOURCES_DIRECTORY_DEFAULT_VALUE}. */ - WEBAPP_RESOURCES_DIRECTORY(ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME, String.class, ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_DEFAULT_VALUE), + WEBAPP_RESOURCES_DIRECTORY(ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME, Path.class, Paths.get("/", ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_DEFAULT_VALUE)), /** * Returns {@value PushContext#WEBSOCKET_ENDPOINT_PORT_PARAM_NAME} as {@link Integer} with default of {@code 0} (default 0 means the code will take the port from the request). @@ -543,7 +543,9 @@ else if (type == Integer.class) { } } else if (type == Path.class) { - return (T) Paths.get(value); + if (!value.startsWith("/")) { + return (T) Paths.get("/", value); + } } else if (type.isEnum()) { for (Object constant : type.getEnumConstants()) {