The Invisible Server Bug: My Experience with a Java HTTP Server
I explored the bugs I encountered while building a bare-metal HTTP server in Java and the importance of I/O.
In this article, I share my experience of building an HTTP server in Java without frameworks. I started with a simple structure crammed into a single main() method. However, as I tried to modularize the code, I encountered a bug: closing the socket before sending the response resulted in no response being delivered.
The root of the bug lay in the complexity of Java's I/O structure. Closing the socket without flushing the writer caused the data to be lost. This experience helped me understand why Java's I/O design is so layered and demonstrated how the Open-Closed Principle works in practice.