jenkinsci / lib-file-leak-detector

Java agent that detects file handle leak
http://file-leak-detector.kohsuke.org/
MIT License
241 stars 112 forks source link

Browser displays the HTTP result and then quickly shows error page #7

Closed centic9 closed 10 years ago

centic9 commented 11 years ago

I tried the http= option of file-leak-detector on Windows, it worked fine there. But on Linux it behaves strangely, the Browser (Firefox 23.0) quickly displays the page, but then switches to an error page, telling me that the connection has been reset.

Sometimes it works, but especially when the application is under stress, it never manages to show the page correctly.

Any clue why this happens? I already tried to keep the Socket open for a bit longer in runHttpServer() and also tried to not close the Socket, it's the same behaviour.

I already tried to use a different GC or give the JVM more memory to rule out that the garbage collector collects the Socket too quickly somehow.

When I use "wget http://localhost:19999/", I get the same "connection has been reset" error message. Equally with curl.

centic9 commented 11 years ago

I think this is because the response is a simple string of bytes instead of a HTTP stream, thus some Browsers might display it if they access non-HTTP content, but others do not. Strange that it does work on Windows and not on Linux with the same browser, though.

I have exchanged the simple writing of bytes with a very simple HTTP implementation taken from https://github.com/NanoHttpd/nanohttpd, with this it works fine now, are you interesting in a pull request for such a change?