Hi Martin,

I have finally found some time to investigate this issue further.

It seems that clearing the cache only will clear the variable contentCache
and not both the contentCache and urlSourceCache variables in
LessCacheManager. A cleared cache will trigger a recompile in
LessCacheManager.getCss(URLSource) on a cached URLSource, in this case will
the compiler add the imported files to the importedSources list, returned
by AbstractHierarchicalSource.getImportedSources(), once more. And the
importedSources list will grow with imported files after each call to
clearCache.
The NPE that we get is a result of the shared URLSource and a race
condition in AbstractHierarchicalSource.addImportedSource(LessSource)
(importedSources isn't thread safe).

Furthermore I think there is an issue with the
LessCacheManager.getCss(URLSource). For the first file that is compiled
will the list of imported sources for lessSource be empty. The
lastModifiedTime will then only contain the timestamp for the file and not
the last modified time of the file itself or its imports, so the
lastModifiedTime will be incorrect when adding the compiled source to the
timeToContentMap the first time.

You should be able to see these two issues in this commit
https://github.com/strido/wicket-bootstrap/commit/2be0d8d4294162bd103e63c74198d90457e6069e

Should I report this to your issue tracker (
https://github.com/l0rdn1kk0n/wicket-bootstrap/issues)?

Regards
Erik Strid

On Tue, Sep 6, 2016 at 10:49 AM, Martin Grigorov <mgrigo...@apache.org>
wrote:

> Hi,
>
> If the list of imported sources contains "null" then you should ask at
> https://github.com/SomMeri/less4j/issues.
>
> What I can do in Wicket-Bootstrap-Less is to add protection against this
> NullPointerException by ignoring all "null"s. But this may lead to broken
> UI!
> Please file an issue at
> https://github.com/l0rdn1kk0n/wicket-bootstrap/issues if you think this
> could help.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Tue, Sep 6, 2016 at 10:39 AM, Erik Strid <strid.e...@gmail.com> wrote:
>
> > Hi.
> >
> > We are using Wicket Bootstap Less in our project and have an issue with
> the
> > Less compilation.
> > From time to time the compilation fails for some of the Less files in our
> > project, usually we see this in our Selenium Grid but it have happened
> > locally as well.
> >
> > When the compilation fails we get this stacktrace:
> >
> > java.lang.NullPointerException: null
> > at
> > de.agilecoders.wicket.less.LessCacheManager.findLastModified(
> > LessCacheManager.java:159)
> > ~[wicket-bootstrap-less-0.9.16.jar:0.9.16]
> > at
> > de.agilecoders.wicket.less.LessCacheManager.findLastModified(
> > LessCacheManager.java:165)
> > ~[wicket-bootstrap-less-0.9.16.jar:0.9.16]
> > at
> > de.agilecoders.wicket.less.LessCacheManager.getLastModifiedTime(
> > LessCacheManager.java:145)
> > ~[wicket-bootstrap-less-0.9.16.jar:0.9.16]
> > at
> > de.agilecoders.wicket.less.LessResourceStream.lastModifiedTime(
> > LessResourceStream.java:65)
> > ~[wicket-bootstrap-less-0.9.16.jar:0.9.16]
> > at
> > org.apache.wicket.request.resource.PackageResource.newResourceResponse(
> > PackageResource.java:295)
> > ~[wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.resource.AbstractResource.
> > respond(AbstractResource.java:498)
> > ~[wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.handler.resource.ResourceRequestHandler.
> respond(
> > ResourceRequestHandler.java:75)
> > ~[wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.handler.resource.
> ResourceReferenceRequestHandle
> > r.respond(ResourceReferenceRequestHandler.java:108)
> > ~[wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(
> > RequestCycle.java:890)
> > ~[wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.RequestHandlerStack.execute(
> > RequestHandlerStack.java:64)
> > ~[wicket-request-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.cycle.RequestCycle.execute(
> > RequestCycle.java:261)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.cycle.RequestCycle.
> processRequest(RequestCycle.
> > java:218)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(
> > RequestCycle.java:289)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
> > WicketFilter.java:259)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.protocol.http.WicketFilter.
> processRequest(WicketFilter.
> > java:201)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.apache.wicket.protocol.http.WicketFilter.doFilter(
> > WicketFilter.java:282)
> > [wicket-core-6.22.0.jar:6.22.0]
> > at
> > org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> > doFilter(ServletHandler.java:1652)
> > [jetty-servlet-9.2.15.v20160210.jar:9.2.15.v20160210]
> > at
> > org.springframework.security.web.FilterChainProxy$
> > VirtualFilterChain.doFilter(FilterChainProxy.java:369)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.access.intercept.
> > FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.access.intercept.
> > FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.FilterChainProxy$
> > VirtualFilterChain.doFilter(FilterChainProxy.java:381)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.access.ExceptionTranslationFilter.
> > doFilter(ExceptionTranslationFilter.java:97)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.FilterChainProxy$
> > VirtualFilterChain.doFilter(FilterChainProxy.java:381)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.session.SessionManagementFilter.
> doFilter(
> > SessionManagementFilter.java:100)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.FilterChainProxy$
> > VirtualFilterChain.doFilter(FilterChainProxy.java:381)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> > at
> > org.springframework.security.web.authentication.
> > AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.
> > java:78)
> > [spring-security-web-3.0.7.RELEASE.jar:3.0.7.RELEASE]
> >
> > I have been able do see what is happening when we get the problem
> locally,
> > it is the importedSources for the file currently compiled that contains
> > null.
> > And from what I have seen (if I'm remembering correctly) it has been the
> > first element in the list that is null and the other items in the list
> > contains the correct imports. We are using "classpath!" imports for
> usually
> > one or two imports.
> >
> > I cannot see any point where it is possible to add null to the list of
> > imported sources from reviewing the code that adds the imports in the
> Less
> > files.
> >
> > Furthermore we are adding Less a variable using
> > LessCompilerConfigurationFactory and clear the LessCacheManager upon
> > changes to this variable, however during the tests in our Selenium Grid
> > this shouldn't happen.
> >
> > My problem is that I'm not able to reproduce the issue.
> > Have someone encountered this problem before? Or does someone have hints
> on
> > how to proceed with the troubleshooting?
> >
> > Regards
> > Erik Strid
> >
>

Reply via email to