@Override public void destroy() { if (connection != null) { try { connection.close(); } catch (Exception e) { log.error(sm.getString("wsHttpUpgradeHandler.destroyFailed"), e); } } }
@Override public void init(WebConnection wc) { LOGGER.config("Servlet 3.1 Upgrade"); try { is = wc.getInputStream(); os = wc.getOutputStream(); this.wc = wc; } catch (IOException ioe) { throw new RuntimeException(ioe); } try { is.setReadListener(this); } catch (IllegalStateException e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } connection = upgradeInfo.createConnection(writer, new Connection.CloseListener() { @Override public void close(CloseReason reason) { try { TyrusHttpUpgradeHandler.this.getWebConnection().close(); } catch (Exception e) { LOGGER.log(Level.FINE, e.getMessage(), e); } } }); connectionLatch.countDown(); }
@Override public synchronized void write(final ByteBuffer buffer, CompletionHandler<ByteBuffer> completionHandler) { // first write if (servletOutputStream == null) { try { servletOutputStream = tyrusHttpUpgradeHandler.getWebConnection().getOutputStream(); } catch (IOException e) { LOGGER.log(Level.CONFIG, "ServletOutputStream cannot be obtained", e); completionHandler.failed(e); return; } } if (queue.isEmpty() && servletOutputStream.isReady()) { _write(buffer, completionHandler); } else { final QueuedFrame queuedFrame = new QueuedFrame(completionHandler, buffer); queue.offer(queuedFrame); if (!isListenerSet) { isListenerSet = true; servletOutputStream.setWriteListener(this); } } }
@Override public void close() { try { tyrusHttpUpgradeHandler.getWebConnection().close(); } catch (Exception e) { // do nothing. } } }
ServletOutputStream sos; try { sis = connection.getInputStream(); sos = connection.getOutputStream(); } catch (IOException e) { throw new IllegalStateException(e);
@Override public void close(CloseReason reason) { try { TyrusHttpUpgradeHandler.this.getWebConnection().close(); } catch (Exception e) { LOGGER.log(Level.FINE, e.getMessage(), e); } } });
@Override public void destroy() { if (connection != null) { try { connection.close(); } catch (Exception e) { log.error(sm.getString("wsHttpUpgradeHandler.destroyFailed"), e); } } }
@Override public void destroy() { if (connection != null) { try { connection.close(); } catch (Exception e) { log.error(sm.getString("wsHttpUpgradeHandler.destroyFailed"), e); } } }
@Override public void destroy() { if (connection != null) { try { connection.close(); } catch (Exception e) { log.error(sm.getString("wsHttpUpgradeHandler.destroyFailed"), e); } } }
private void close(int closeCode, String closeReason) { if (!closed) { try { connection.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReason)); closed = true; wc.close(); } catch (Exception e) { LOGGER.log(Level.CONFIG, e.getMessage(), e); } } }
private void httpSessionForcedClose(int closeCode, String closeReason) { if (!closed) { try { // TODO // initiates connection close without sending close frame to the client - session is already invalidated // so we should not send anything. // ((TyrusWebSocket) ((TyrusWebSocketEngine) engine).getWebSocketHolder(writer).webSocket).setClosed(); connection.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReason)); closed = true; wc.close(); } catch (Exception e) { LOGGER.log(Level.CONFIG, e.getMessage(), e); } } }
if (isUpgrade && wc != null) { try { wc.close(); } catch (Exception ignored) {