@Override public synchronized void close() throws IOException { super.close(); toTested.close(); toTester.close(); fromTested.close(); fromTester.close(); }
public void pipedInputStreamNotClosedAfterRead(PipedOutputStream pout) { PipedInputStream pin; try { pin = new PipedInputStream(pout); int data = pin.read(); pin.close(); } catch (IOException e) { } }
/** * ************************************************************************* CONCRETE METHOD:: * ClosePorts Purpose: This method is used to close the input and output ports of the filter. It * is important that filters close their ports before the filter thread exits. * * <p>Arguments: void * * <p>Returns: void * * <p>Exceptions: IOExecption * * <p>************************************************************************** */ void ClosePorts() { try { InputReadPort.close(); OutputWritePort.close(); } catch (Exception Error) { System.out.println("\n" + this.getName() + " ClosePorts error::" + Error); } // catch } // ClosePorts
private void closeIO() { try { fMIOutConsolePipe.close(); } catch (IOException e) { } try { fMIInConsolePipe.close(); } catch (IOException e) { } try { fMIOutLogPipe.close(); } catch (IOException e) { } try { fMIInLogPipe.close(); } catch (IOException e) { } }
public void pipedInputStreamClosed(PipedOutputStream pout) throws IOException { PipedInputStream pin = null; try { pin = new PipedInputStream(pout); int data = pin.read(); } catch (IOException e) { } finally { pin.close(); } }
@Override public void close() { closed = true; try { super.close(); out.close(); } catch (IOException e) { logger.error("Unexpected IO exception", e); } }
@Override public void run() { long lastInvocation = 0; byte[] readBuffer = new byte[flushBufferSize]; while (state == 0) { long curTime = System.currentTimeMillis(); try { if ((lastInvocation + flushBufferTimeout) <= curTime) { lastInvocation = curTime; // Flush given buffer size to output buffer. int read = pis.read(readBuffer, 0, readBuffer.length); if (read > 0) { out.write(readBuffer, 0, read); out.flush(); } else { break; } } // Sleep for a small unit of time. Thread.sleep(SLEEP_TIME); } catch (Exception ex) { ex.printStackTrace(System.err); break; } } System.err.println("SDS: finished, state=" + state + "; TID=" + Thread.currentThread().getId()); // In this state keep flushing rapidly. if (state == 1) { int count; byte[] buffer = new byte[8192]; try { while ((count = pis.read(buffer, 0, buffer.length)) > 0) { out.write(buffer, 0, count); out.flush(); } } catch (Exception ex) { ex.printStackTrace(System.err); } } state = 3; try { pis.close(); pos.close(); } catch (IOException ex) { ex.printStackTrace(System.err); } System.err.println("SDS: finished, state=" + state + "; TID=" + Thread.currentThread().getId()); }
@Override public void process() throws Exception { log.trace("process()"); HandlerThread handlerThread = new HandlerThread(); handlerThread.setName(Thread.currentThread().getName() + "-soap"); handlerThread.start(); try { // Wait for the request SOAP message to be parsed before we can // start sending stuff. waitForSoapMessage(); // If the handler thread excepted, do not continue. checkError(); // Verify that the client is registered verifyClientStatus(); // Check client authentication mode verifyClientAuthentication(); // If the message is synchronous, start sending proxy message if (!isAsync) { processRequest(); } if (response != null) { sendResponse(); } } catch (Exception e) { if (reqIns != null) { reqIns.close(); } // Let's interrupt the handler thread so that it won't // block forever waiting for us to do something. handlerThread.interrupt(); throw e; } finally { handlerThread.join(); if (response != null) { response.consume(); } } }
/** * The local connection was meant to use PipeStreams instead of initiateQueueDataExchange. As I * had issues, I resorted to Queues. Unfortunately, this means that the protocol handshake is * written twice. */ private void initiate() { try { logger.log(Level.INFO, "Starting the server Protocol"); serverProtocol.startProtocol(outputStream, inputStream); } catch (UnexpectedProtocolException e) { logger.log(Level.SEVERE, "Server received an incorrect protocol from the client."); e.printStackTrace(); } catch (IOException e) { logger.log(Level.SEVERE, "Error trying to start the server protocol"); e.printStackTrace(); } finally { try { logger.log(Level.INFO, "Server closing streams"); outputStream.close(); inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } }
private void sendRequest(HttpSender httpSender) throws Exception { log.trace("sendRequest()"); try { // If we're using SSL, we need to include the provider name in // the HTTP request so that server proxy could verify the SSL // certificate properly. if (SystemProperties.isSslEnabled()) { httpSender.setAttribute(AuthTrustVerifier.ID_PROVIDERNAME, requestServiceId); } // Start sending the request to server proxies. The underlying // SSLConnectionSocketFactory will select the fastest address // (socket that connects first) from the provided addresses. // Dummy service address is only needed so that host name resolving // could do its thing and start the ssl connection. URI[] addresses = getServiceAddresses(requestServiceId, requestSoap.getSecurityServer()); httpSender.setAttribute(ID_TARGETS, addresses); httpSender.setTimeout(SystemProperties.getClientProxyTimeout()); httpSender.addHeader(HEADER_HASH_ALGO_ID, getHashAlgoId()); httpSender.addHeader(HEADER_PROXY_VERSION, ProxyMain.getVersion()); try { httpSender.doPost( getDummyServiceAddress(addresses), reqIns, CHUNKED_LENGTH, outputContentType); } catch (Exception e) { // Failed to connect to server proxy MonitorAgent.serverProxyFailed(createRequestMessageInfo()); // Rethrow throw e; } } finally { if (reqIns != null) { reqIns.close(); } } }
public void closePipedInputStream() throws IOException { pIn.close(); }