pashapm / lanterna

Automatically exported from code.google.com/p/lanterna
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Issue with TelnetTerminalServer and Spring #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is more of an annoyance than a bug...

TelnetTerminalServer does not give access to the underlying ServerSocket, so we 
have no way to see if the ServerSocket has been closed.  This is usually fine, 
however, if the TelnetTerminalServer is created as a Spring managed bean, a la:

@Bean
public TelnetTerminalServer getTelnetTerminalServer(){ ... }

Spring infers the close() method on the terminalServer, and closes the server 
on shutdown.  When this happens, whatever thread you are calling 
acceptConnection() on starts failing.  As a workaround I used:

@Bean(destroyMethod = "")
public TelnetTerminalServer getTelnetTerminalServer(){ ... }

Added a shutdown hook, and handled interrupts in the server thread.  I don't 
really know of the proper way to address this (or if it should be addressed), 
but an easy fix could be to expose the ServerSocket with a getter, or add an 
isClosed() method to the TelnetTerminalServer class.

Original issue reported on code.google.com by magn...@gmail.com on 19 Jun 2015 at 4:22

GoogleCodeExporter commented 9 years ago
Should have said that I'm working in the master branch of 3.0-SNAPSHOT

Original comment by magn...@gmail.com on 19 Jun 2015 at 4:23

GoogleCodeExporter commented 9 years ago
Sure, I've replaced the setter for socket timeout with a getter for the whole 
server socket

Original comment by mab...@gmail.com on 28 Jun 2015 at 12:29