nhandbunch / hapax2 Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/hapax2
License: Other
Automatically exported from code.google.com/p/hapax2
License: Other
What steps will reproduce the problem?
1. Using the following template (template.xtm):
{{#menu}}
<{{#submenu}}{{>template}}{{/submenu}}>
{{#menuitem}}-item{{number}}-
{{/menuitem}}
{{/menu}}
2. And the following code snippet:
TemplateResourceLoader loader = new TemplateResourceLoader("");
Template t = loader.getTemplate("template");
TemplateDictionary dict = TemplateDictionary.create();
TemplateDataDictionary menu = dict.addSection("menu");
menu.addSection("menuitem").setVariable("number", "" + 1);
menu.addSection("menuitem").setVariable("number", "" + 2);
menu.addSection("submenu").addSection("template").addSection("menu").addSection(
"menuitem").setVariable("number",
"" + 3);
System.out.println(t.renderToString(dict));
What is the expected output?
<-item3->
-item1-
-item2-
What do you see instead?
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.getEntry(HashMap.java:344)
at java.util.LinkedHashMap.get(LinkedHashMap.java:280)
at hapax.TemplateDictionary.getVariable(TemplateDictionary.java:147)
at hapax.TemplateDictionary.getVariable(TemplateDictionary.java:155)
at hapax.TemplateDictionary.getVariable(TemplateDictionary.java:155)
...
What version of the product are you using? On what operating system?
Please provide any additional information below.
Eclipse project with a test case attached
Original issue reported on code.google.com by [email protected]
on 18 May 2011 at 8:38
Attachments:
TemplateCache locks the cache hashmap only when adding a new entry, the query
part in TemplateCache.hitCache,
http://code.google.com/p/hapax2/source/browse/trunk/src/hapax/TemplateCache.java
#205 , just calls the get method.
This is not thread-safe. If another thread is adding an entry to the cache,
then during that moment LinkedHashMap may be in inconsistent state and the get
method may either fail like with NullPointerException or, worse, it may return
a wrong entry.
The attached patch fix that via adding missing synchronized around the get call.
Original issue reported on code.google.com by [email protected]
on 31 Mar 2012 at 11:07
Attachments:
I had no idea there was a rewrite of http://code.google.com/p/hapax/
You should probably update that old project to say its deprecated.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2012 at 4:12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.