[MGNLSTK-554] freemarker error in search results stk template Created: 06/Jan/10  Updated: 23/Jan/13  Resolved: 11/Jan/10

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: templates
Affects Version/s: 1.2.1
Fix Version/s: 1.3

Type: Bug Priority: Major
Reporter: Matthew Arriaga Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: freemarker, search_results, stk
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Has occurred in Windows development environment and Redhat production instances using magnolia 4.0, 4.1, 4.2.2


Attachments: Text File freemarker_stacktrace_searchResult_ftl.txt    
Issue Links:
relation
is related to MAGNOLIA-2655 searchResultSnippet tag crashes with ... Closed
is related to MAGNOLIA-2993 Extract logic out of taglibs - reusab... Closed
Template:
Acceptance criteria:
Empty
Date of First Response:

 Description   
  • I think there is something in my content that searchResult.ftl doesn't like.
  • I setup a fresh installation of 4.2.2 and imported my content and was able to reproduce the error after activating the website content to the new install.
  • If I put quotes around the search term the error always goes away.
  • I don't always get the error, only on some search terms, although the terms that cause the error, reliably do so.
  • The error is confusing because I can't find a pattern that indicates what the exact problem with my content is(if that is the cause).
  • For example... If I search for the word "issues" I will get 6 results.
  • If I drop the quotes and search for issues I get the error.
  • If I search for each of the 6 search result's page titles without quotes, the search results correctly display for each term.
  • Some search terms will correctly return more than 6 results without using quotes.
  • I am able to print out the count before the exception is thrown using getCount, so I know the results are there.
  • I tried plugging in some new numbers for the -Xss value in java_opts, hoping to address the stackoverflow but it didn't work.
  • I'm still learning freemarker and I am stuck!

This is the error I am getting...

get(result) failed on instance of info.magnolia.module.templatingkit.search.SearchResultModel
The problematic instruction:
----------
==> assignment: result=model.result! [on line 12, column 1 in templating-kit/paragraphs/features/searchResult.ftl]
----------
Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: get(result) failed on instance ofinfo.magnolia.module.templatingkit.search.SearchResultModel
at freemarker.ext.beans.BeanModel.get(BeanModel.java:223)
...
further down the stack trace I see pages of this...
Caused by: java.lang.StackOverflowError
at java.util.regex.Pattern$Curly.match(Pattern.java:3736)
at java.util.regex.Pattern$Curly.match1(Pattern.java:3797)
at java.util.regex.Pattern$Curly.match(Pattern.java:3746)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
at java.util.regex.Pattern$Curly.match0(Pattern.java:3789)
at java.util.regex.Pattern$Curly.match(Pattern.java:3744)
at java.util.regex.Pattern$Curly.match1(Pattern.java:3797)
at java.util.regex.Pattern$Curly.match(Pattern.java:3746)
...



 Comments   
Comment by Magnolia International [ 06/Jan/10 ]

Hi Matthew,

Thanks for the report! Any chance you could attach the complete stacktrace so we could see where this is coming from, if at all ?

Comment by Magnolia International [ 06/Jan/10 ]

Additionally, if you could provide some sample content that generates the error, it could hopefully help us write some tests and make this piece of code stronger.

(at first glance, all I see involving regexes there, is info.magnolia.module.templatingkit.search.SearchResultItem#stripHtmlTags)

Comment by Matthew Arriaga [ 06/Jan/10 ]

The full stack trace is in the file, here are the first 150 lines.

get(result) failed on instance of info.magnolia.module.templatingkit.search.SearchResultModel
The problematic instruction:
----------
==> assignment: result=model.result! [on line 12, column 1 in templating-kit/paragraphs/features/searchResult.ftl]
<---snipped for readability -->

Comment by Matthew Arriaga [ 06/Jan/10 ]

I've included an export containing a portion of our content that throws the exception. After I import this xml file and search for the word issues, I get the error, if I add quotes it goes away, if I search for the page title returned in the search results I do not get the error. I reproduced the error using a clean install of 4.2.2 enterprise bundle on windows xp pro 32-bit.

Comment by Magnolia International [ 06/Jan/10 ]

I knew this was ringing a bell, and seems similar to MAGNOLIA-2655 (parts of the code of SearchResult* was copied from there...)

Comment by Magnolia International [ 07/Jan/10 ]

fixed on the 1.1, 1.2 branches and the trunk for 1.3.

Matthew, you can grab a patched jar for STK 1.2 here: http://ci.magnolia-cms.com/job/standard-templating-kit_branch-1.2/info.magnolia$magnolia-module-standard-templating-kit/ - can you give it a shot ?

Comment by Matthew Arriaga [ 09/Jan/10 ]

IT WORKED!

I updated our production servers to 4.2.3 and patched using the snapshot and I am no longer seeing the error.

Your timely response on this issue was absolutely outstanding.

Thank-you Grégory,

-Matt

Comment by Magnolia International [ 11/Jan/10 ]

Good to hear! We'll hopefully release STK 1.2.2 shortly, including this bugfix.

Comment by Magnolia International [ 03/Feb/10 ]

Matthew, fyi, STK 1.2.2, and even 1.2.3, have been released. Cheers!

Generated at Mon Feb 12 07:28:09 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.