Skip to content

Commit 6aa3219

Browse files
author
Ваше Имя
committed
Fix TCP socket finishConnect() exception handling and connection logic
- Fix bug where finishConnect() required multiple calls before throwing exceptions - Fix logic where address resolution didn't immediately attempt connection - After address is resolved, immediately call channel.finishConnect() - Ensures immediate error reporting for failed socket connections - Improves reliability of socket connection error handling
1 parent a430047 commit 6aa3219

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/scala/li/cil/oc/server/component/InternetCard.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ object InternetCard {
329329
private def checkConnected() = {
330330
if (owner.isEmpty) throw new IOException("connection lost")
331331
try {
332-
if (isAddressResolved) channel.finishConnect()
332+
if (isAddressResolved) {
333+
channel.finishConnect()
334+
}
333335
else if (address.isCancelled) {
334336
// I don't think this can ever happen, Justin Case.
335337
channel.close()
@@ -341,14 +343,15 @@ object InternetCard {
341343
case e: ExecutionException => throw e.getCause
342344
}
343345
isAddressResolved = true
344-
false
346+
// After address resolution, immediately attempt connection
347+
channel.finishConnect()
345348
}
346349
else false
347350
}
348351
catch {
349352
case t: Throwable =>
350353
close()
351-
false
354+
throw t // Propagate exception instead of returning false
352355
}
353356
}
354357

0 commit comments

Comments
 (0)