/** * {@inheritDoc} */ protected void onStop() { if (socket != null) { CloseUtil.closeQuietly(socket); } }
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
private void dispatchEvents(LoggerContext lc) { ObjectInputStream ois = null; try { socket.setSoTimeout(acceptConnectionTimeout); ois = new HardenedLoggingEventInputStream(socket.getInputStream()); socket.setSoTimeout(0); addInfo(receiverId + "connection established"); while (true) { ILoggingEvent event = (ILoggingEvent) ois.readObject(); Logger remoteLogger = lc.getLogger(event.getLoggerName()); if (remoteLogger.isEnabledFor(event.getLevel())) { remoteLogger.callAppenders(event); } } } catch (EOFException ex) { addInfo(receiverId + "end-of-stream detected"); } catch (IOException ex) { addInfo(receiverId + "connection failed: " + ex); } catch (ClassNotFoundException ex) { addInfo(receiverId + "unknown event class: " + ex); } finally { CloseUtil.closeQuietly(ois); CloseUtil.closeQuietly(socket); socket = null; addInfo(receiverId + "connection closed"); } }
/** * Starts the server. */ protected boolean shouldStart() { try { ServerSocket serverSocket = getServerSocketFactory().createServerSocket(getPort(), getBacklog(), getInetAddress()); ServerListener<RemoteAppenderClient> listener = createServerListener(serverSocket); runner = createServerRunner(listener, getContext().getExecutorService()); runner.setContext(getContext()); return true; } catch (Exception ex) { addError("server startup error: " + ex, ex); CloseUtil.closeQuietly(serverSocket); return false; } }
} finally { if (ois != null) { CloseUtil.closeQuietly(ois);
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
/** * {@inheritDoc} */ protected void onStop() { if (socket != null) { CloseUtil.closeQuietly(socket); } }
/** * {@inheritDoc} */ public void close() { CloseUtil.closeQuietly(serverSocket); }
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
/** * {@inheritDoc} */ @Override public void stop() { if (!isStarted()) return; CloseUtil.closeQuietly(socket); task.cancel(true); if(connectorTask != null) connectorTask.cancel(true); super.stop(); }
private void dispatchEvents() throws InterruptedException { try { socket.setSoTimeout(acceptConnectionTimeout); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); socket.setSoTimeout(0); addInfo(peerId + "connection established"); int counter = 0; while (true) { E event = queue.take(); postProcessEvent(event); Serializable serEvent = getPST().transform(event); oos.writeObject(serEvent); oos.flush(); if (++counter >= CoreConstants.OOS_RESET_FREQUENCY) { // Failing to reset the object output stream every now and // then creates a serious memory leak. oos.reset(); counter = 0; } } } catch (IOException ex) { addInfo(peerId + "connection failed: " + ex); } finally { CloseUtil.closeQuietly(socket); socket = null; addInfo(peerId + "connection closed"); } }
private void dispatchEvents(LoggerContext lc) { try { socket.setSoTimeout(acceptConnectionTimeout); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); socket.setSoTimeout(0); addInfo(receiverId + "connection established"); while (true) { ILoggingEvent event = (ILoggingEvent) ois.readObject(); Logger remoteLogger = lc.getLogger(event.getLoggerName()); if (remoteLogger.isEnabledFor(event.getLevel())) { remoteLogger.callAppenders(event); } } } catch (EOFException ex) { addInfo(receiverId + "end-of-stream detected"); } catch (IOException ex) { addInfo(receiverId + "connection failed: " + ex); } catch (ClassNotFoundException ex) { addInfo(receiverId + "unknown event class: " + ex); } finally { CloseUtil.closeQuietly(socket); socket = null; addInfo(receiverId + "connection closed"); } }
CloseUtil.closeQuietly(oos);
/** * {@inheritDoc} */ protected void onStop() { if (socket != null) { CloseUtil.closeQuietly(socket); } }
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
/** * {@inheritDoc} */ public void close() { CloseUtil.closeQuietly(serverSocket); }
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
/** * {@inheritDoc} */ public void close() { if (socket == null) return; CloseUtil.closeQuietly(socket); }
/** * {@inheritDoc} */ public void close() { CloseUtil.closeQuietly(serverSocket); }
/** * {@inheritDoc} */ protected void onStop() { if (socket != null) { CloseUtil.closeQuietly(socket); } }