Java Code Examples for java.nio.channels.ClosedChannelException#printStackTrace()

The following examples show how to use java.nio.channels.ClosedChannelException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NioTest.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@Override
public void doTask(final Task task) {
    if (task.getType() == Task.Type.CONNECT) {
        LOGGER.info("Client: Received CONNECT task");
        try {
            LOGGER.info("Sending data to server");
            task.getLink().send(getTestBytes());
        } catch (ClosedChannelException e) {
            LOGGER.error(e.getMessage());
            e.printStackTrace();
        }
    } else if (task.getType() == Task.Type.DATA) {
        LOGGER.info("Client: Received DATA task");
    } else if (task.getType() == Task.Type.DISCONNECT) {
        LOGGER.info("Client: Received DISCONNECT task");
        stopClient();
    } else if (task.getType() == Task.Type.OTHER) {
        LOGGER.info("Client: Received OTHER task");
    }
}
 
Example 2
Source File: ReactorEchoServerV1.java    From new-bull with MIT License 5 votes vote down vote up
public void register(SelectableChannel channel, int ops, Handler handler) {
    try {
        channel.register(selector, ops, handler);
    } catch (ClosedChannelException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: FileIEngineImpl.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private void unlockSession() throws IOException {
    try {
        lock.release();
    } catch (ClosedChannelException e) {
        e.printStackTrace();
    }
    oLock.close();
    fLock.delete();
}
 
Example 4
Source File: HTTPReadHandler.java    From AdditionsAPI with MIT License 5 votes vote down vote up
private void sendResponse(SelectionKey selectionKey, HTTPResponse response)
{
	try
	{
		server.writePool.getLightest().register(selectionKey.channel(), response);
	}
	catch (ClosedChannelException e)
	{
		this.closeChannel(selectionKey);
		e.printStackTrace();
	}
}
 
Example 5
Source File: NioTest.java    From cosmic with Apache License 2.0 5 votes vote down vote up
public void testConnection() {
    _testBytes = new byte[1000000];
    randomGenerator.nextBytes(_testBytes);
    try {
        getOneMoreTest();
        _clientLink.send(_testBytes);
        s_logger.info("Client: Data sent");
        getOneMoreTest();
        _clientLink.send(_testBytes);
        s_logger.info("Client: Data sent");
    } catch (final ClosedChannelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}