changcheng / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

WildcardExpanderModelTransformer is not thread safe #455

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create two different resource groups that each use wildcards; i.e:
<group name="js">
  <js>/path/with/lots/of/js/files/**</js>
</group>
<group name="css">
  <css>/path/with/lots/of/css/files/**</css>
</group>

2. request both groups at close to the same time; i.e. requesting the css and 
js on a page

What is the expected output? What do you see instead?
Expect things to work correctly as when each group is requested individually.  
Instead one or both groups do not get served as the processing was thrown off 
by a ConcurrentModificationException:

What version of the product are you using? On what operating system?
Version 1.4.6 Firefox 12, OSX 10.6.8, Java 1.6.0_31

Please provide any additional information below.

Exception is being caught in DefaultWildcardStreamLocator.java:185 with stack 
trace:

java.util.ConcurrentModificationException
    at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
    at java.util.AbstractList$Itr.next(AbstractList.java:343)
    at ro.isdc.wro.model.group.Group.hasResource(Group.java:75)
    at ro.isdc.wro.model.group.Group.addResource(Group.java:166)
    at ro.isdc.wro.model.group.Group.setResources(Group.java:184)
    at ro.isdc.wro.model.group.Group.replace(Group.java:121)
    at ro.isdc.wro.model.transformer.WildcardExpanderModelTransformer$2.apply(WildcardExpanderModelTransformer.java:202)
    at ro.isdc.wro.model.transformer.WildcardExpanderModelTransformer$2.apply(WildcardExpanderModelTransformer.java:180)
    at ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator.triggerWildcardExpander(DefaultWildcardStreamLocator.java:179)
    at ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator.findMatchedFiles(DefaultWildcardStreamLocator.java:129)
    at ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator.locateStream(DefaultWildcardStreamLocator.java:78)
    at ro.isdc.wro.model.resource.locator.ServletContextUriLocator.locate(ServletContextUriLocator.java:128)
    at ro.isdc.wro.model.transformer.WildcardExpanderModelTransformer.processResource(WildcardExpanderModelTransformer.java:114)
    at ro.isdc.wro.model.transformer.WildcardExpanderModelTransformer.transform(WildcardExpanderModelTransformer.java:85)
    at ro.isdc.wro.model.transformer.WildcardExpanderModelTransformer.transform(WildcardExpanderModelTransformer.java:58)
    at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:61)
    at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:27)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:53)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:25)
    at ro.isdc.wro.model.group.processor.GroupsProcessor.process(GroupsProcessor.java:65)
    at ro.isdc.wro.cache.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:40)
    at ro.isdc.wro.cache.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:22)
    at ro.isdc.wro.cache.AbstractSynchronizedCacheStrategyDecorator.get(AbstractSynchronizedCacheStrategyDecorator.java:52)
    at ro.isdc.wro.manager.WroManager.serveProcessedBundle(WroManager.java:182)
    at ro.isdc.wro.manager.WroManager.process(WroManager.java:134)
    at ro.isdc.wro.http.WroFilter.processRequest(WroFilter.java:374)
    at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:324)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:416)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at opower.ei.web.service.messages.XrayFilter.doFilter(XrayFilter.java:53)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at opower.util.log.DebugFilter.doFilter(DebugFilter.java:66)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at poscore.util.web.XForwardedFilter.doFilter(XForwardedFilter.java:54)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Original issue reported on code.google.com by aaron.si...@opower.com on 6 Jun 2012 at 9:58

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 7 Jun 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Fixed in branch 1.4.x.
The problem is that the Group class is not thread-safe. The methods which 
mutate the state of the group were synchronized.

Thanks for noticing!

Original comment by alex.obj...@gmail.com on 7 Jun 2012 at 9:52