This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git
commit fed4479b409201634a8218f1c034d6b1f4da8ed5 Author: Dan Haywood <d...@haywood-associates.co.uk> AuthorDate: Sun May 13 15:15:10 2018 +0100 ISIS-1946: allows running using o.a.i.WebServer by relaxing validation in _Resource_Path. --- .../applib/internal/resources/_Resource_Path.java | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/resources/_Resource_Path.java b/core/applib/src/main/java/org/apache/isis/applib/internal/resources/_Resource_Path.java index abd19de..fd047d6 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/internal/resources/_Resource_Path.java +++ b/core/applib/src/main/java/org/apache/isis/applib/internal/resources/_Resource_Path.java @@ -34,15 +34,21 @@ abstract class _Resource_Path { protected abstract String resourceName(); public _Resource_Path(String contextPath) { - - if(_Strings.isEmpty(contextPath)) - throw new IllegalArgumentException(resourceName()+" can not be empty"); - - contextPath = contextPath.trim(); - - if(_Strings.isEmpty(contextPath)) - throw new IllegalArgumentException(resourceName()+" can not be empty"); - + +// as it stands, this code fails when running under org.apache.isis.WebServer, because the contextPath passed in is just "" +// But it's not obvious to me why an empty contextPath is not allowed; a value of "/" would be trimmed down to "" anyway. +// Therefore relaxing the logic. +// +// if(_Strings.isEmpty(contextPath)) +// throw new IllegalArgumentException(resourceName()+" can not be empty"); +// +// contextPath = contextPath.trim(); +// +// if(_Strings.isEmpty(contextPath)) +// throw new IllegalArgumentException(resourceName()+" can not be empty"); + + contextPath = defaultIfEmpty(contextPath); + while(contextPath.startsWith("/")) { contextPath = contextPath.substring(1); } @@ -58,5 +64,16 @@ abstract class _Resource_Path { this.path = contextPath; } - + + private static String defaultIfEmpty(final String contextPath) { + if(contextPath == null) { + return "/"; + } + final String trimmedContextPath = contextPath.trim(); + if(_Strings.isEmpty(trimmedContextPath)) { + return "/"; + } + return trimmedContextPath; + } + } -- To stop receiving notification emails like this one, please contact danhayw...@apache.org.