@Override public int read(byte[] bytes, int off, int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, address); } }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { return wrapped.read(buf, off, len); }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { return wrapped.read(buf, off, len); }
/** * Read in the root node if it has not yet been read. */ private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
private boolean fillTokenizer() { try { int length = trans.read(buf, 0, buf.length); if (length <= 0) { tokenizer = new StringTokenizer("", separator, true); return false; } String row; try { row = Text.decode(buf, 0, length); } catch (CharacterCodingException e) { throw new RuntimeException(e); } tokenizer = new StringTokenizer(row, separator, true); } catch (TTransportException e) { if(e.getType() == TTransportException.END_OF_FILE){ tokenizer = new StringTokenizer("", separator, true); return false; } tokenizer = null; throw new RuntimeException(e); } return true; }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { return wrapped.read(buf, off, len); }
@Override public int read() throws IOException { try { byte[] buf = new byte[1]; transport.read(buf, 0, 1); return buf[0]; } catch (TTransportException e) { throw new IOException(e); } }
@Override public int read(byte b[], int off, int len) throws IOException { try { return transport.read(b, off, len); } catch (TTransportException e) { throw new IOException(e); } } }
@Override public int read(byte[] arg0, int arg1, int arg2) throws TTransportException { try { ioCount++; return wrappedTransport.read(arg0, arg1, arg2); } catch (TTransportException tte) { sawError(); throw tte; } finally { ioCount++; } }
/** * Guarantees that all of len bytes are actually read off the transport. * * @param buf Array to read into * @param off Index to start reading at * @param len Maximum number of bytes to read * @return The number of bytes actually read, which must be equal to len * @throws TTransportException if there was an error reading data */ public int readAll(byte[] buf, int off, int len) throws TTransportException { int got = 0; int ret = 0; while (got < len) { ret = read(buf, off+got, len-got); if (ret <= 0) { throw new TTransportException( "Cannot read. Remote side has closed. Tried to read " + len + " bytes, but only got " + got + " bytes. (This is often indicative of an internal error on the server side. Please check your server logs.)"); } got += ret; } return got; }
byte[] buffer = new byte[1024 * 100]; int n = 0; while ((n = transport.read(buffer, 0, buffer.length)) > 0) { response.append(new String(buffer, 0, n, UTF_8));
@Override public int read(final byte[] bytes, final int off, final int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, host); } }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { return inputTransport.read(buf, off, len); }
@Override public int read(final byte[] bytes, final int off, final int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, host); } }
@Override public int read(byte[] bytes, int off, int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, address); } }
@Override public int read(byte[] bytes, int off, int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, host); } }
@Override public int read(byte[] bytes, int off, int len) throws IOException { try { return trans.read(bytes, off, len); } catch (TTransportException e) { throw new IOException(e); } } }
@Override public int read(byte[] arg0, int arg1, int arg2) throws TTransportException { try { ioCount++; return wrappedTransport.read(arg0, arg1, arg2); } catch (TTransportException tte) { sawError(tte); throw tte; } finally { ioCount++; } }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { if (!mTransport.isOpen()) { throw new TTransportException("transport is not open"); } return mTransport.read(buf, off, len); }
@Override public int read(byte[] buf, int off, int len) throws TTransportException { if (!isOpen()) { throw new TTransportException("transport is not open: " + mTransport); } return mTransport.read(buf, off, len); }