[ 
https://issues.apache.org/jira/browse/MYFACES-3941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14224354#comment-14224354
 ] 

Thomas Timbul commented on MYFACES-3941:
----------------------------------------

I think you have misunderstood the issue, or I did not explain properly, as it 
has nothing to do with bottlenecks or performance. So let me try again:

When creating the map, you are mapping from *{{String}}* to {{DefaultFacelet}}.

In {{isFaceletCached(URL url)}} you are testing for presence of a *{{URL}}* key 
in that same map.

That is never going to work, the map will never contain a URL key when it has 
been populated with Strings. So your {{isFaceletCached(URL url)}} method might 
as well not exist. What is the purpose of that method, is it ever used in 
MyFaces code? If not I suggest it is an interface method intended for 
subclassing. If that is the case, please fix it, as it will always return false 
in its current implementation.

To illustrate the issue, I have condensed it to the following:

{code}
import static org.junit.Assert.assertTrue;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;

public class FaceletCacheImplTest {

   @Test
   public void test() throws MalformedURLException {
      URL url = new URL("http://www.example.com";);
      Map<String,Object> _facelets = new HashMap<String,Object>();
      _facelets.put(url.toString(), null);
      assertTrue(
         "According to MyFaces team the <String,Object> map should contain a 
key of type URL",
         _facelets.containsKey(url)
      );
   }
}
{code}

Try running it and watch the assertion fail. Note that there's no actual 
dependency on MyFaces in this code, it isn't required to illustrate the issue.

> FaceletCacheImpl#isFaceletCached(URL) always returns false
> ----------------------------------------------------------
>
>                 Key: MYFACES-3941
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3941
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.16, 2.2.6
>            Reporter: Thomas Timbul
>            Assignee: Leonardo Uribe
>
> Correct definition should be:
> {code:title=org.apache.myfaces.view.facelets.impl.FaceletCacheImpl}
> public boolean isFaceletCached(URL url)
> {
>     return _facelets.containsKey(url.toString());
> }
> {code}
> The facelets map {{_facelets}} is actually declared as:
> {code}
> private Map<String, DefaultFacelet> _facelets;
> {code}
> For obvious reasons the current implementation will, in effect, always return 
> false.
> I don't know if a null check might be appropriate, i.e. 
> {code:title=org.apache.myfaces.view.facelets.impl.FaceletCacheImpl}
> public boolean isFaceletCached(URL url)
> {
>     return url!=null && _facelets.containsKey(url.toString());
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to