/** * Constructs a new BLOB input stream. * * @param wrappedInputStream * the underlying input stream to read from * @param blobKey * the expected BLOB key for content-addressable BLOBs, <code>null</code> for non-content-addressable BLOBs. * @throws IOException * throws if an I/O error occurs while reading the BLOB data from the BLOB server */ BlobInputStream(final InputStream wrappedInputStream, final BlobKey blobKey) throws IOException { this.wrappedInputStream = wrappedInputStream; this.blobKey = blobKey; this.bytesToReceive = readLength(wrappedInputStream); if (this.bytesToReceive < 0) { throw new FileNotFoundException(); } this.md = (blobKey != null) ? BlobUtils.createMessageDigest() : null; }
/** * Reads the key of a BLOB from the given input stream. * * @param buf * auxiliary buffer to data deserialization * @param inputStream * the input stream to read the key from * @return the key of a BLOB * @throws IOException * thrown if an I/O error occurs while reading the key data from the input stream */ private static String readKey(byte[] buf, InputStream inputStream) throws IOException { final int keyLength = readLength(inputStream); if (keyLength > MAX_KEY_LENGTH) { throw new IOException("Unexpected key length " + keyLength); } readFully(inputStream, buf, 0, keyLength, "BlobKey"); return new String(buf, 0, keyLength, BlobUtils.DEFAULT_CHARSET); }
private static Throwable readExceptionFromStream(InputStream in) throws IOException { int len = readLength(in); byte[] bytes = new byte[len]; readFully(in, bytes, 0, len, "Error message"); try { return (Throwable) InstantiationUtil.deserializeObject(bytes, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { // should never occur throw new IOException("Could not transfer error message", e); } } }
/** * Constructs a new BLOB input stream. * * @param wrappedInputStream * the underlying input stream to read from * @param blobKey * the expected BLOB key for content-addressable BLOBs, <code>null</code> for non-content-addressable BLOBs. * @param wrappedOutputStream * the underlying output stream to write the result to * * @throws IOException * throws if an I/O error occurs while reading the BLOB data from the BLOB server */ BlobInputStream( final InputStream wrappedInputStream, final BlobKey blobKey, OutputStream wrappedOutputStream) throws IOException { this.wrappedInputStream = wrappedInputStream; this.blobKey = blobKey; this.wrappedOutputStream = wrappedOutputStream; this.bytesToReceive = readLength(wrappedInputStream); if (this.bytesToReceive < 0) { throw new FileNotFoundException(); } this.md = (blobKey != null) ? BlobUtils.createMessageDigest() : null; }
/** * Constructs a new BLOB input stream. * * @param wrappedInputStream * the underlying input stream to read from * @param blobKey * the expected BLOB key for content-addressable BLOBs, <code>null</code> for non-content-addressable BLOBs. * @param wrappedOutputStream * the underlying output stream to write the result to * * @throws IOException * throws if an I/O error occurs while reading the BLOB data from the BLOB server */ BlobInputStream( final InputStream wrappedInputStream, final BlobKey blobKey, OutputStream wrappedOutputStream) throws IOException { this.wrappedInputStream = wrappedInputStream; this.blobKey = blobKey; this.wrappedOutputStream = wrappedOutputStream; this.bytesToReceive = readLength(wrappedInputStream); if (this.bytesToReceive < 0) { throw new FileNotFoundException(); } this.md = (blobKey != null) ? BlobUtils.createMessageDigest() : null; }
/** * Constructs a new BLOB input stream. * * @param wrappedInputStream * the underlying input stream to read from * @param blobKey * the expected BLOB key for content-addressable BLOBs, <code>null</code> for non-content-addressable BLOBs. * @param wrappedOutputStream * the underlying output stream to write the result to * * @throws IOException * throws if an I/O error occurs while reading the BLOB data from the BLOB server */ BlobInputStream( final InputStream wrappedInputStream, final BlobKey blobKey, OutputStream wrappedOutputStream) throws IOException { this.wrappedInputStream = wrappedInputStream; this.blobKey = blobKey; this.wrappedOutputStream = wrappedOutputStream; this.bytesToReceive = readLength(wrappedInputStream); if (this.bytesToReceive < 0) { throw new FileNotFoundException(); } this.md = (blobKey != null) ? BlobUtils.createMessageDigest() : null; }
/** * Reads exception from given {@link InputStream}. * * @param in the input stream to read from * @return exception that was read * @throws IOException thrown if an I/O error occurs while reading from the input * stream */ static Throwable readExceptionFromStream(InputStream in) throws IOException { int len = readLength(in); byte[] bytes = new byte[len]; readFully(in, bytes, 0, len, "Error message"); try { return (Throwable) InstantiationUtil.deserializeObject(bytes, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { // should never occur throw new IOException("Could not transfer error message", e); } }
/** * Reads exception from given {@link InputStream}. * * @param in the input stream to read from * @return exception that was read * @throws IOException thrown if an I/O error occurs while reading from the input * stream */ static Throwable readExceptionFromStream(InputStream in) throws IOException { int len = readLength(in); byte[] bytes = new byte[len]; readFully(in, bytes, 0, len, "Error message"); try { return (Throwable) InstantiationUtil.deserializeObject(bytes, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { // should never occur throw new IOException("Could not transfer error message", e); } }
/** * Reads exception from given {@link InputStream}. * * @param in the input stream to read from * @return exception that was read * @throws IOException thrown if an I/O error occurs while reading from the input * stream */ static Throwable readExceptionFromStream(InputStream in) throws IOException { int len = readLength(in); byte[] bytes = new byte[len]; readFully(in, bytes, 0, len, "Error message"); try { return (Throwable) InstantiationUtil.deserializeObject(bytes, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { // should never occur throw new IOException("Could not transfer error message", e); } }
final int bytesExpected = readLength(inputStream); if (bytesExpected == -1) {
final int bytesExpected = readLength(inputStream); if (bytesExpected == -1) {
final int bytesExpected = readLength(inputStream); if (bytesExpected == -1) {
final int bytesExpected = readLength(inputStream); if (bytesExpected == -1) {