This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new 517c2d6  use Tiles already provided URLApplicationResource
     new 33137a4  Merge pull request #352 from yasserzamani/WW-5011
517c2d6 is described below

commit 517c2d690b5ec4d10bd86a490341239beccc530f
Author: Yasser Zamani <yasserzam...@apache.org>
AuthorDate: Sat Apr 20 12:28:07 2019 +0430

    use Tiles already provided URLApplicationResource
    
    fixes WW-5011
    see also: 
https://github.com/joshlong/spring-framework/blob/910dd4146721a803cd9d246b91854e77ffe9272a/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java#L88
---
 .../struts2/tiles/StrutsApplicationResource.java   | 55 ----------------------
 .../StrutsWildcardServletApplicationContext.java   |  6 ++-
 2 files changed, 4 insertions(+), 57 deletions(-)

diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
deleted file mode 100644
index 1f636f9..0000000
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.tiles;
-
-import org.apache.tiles.request.locale.PostfixedApplicationResource;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-public class StrutsApplicationResource extends PostfixedApplicationResource {
-
-    private final URL url;
-
-    public StrutsApplicationResource(URL url) {
-        super(url.getPath());
-        this.url = url;
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException {
-        return url.openStream();
-    }
-
-    @Override
-    public long getLastModified() throws IOException {
-        File file = new File(url.getPath());
-        if (file.exists()) {
-            return file.lastModified();
-        }
-        return 0;
-    }
-
-    @Override
-    public String toString() {
-        return "Resource " + getLocalePath() + " at " + url.toString();
-    }
-}
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
index 7af6069..5b1181f 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java
@@ -24,6 +24,7 @@ import com.opensymphony.xwork2.util.finder.ResourceFinder;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.tiles.request.ApplicationResource;
+import org.apache.tiles.request.locale.URLApplicationResource;
 import org.apache.tiles.request.servlet.ServletApplicationContext;
 
 import javax.servlet.ServletContext;
@@ -101,7 +102,7 @@ public class StrutsWildcardServletApplicationContext 
extends ServletApplicationC
         File localFile = new File(localePath);
         if (localFile.exists()) {
             try {
-                return new 
StrutsApplicationResource(localFile.toURI().toURL());
+                return new URLApplicationResource(localePath, 
localFile.toURI().toURL());
             } catch (MalformedURLException e) {
                 LOG.warn("Cannot access [{}]", localePath, e);
                 return null;
@@ -120,7 +121,8 @@ public class StrutsWildcardServletApplicationContext 
extends ServletApplicationC
 
         for (Map.Entry<String, URL> entry : matches.entrySet()) {
             if (pattern.matcher(entry.getKey()).matches()) {
-                resources.add(new StrutsApplicationResource(entry.getValue()));
+                URL url = entry.getValue();
+                resources.add(new URLApplicationResource(url.toExternalForm(), 
url));
             }
         }
 

Reply via email to