/** * Write this remote exception cause to the given stream, without using serialization. * * @param output the output stream (must not be {@code null}) * @throws IOException if an error occurs writing the data */ public void writeToStream(DataOutput output) throws IOException { Assert.checkNotNullParam("output", output); writeToStream(output, new IdentityIntMap<Object>(), new HashMap<String,String>(), 0); }
private int writeThrowable(final DataOutput output, final Throwable throwable, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, final int cnt) throws IOException { if (throwable == null) { output.write(ST_NULL); return cnt; } else { final int idx = seen.get(throwable, - 1); final int distance = cnt - idx; if (idx == - 1 || distance >= 0x4000) { RemoteExceptionCause nested; if (throwable instanceof RemoteExceptionCause) { nested = (RemoteExceptionCause) throwable; } else { seen.put(throwable, cnt); // do not increment yet nested = of(throwable); } return nested.writeToStream(output, seen, stringCache, cnt); // this will increment it } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e, int errorCode) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); dos.writeInt(errorCode); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
/** * Write this remote exception cause to the given stream, without using serialization. * * @param output the output stream (must not be {@code null}) * @throws IOException if an error occurs writing the data */ public void writeToStream(DataOutput output) throws IOException { Assert.checkNotNullParam("output", output); writeToStream(output, new IdentityIntMap<Object>(), new HashMap<String,String>(), 0); }
/** * Write this remote exception cause to the given stream, without using serialization. * * @param output the output stream (must not be {@code null}) * @throws IOException if an error occurs writing the data */ public void writeToStream(DataOutput output) throws IOException { Assert.checkNotNullParam("output", output); writeToStream(output, new IdentityIntMap<Object>(), new HashMap<String,String>(), 0); }
private int writeThrowable(final DataOutput output, final Throwable throwable, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, final int cnt) throws IOException { if (throwable == null) { output.write(ST_NULL); return cnt; } else { final int idx = seen.get(throwable, - 1); final int distance = cnt - idx; if (idx == - 1 || distance >= 0x4000) { RemoteExceptionCause nested; if (throwable instanceof RemoteExceptionCause) { nested = (RemoteExceptionCause) throwable; } else { seen.put(throwable, cnt); // do not increment yet nested = of(throwable); } return nested.writeToStream(output, seen, stringCache, cnt); // this will increment it } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } } }
private int writeThrowable(final DataOutput output, final Throwable throwable, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, final int cnt) throws IOException { if (throwable == null) { output.write(ST_NULL); return cnt; } else { final int idx = seen.get(throwable, - 1); final int distance = cnt - idx; if (idx == - 1 || distance >= 0x4000) { RemoteExceptionCause nested; if (throwable instanceof RemoteExceptionCause) { nested = (RemoteExceptionCause) throwable; } else { seen.put(throwable, cnt); // do not increment yet nested = of(throwable); } return nested.writeToStream(output, seen, stringCache, cnt); // this will increment it } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e, int errorCode) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); dos.writeInt(errorCode); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e, int errorCode) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); dos.writeInt(errorCode); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }