changcheng / wro4j

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

Processing cssImport of custom jquery-ui.css StackOverflowError #507

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Starting v1.4.8 I get the following when I add jquery-ui-1.8.2.custom.css to 
group.

14:48:28,986 DEBUG CssUrlRewritingProcessor:201 - aggregatedFolderPath: /assets/
14:48:28,986 DEBUG CssUrlRewritingProcessor:207 - subfolders [, assets]
14:48:28,986 DEBUG CssUrlRewritingProcessor:215 - computedPrefix: ..
14:48:28,987 DEBUG CssUrlRewritingProcessor:161 - computed aggregatedPathPrefix 
..
14:48:28,987 DEBUG CssUrlRewritingProcessor:229 - cssUri: 
../gui-common/jquery-ui-1.8.2.custom.css, imageUrl 
images/ui-anim_basic_16x16.gif
14:48:28,987 DEBUG CssUrlRewritingProcessor:255 - computedImageLocation: 
../gui-common/images/ui-anim_basic_16x16.gif
14:48:28,987 DEBUG AbstractCssUrlRewritingProcessor:107 - replaced old Url: 
[images/ui-anim_basic_16x16.gif] with: 
[../gui-common/images/ui-anim_basic_16...].
14:48:28,988 DEBUG CssUrlRewritingProcessor:133 - adding allowed url: 
../gui-common/images/ui-anim_basic_16x16.gif
14:48:28,988 DEBUG ResourceAuthorizationManager:43 - authorize resource: 
../gui-common/images/ui-anim_basic_16x16.gif
14:48:29,010 DEBUG CssUrlRewritingProcessor:124 - allowed urls: 
[../gui-common/images/ui-bg_flat_0_aaaaaa_40x100.png, 
../gui-common/images/ui-anim_basic_16x16.gif]
14:48:29,012 DEBUG MinimizeAwareProcessorDecorator:61 - Using Processor: 
ro.isdc.wro.model.resource.processor.impl.css.CssImportPreProcessor@32919d3e
14:48:29,012 DEBUG CssImportPreProcessor:75 - Applying CssImportPreProcessor 
processor
14:48:29,013 DEBUG ServletContextUriLocator:130 - locate resource: 
/gui-common/jquery-ui-1.8.2.custom.css
14:48:29,013 DEBUG DispatcherStreamLocator:70 - dispatching request to 
location: /gui-common/jquery-ui-1.8.2.custom.css
14:48:29,081 ERROR [default]:253 - Servlet.service() for servlet default threw 
exception
java.lang.StackOverflowError
    at java.util.regex.Pattern$Loop.match(Pattern.java:4275)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
    at java.util.regex.Pattern$Loop.match(Pattern.java:4295)

It is produced after several refreshes on the start of the page and then on 
some e.g. forth or N-th (where N is usually > 4) processes everything without 
this exception but the resulting css file group is without 
jquery-ui-1.8.2.custom.css

This is get with:

debug=true
disableCache=true

and tried both:
resourceWatcherUpdatePeriod=0
and
resourceWatcherUpdatePeriod=1

Disabling cssImport or removing jquery-ui-1.8.2.custom.css from group resolves 
the issue.

Not sure if it is connected to issue #459 so posting separately.

Original issue reported on code.google.com by lystoc...@gmail.com on 10 Aug 2012 at 1:26

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 1:35

GoogleCodeExporter commented 9 years ago
Managed to reproduce it. 
Apparently the comment from line #40 is causing the regex to fail.

As a temporary solution, you can remove it from the css. 
I'll try to fix the problem as soon as possible and will provide you the patch. 

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 1:51

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 1:51

GoogleCodeExporter commented 9 years ago
Fixed in branch 1.4.x. The regex was changed from:
cssImportFromComments=(?:/\*(?:[^*]|(?:\*+[^*/]))*\*+/)|(?://.*)

to

cssImportFromComments=(?:/\*(?:[^*]|(?:\*+[^*/]))*+\*+/)|(?://.*)

The solution is tu use possessive quantifier (*+) instead of lazy one (*?) to 
avoid infinite recursion.

Until the 1.4.9 release is available, you can create a custom implementation of 
CssImportPreProcessor which uses the updated regex.

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 2:37

GoogleCodeExporter commented 9 years ago
This is the exactly the line which was causing the StackOverflowException:

http://jqueryui.com/themeroller/?ctl=themeroller&ffDefault=Verdana,Arial,sans-se
rif&fwDefault=bold&fsDefault=1.0em&cornerRadius=4px&bgColorHeader=909090&bgTextu
reHeader=01_flat.png&bgImgOpacityHeader=75&borderColorHeader=909090&fcHeader=000
000&iconColorHeader=5c5c5c&bgColorContent=bdbdbd&bgTextureContent=03_highlight_s
oft.png&bgImgOpacityContent=50&borderColorContent=e4e4e4&fcContent=000000&iconCo
lorContent=5c5c5c&bgColorDefault=c3c3c3&bgTextureDefault=03_highlight_soft.png&b
gImgOpacityDefault=100&borderColorDefault=999999&fcDefault=000000&iconColorDefau
lt=5c5c5c&bgColorHover=3468a2&bgTextureHover=03_highlight_soft.png&bgImgOpacityH
over=30&borderColorHover=3468a2&fcHover=ffffff&iconColorHover=5c5c5c&bgColorActi
ve=3468a2&bgTextureActive=03_highlight_soft.png&bgImgOpacityActive=30&borderColo
rActive=3468a2&fcActive=ffffff&iconColorActive=5c5c5c&bgColorHighlight=b0d9f7&bg
TextureHighlight=03_highlight_soft.png&bgImgOpacityError=30&borderColorError=cd0
a0a&fcError=ffffff&iconColorError=ffcc00&bgColorOverlay=aaaaaa&bgTextureOverlay=
01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextu
reShadow=01_flat.png

It is very hard to identify the exact pattern which triggers the SO...

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 2:40

GoogleCodeExporter commented 9 years ago
Thanks for fixing it so quickly Alex.
As this comment is generated by themeroller I suppose others who use jquery-ui 
will hit it, but removing the comment should be easy workaround until 1.4.9.

Original comment by lystoc...@gmail.com on 10 Aug 2012 at 3:20

GoogleCodeExporter commented 9 years ago
The simplest way to not get this exception is to create a custom processor 
which uses the patched regex. I can provide more details if needed.

Original comment by alex.obj...@gmail.com on 10 Aug 2012 at 3:24

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 12 Aug 2012 at 6:55