public void disconnect () throws IOException { super.disconnect (); reader = null; } protected int getHeaderLength() {
public void disconnect () throws IOException { super.disconnect (); reader = null; }
public void disconnect() throws IOException { super.disconnect(); if (reader != null) reader.close(); reader = null; } }
public void disconnect () throws IOException { super.disconnect (); if (reader != null) reader.close (); reader = null; } }
/** * Issues a disconnect followed by a connect * @exception IOException */ public void reconnect() throws IOException { disconnect(); connect(); } public void setLogger (Logger logger, String realm) {
public ISOResponse process(InputStream in, ClientRequestDetails requestDetails) { ISOResponse res = null; BaseChannel c = null; try { initialize(); ByteArrayOutputStream out = new ByteArrayOutputStream(512); c = channel.getChannel(in, out, requestDetails); List<ISOMsg> mList = new ArrayList<ISOMsg>(); do { ISOMsg m = c.receive(); mList.add(m); } while (HttpWrapperUtil.hasMoreData(c)); logger.debug("Received: expected {} bytes with {} messages.", requestDetails.length, mList.size()); res = new ISOResponse(c, mList, out); for (ISOMsg m : mList) { m.setSource(res); processListeners(m); } } catch (Exception e) { logger.error("Failed to process txn", e); } res.getResponse(requestDetails.getTimeout()); if (c != null) { try { c.disconnect(); } catch (IOException ignore) { } } return res; }
@Test public void testDisconnectWithDefaultSoLingerOption() throws Exception { Socket socket = mockSocket(); when(socketFactory.createSocket(anyString(), anyInt())).thenReturn(socket); BaseChannel rawChannel = new RawChannel(); rawChannel.setSocketFactory(socketFactory); rawChannel.connect(); rawChannel.disconnect(); verify(socket).setSoLinger(true, 5); verify(socket).shutdownOutput(); verify(socket).close(); assertTrue(rawChannel.isSoLingerOn()); assertEquals(5, rawChannel.getSoLingerSeconds()); }
@Test public void testDisconnectWithCustomSoLingerOption() throws Exception { Socket socket = mockSocket(); when(socketFactory.createSocket(anyString(), anyInt())).thenReturn(socket); BaseChannel rawChannel = new RawChannel(); rawChannel.setSocketFactory(socketFactory); rawChannel.setSoLinger(true, 0); rawChannel.connect(); rawChannel.disconnect(); verify(socket).setSoLinger(true, 0); verify(socket).close(); verify(socket, never()).shutdownOutput(); // this does not make sense when sending a TCP RST down the socket assertTrue(rawChannel.isSoLingerOn()); assertEquals(0, rawChannel.getSoLingerSeconds()); }
@Test public void testDisconnect() throws Throwable { BaseChannel rawChannel = new RawChannel(); rawChannel.disconnect(); assertNull("(RawChannel) rawChannel.getSocket()", rawChannel.getSocket()); assertFalse("(RawChannel) rawChannel.usable", ((RawChannel) rawChannel).usable); }
@Test public void testDisconnect1() throws Throwable { ServerSocket sock = new ServerSocket(); BaseChannel cSChannel = new CSChannel(new PostPackager()); cSChannel.setServerSocket(sock); cSChannel.disconnect(); assertSame("(CSChannel) cSChannel.serverSocket", sock, ((CSChannel) cSChannel).serverSocket); assertNull("(CSChannel) cSChannel.getSocket()", cSChannel.getSocket()); assertFalse("(CSChannel) cSChannel.usable", ((CSChannel) cSChannel).usable); }