()
| 294 | |
| 295 | |
| 296 | @Override |
| 297 | public void run() { |
| 298 | while (Thread.currentThread() == thread) { |
| 299 | try { |
| 300 | Socket socket = server.accept(); |
| 301 | Client client = new Client(parent, socket); |
| 302 | synchronized (clientsLock) { |
| 303 | addClient(client); |
| 304 | if (serverEventMethod != null) { |
| 305 | try { |
| 306 | serverEventMethod.invoke(parent, this, client); |
| 307 | } catch (Exception e) { |
| 308 | System.err.println("Disabling serverEvent() for port " + port); |
| 309 | Throwable cause = e; |
| 310 | // unwrap the exception if it came from the user code |
| 311 | if (e instanceof InvocationTargetException && e.getCause() != null) { |
| 312 | cause = e.getCause(); |
| 313 | } |
| 314 | cause.printStackTrace(); |
| 315 | serverEventMethod = null; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } catch (SocketException e) { |
| 320 | //thrown when server.close() is called and server is waiting on accept |
| 321 | System.err.println("Server SocketException: " + e.getMessage()); |
| 322 | thread = null; |
| 323 | } catch (IOException e) { |
| 324 | //errorMessage("run", e); |
| 325 | e.printStackTrace(); |
| 326 | thread = null; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | |
| 332 | /** |
nothing calls this directly
no test coverage detected