Search in sources :

Example 1 with FailedWriteException

use of org.teiid.transport.ObjectEncoder.FailedWriteException in project teiid by teiid.

the class SocketClientInstance method exceptionOccurred.

public void exceptionOccurred(Throwable t) {
    // Object encoding may fail, so send a specific type of message to indicate there was a problem
    if (objectSocket.isOpen() && !isClosedException(t)) {
        if (workContext.getClientVersion().compareTo(Version.EIGHT_4) >= 0 && t instanceof FailedWriteException) {
            FailedWriteException fwe = (FailedWriteException) t;
            if (fwe.getObject() instanceof Message) {
                Message m = (Message) fwe.getObject();
                if (!(m.getMessageKey() instanceof ExceptionHolder)) {
                    Message exception = new Message();
                    exception.setContents(m.getMessageKey());
                    exception.setMessageKey(new ExceptionHolder(fwe.getCause()));
                    objectSocket.write(exception);
                    LogManager.log(getLevel(t), LogConstants.CTX_TRANSPORT, t, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40113));
                    return;
                }
            }
        }
        if (workContext.getClientVersion().compareTo(Version.EIGHT_6) >= 0) {
            Message exception = new Message();
            exception.setMessageKey(new ExceptionHolder(t));
            objectSocket.write(exception);
            LogManager.log(getLevel(t), LogConstants.CTX_TRANSPORT, t, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40113));
            return;
        }
    }
    int level = getLevel(t);
    LogManager.log(level, LogConstants.CTX_TRANSPORT, LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL) || level < MessageLevel.WARNING ? t : null, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40114, t.getMessage()));
    objectSocket.close();
}
Also used : Message(org.teiid.net.socket.Message) ExceptionHolder(org.teiid.client.util.ExceptionHolder) FailedWriteException(org.teiid.transport.ObjectEncoder.FailedWriteException)

Aggregations

ExceptionHolder (org.teiid.client.util.ExceptionHolder)1 Message (org.teiid.net.socket.Message)1 FailedWriteException (org.teiid.transport.ObjectEncoder.FailedWriteException)1