Menu

#40 Double-Checked Locking Trouble with SGMLParser Singleton

open
nobody
None
5
2005-03-03
2005-03-03
Anonymous
No

I have trouble with HTMLTemplatePanel. After on 1 of 10
restarts of my application i get strange HTML output,
mostly the HTML TemplatePanels are "unparsed" so that
<component> Tags arent replaced.

I guess that an nasty multithread bug exists in the
SGMLPageParser.getInstance() Method:

public static SGMLPageParser getInstance() {
if (sharedInstance == null) {
synchronized (SGMLPageParser.class) {
if (sharedInstance == null)
sharedInstance = new SGMLPageParser();
......
}

Thats look like an Double-Checked Locking bug. For more
information consider:

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

As workaoround i extend HtmlTemplateLayoutManager and
HtmlTemplateLayoutManagerUI and synchronized the
.compileDataSource() + .render(...) Methodes.

OS: Windows 2000
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

Discussion


Log in to post a comment.