Sindri Traustason came in to work one morning to find himself the new owner of a high-priority issue that one of their customers were experiencing: all pages in their web application were erroring-out. Sindri dug in and found the following stack trace in the error logs ...

Caused by: java.lang.StackOverflowError 
at com.sun.org.apache.xml.internal.serializer.CharInfo.isSpecialTextChar(CharInfo.java:430) 
at com.sun.org.apache.xml.internal.serializer.ToStream.accumDefaultEntity(ToStream.java:1055) 
at com.sun.org.apache.xml.internal.serializer.ToStream.accumDefaultEscape(ToStream.java:1613) 
at com.sun.org.apache.xml.internal.serializer.ToStream.characters(ToStream.java:1488)
at com.sun.org.apache.xml.internal.serializer.ToHTMLStream.characters(ToHTMLStream.java:1433) 
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
at GregorSamsa.star() at GregorSamsa.star() at GregorSamsa.star()
-- snip --

Having absolutely no idea what was causing this problem, Sindri turned to Google. He soon learned that Gregor Samsa is the main character from The Metamorphosis by Franz Kafka, and that Gregor turns into a cockroach. Interesting, but not really helpful with the problem at hand.

After some more googling, Sindri learned that Apache Xalan, an XSLT processor, creates "Translet" classes at runtime and that the default class name for the Translet is "GregorSamsa". The problem was that there was infinite recursion in the "star" template. What inspired Sindri to share this WTF was not only the choice of classname, and that it was in the default package, but the excellent explanation of why it was chosen. From the Xalan source code ...

/**
 * As Gregor Samsa awoke one morning from uneasy dreams he found himself
 * transformed in his bed into a gigantic insect. He was lying on his hard,
 * as it were armour plated, back, and if he lifted his head a little he
 * could see his big, brown belly divided into stiff, arched segments, on
 * top of which the bed quilt could hardly keep in position and was about
 * to slide off completely. His numerous legs, which were pitifully thin
 * compared to the rest of his bulk, waved helplessly before his eyes.
 * "What has happened to me?", he thought. It was no dream....
 */
protected static String DEFAULT_TRANSLET_NAME = "GregorSamsa";
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!