Problem
A failed bind is swallowed, and the accept loop then spins without bound.
MultiServer's constructor calls initializeServerSocket() and ignores its boolean result (lines 14-17). On failure that helper prints Something went wrong while initializing with port 2000! and leaves serverSocket as null (lines 40-48).
start() then runs (lines 19-26):
public void start() {
listening = true;
while (isListening()) {
System.out.println("Listening for a new connection...");
createNewServerThread();
}
}
createNewServerThread() calls serverSocket.accept() on the null reference, catches the resulting exception, prints ERROR: Was not able to listen on port 2000, and returns false — which the loop discards. Nothing sets listening back to false, so the loop repeats immediately and forever.
Starting a second server while port 2000 is already held is therefore expected to produce an unbounded flood of alternating "Listening for a new connection..." and "ERROR: Was not able to listen on port 2000" lines rather than an exit.
Related: stop() does not stop anything
stop() (lines 28-30) sets listening = false, but in the healthy case the loop is blocked inside accept() and will not re-test the flag until a connection arrives. serverSocket is never closed by anything in the tree.
Evidence
Read from src/SimpleServer/server/MultiServer.java, lines 14-59, and src/SimpleServer/server/ServerApp.java lines 8-12 (which hardcodes port 2000).
The busy-loop output described above is UNVERIFIED — no compile or run was performed in the session that filed this issue. The discarded return values and the absent listening reset are source-verifiable; the observed flood is inferred from them.
Proposed change
The bind failure should stop startup rather than being swallowed: either the constructor refuses to leave a half-built server, or start() declines to loop when no socket was bound. A failed createNewServerThread() should not be ignored indefinitely.
This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
Problem
A failed bind is swallowed, and the accept loop then spins without bound.
MultiServer's constructor callsinitializeServerSocket()and ignores itsbooleanresult (lines 14-17). On failure that helper printsSomething went wrong while initializing with port 2000!and leavesserverSocketasnull(lines 40-48).start()then runs (lines 19-26):createNewServerThread()callsserverSocket.accept()on thenullreference, catches the resulting exception, printsERROR: Was not able to listen on port 2000, and returnsfalse— which the loop discards. Nothing setslisteningback tofalse, so the loop repeats immediately and forever.Starting a second server while port 2000 is already held is therefore expected to produce an unbounded flood of alternating "Listening for a new connection..." and "ERROR: Was not able to listen on port 2000" lines rather than an exit.
Related:
stop()does not stop anythingstop()(lines 28-30) setslistening = false, but in the healthy case the loop is blocked insideaccept()and will not re-test the flag until a connection arrives.serverSocketis never closed by anything in the tree.Evidence
Read from
src/SimpleServer/server/MultiServer.java, lines 14-59, andsrc/SimpleServer/server/ServerApp.javalines 8-12 (which hardcodes port 2000).The busy-loop output described above is UNVERIFIED — no compile or run was performed in the session that filed this issue. The discarded return values and the absent
listeningreset are source-verifiable; the observed flood is inferred from them.Proposed change
The bind failure should stop startup rather than being swallowed: either the constructor refuses to leave a half-built server, or
start()declines to loop when no socket was bound. A failedcreateNewServerThread()should not be ignored indefinitely.This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson