Link: Socket + XML -> hard to troubleshoot issue

Kohsuke Kawaguchi (Sun engineer working with XML) writes about what happens when you try to read XML directly from a socket stream with expectations of actually writing back to that socket. Specifically, a big nothing. The connection either hangs or dies without sending the response.

Kohsuke gives a clear step by step explanation of why that happens and how to prevent it in the future. If you work with XML, read this article just in case you will run into this in the future. It will save you a lot of troubleshooting time.

Now – after reading the article – the question is how would one figure this out without knowing the XML code backwards?

Since the issue is network related, I would probably start with my favourite multi-tool Ethereal. With the tool running, doing the test case should show that the connection is closed too early by the server. From that point, I would start tracing which bit of code is calling InputStream.close(). Or I would instrument/substitute/wrap the InputStream implementation and do a stack trace dump when its close() method is called.

That’s what I would do. I wonder though how Kohsuke did it himself.

Update: I posted this as a question in the original article’s comments and Kohsuke answered it.

BlogicBlogger Over and Out