[ https://issues.apache.org/jira/browse/TILES-598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16534999#comment-16534999 ]
ASF GitHub Bot commented on TILES-598: -------------------------------------- GitHub user chschu opened a pull request: https://github.com/apache/tiles/pull/14 TILES-598: Possible NullPointerException in OptionsRenderer This PR fixes the NullPointerException described in TILES-598. Instead of (erroneously) assuming a non-null cache value if the key exists, it checks the cached value for null. You can merge this pull request into a Git repository by running: $ git pull https://github.com/chschu/tiles trunk Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tiles/pull/14.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #14 ---- commit 42e2abf80de803c08520f301896251a299e1b4b0 Author: Christian Schuster <christian.schuster@...> Date: 2018-07-06T15:21:37Z TILES-598: Possible NullPointerException in OptionsRenderer ---- > Possible NullPointerException in OptionsRenderer > ------------------------------------------------ > > Key: TILES-598 > URL: https://issues.apache.org/jira/browse/TILES-598 > Project: Tiles > Issue Type: Bug > Components: tiles-extras > Affects Versions: 3.0.5 > Reporter: Jo Schm > Priority: Major > Fix For: 3.0.7 > > > *Analysis:* > OptionsRenderer#attemptTemplate (line 193) > If Map#containsKey(template) is true for a template there is another call to > Map#get(template) to retrieve the value for that template / key. At that > point the observation (there exists a mapping) might have become invalid > because the Entry could have been expired at the second call. In this case > Map#get(template) returns "null" which causes a NPE when unboxing is > performed. > *Reproduce:* > Set Cache TTL to 5 seconds: > -Dorg.apache.tiles.extras.renderer.OptionsRenderer.cache_ttl_ms=50000 > Set two breakpoints: > BP 1) line 2728, LocaleCache$Segment#containsKey(Object, int) > BP 2) line 2065, LocaleCache$Segment#get(Object, int) > Call an URL to trigger page rendering. You should hit BP 1) with a key e.g. > "header.jsp". Wait 5 seconds, disable BP 1) and resume. You should hit BP 2) > now. See how #get(..) returns "null" for that key ("header.jsp"). > > *Example Stacktrace:* > {code:java} > java.lang.NullPointerException: null > at > org.apache.tiles.extras.renderer.OptionsRenderer$Cache.attemptTemplate(OptionsRenderer.java:193) > at > org.apache.tiles.extras.renderer.OptionsRenderer.renderAttempt(OptionsRenderer.java:136) > at > org.apache.tiles.extras.renderer.OptionsRenderer.render(OptionsRenderer.java:123) > at > org.apache.tiles.request.render.ChainedDelegateRenderer.render(ChainedDelegateRenderer.java:68) > at > org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) > at > org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:188) > at > org.apache.tiles.template.InsertAttributeModel.execute(InsertAttributeModel.java:132) > at > org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:299) > at > org.apache.jsp.WEB_002dINF.conf.tiles3.page.page_jsp._jspx_meth_tiles_005finsertAttribute_005f0(page_jsp.java:539) > at > org.apache.jsp.WEB_002dINF.conf.tiles3.page.page_jsp._jspService(page_jsp.java:246) > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) > at > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) > at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:386) > at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:40001) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)