28 октября 2008 г.

S?XBuilder

Today I've seen quite amazing exception: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) ... ... ... at org.jdom.input.SAXBuilder.build(SAXBuilder.java:489) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:888) at asg.newsbook.XHtmlToolkit.createDocument(XHtmlToolkit.java:61) ... ... ... (deep from Jasper engine) I've simply called org.jdom.input.SAXBuilder.build(String). I expected this thing to simply parse the damn string into Document, I could expect that it'll throw an exception about invalidity of the document, whatever. No. Software gets so complicated. SAXBuilder decided for whatever reason (here I'm guilty, of course), that it must connect with W3C and download the XSD, or DTD, whatever it needed. And for my each document it sent a web request. Thus slowing down the application a factor of hundreds, accidentally throwing exceptions like the one above, when W3C was too busy. Soo.. Decide for yourself, is this behavior sexy. I think it is. Today I've had enough sex debugging that application. Easy as it was to believe that SAXParser really sux, I'm full of respect of this quite intelligent thing.