Java Code Examples for org.apache.thrift.protocol.TProtocolException#SIZE_LIMIT

The following examples show how to use org.apache.thrift.protocol.TProtocolException#SIZE_LIMIT . 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: MappedFileTBinaryProtocol.java    From singer with Apache License 2.0 5 votes vote down vote up
private void checkStringReadLength(int length) throws TProtocolException {
  if (length < 0) {
    throw new TProtocolException(TProtocolException.NEGATIVE_SIZE, "Negative length: " + length);
  }
  if (stringLengthLimit != NO_LENGTH_LIMIT && length > stringLengthLimit) {
    throw new TProtocolException(TProtocolException.SIZE_LIMIT,
        "Length exceeded max allowed: " + length);
  }
}
 
Example 2
Source File: MappedFileTBinaryProtocol.java    From singer with Apache License 2.0 5 votes vote down vote up
private void checkContainerReadLength(int length) throws TProtocolException {
  if (length < 0) {
    throw new TProtocolException(TProtocolException.NEGATIVE_SIZE, "Negative length: " + length);
  }
  if (containerLengthLimit != NO_LENGTH_LIMIT && length > containerLengthLimit) {
    throw new TProtocolException(TProtocolException.SIZE_LIMIT,
        "Length exceeded max allowed: " + length);
  }
}
 
Example 3
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getExceptionString(Throwable t) {
  String typeMessage = null;
  if (t instanceof TTransportException) {
    TTransportException tte = (TTransportException)t;
    switch (tte.getType()) {
      case TTransportException.ALREADY_OPEN:
        typeMessage = "SOCKET ALREADY OPEN";
        break;
      case TTransportException.END_OF_FILE:
        typeMessage = "SOCKET END OF TRANSMISSION";
        break;
      case TTransportException.NOT_OPEN:
        typeMessage = "SOCKET NOT OPEN";
        break;
      case TTransportException.TIMED_OUT:
        typeMessage = "SOCKET TIMED OUT";
        break;
      default:
        typeMessage = "UNKNOWN SOCKET ERROR";
        break;
    }
  }
  else if (t instanceof TProtocolException) {
    TProtocolException tpe = (TProtocolException)t;
    switch (tpe.getType()) {
      case TProtocolException.BAD_VERSION:
        typeMessage = "BAD PROTOCOL VERSION";
        break;
      case TProtocolException.INVALID_DATA:
        typeMessage = "INVALID DATA IN PROTOCOL";
        break;
      case TProtocolException.NEGATIVE_SIZE:
        typeMessage = "NEGATIVE SIZE IN PROTOCOL";
        break;
      case TProtocolException.NOT_IMPLEMENTED:
        typeMessage = "NOT IMPLEMENTED";
        break;
      case TProtocolException.SIZE_LIMIT:
        typeMessage = "PROTOCOL SIZE LIMIT HIT";
        break;
      default:
        typeMessage = "UNKNOWN PROTOCOL ERROR";
        break;
    }
  }
  else if (t instanceof TApplicationException) {
    TApplicationException tae = (TApplicationException)t;
    switch (tae.getType()) {
      case TApplicationException.BAD_SEQUENCE_ID:
        typeMessage = "BAD SEQUENCE ID";
        break;
      case TApplicationException.INTERNAL_ERROR:
        typeMessage = "INTERNAL ERROR";
        break;
      case TApplicationException.INVALID_MESSAGE_TYPE:
        typeMessage = "INVALID MESSAGE TYPE";
        break;
      case TApplicationException.MISSING_RESULT:
        typeMessage = "MISSING RESULT";
        break;
      case TApplicationException.PROTOCOL_ERROR:
        typeMessage = "PROTOCOL ERROR";
        break;
      case TApplicationException.UNKNOWN_METHOD:
        typeMessage = "UNKNOWN METHOD";
        break;
      case TApplicationException.WRONG_METHOD_NAME:
        typeMessage = "WRONG METHOD NAME";
        break;
      default:
        typeMessage = "UNKNOWN APPLICATION ERROR";
        break;
    }
  }
  String message = t.getLocalizedMessage();
  if (message == null || message.length() == 0) {
    message = t.getClass().getName();
  }
  if (typeMessage != null) {
    return message + " [" + typeMessage + ']';
  }
  else {
    return message;
  }
}
 
Example 4
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getExceptionString(Throwable t) {
  String typeMessage = null;
  if (t instanceof TTransportException) {
    TTransportException tte = (TTransportException)t;
    switch (tte.getType()) {
      case TTransportException.ALREADY_OPEN:
        typeMessage = "SOCKET ALREADY OPEN";
        break;
      case TTransportException.END_OF_FILE:
        typeMessage = "SOCKET END OF TRANSMISSION";
        break;
      case TTransportException.NOT_OPEN:
        typeMessage = "SOCKET NOT OPEN";
        break;
      case TTransportException.TIMED_OUT:
        typeMessage = "SOCKET TIMED OUT";
        break;
      default:
        typeMessage = "UNKNOWN SOCKET ERROR";
        break;
    }
  }
  else if (t instanceof TProtocolException) {
    TProtocolException tpe = (TProtocolException)t;
    switch (tpe.getType()) {
      case TProtocolException.BAD_VERSION:
        typeMessage = "BAD PROTOCOL VERSION";
        break;
      case TProtocolException.INVALID_DATA:
        typeMessage = "INVALID DATA IN PROTOCOL";
        break;
      case TProtocolException.NEGATIVE_SIZE:
        typeMessage = "NEGATIVE SIZE IN PROTOCOL";
        break;
      case TProtocolException.NOT_IMPLEMENTED:
        typeMessage = "NOT IMPLEMENTED";
        break;
      case TProtocolException.SIZE_LIMIT:
        typeMessage = "PROTOCOL SIZE LIMIT HIT";
        break;
      default:
        typeMessage = "UNKNOWN PROTOCOL ERROR";
        break;
    }
  }
  else if (t instanceof TApplicationException) {
    TApplicationException tae = (TApplicationException)t;
    switch (tae.getType()) {
      case TApplicationException.BAD_SEQUENCE_ID:
        typeMessage = "BAD SEQUENCE ID";
        break;
      case TApplicationException.INTERNAL_ERROR:
        typeMessage = "INTERNAL ERROR";
        break;
      case TApplicationException.INVALID_MESSAGE_TYPE:
        typeMessage = "INVALID MESSAGE TYPE";
        break;
      case TApplicationException.MISSING_RESULT:
        typeMessage = "MISSING RESULT";
        break;
      case TApplicationException.PROTOCOL_ERROR:
        typeMessage = "PROTOCOL ERROR";
        break;
      case TApplicationException.UNKNOWN_METHOD:
        typeMessage = "UNKNOWN METHOD";
        break;
      case TApplicationException.WRONG_METHOD_NAME:
        typeMessage = "WRONG METHOD NAME";
        break;
      default:
        typeMessage = "UNKNOWN APPLICATION ERROR";
        break;
    }
  }
  String message = t.getLocalizedMessage();
  if (message == null || message.length() == 0) {
    message = t.getClass().getName();
  }
  if (typeMessage != null) {
    return message + " [" + typeMessage + ']';
  }
  else {
    return message;
  }
}