/** * {@inheritDoc} */ @Override public T read(ByteBuffer binary) throws ClassNotFoundException, SerializerException { try { try (ObjectInputStream oin = getObjectInputStream(new ByteBufferInputStream(binary))) { @SuppressWarnings("unchecked") T value = (T) oin.readObject(); return value; } } catch (IOException e) { throw new SerializerException(e); } }
@SuppressWarnings("unchecked") @Override public T read(ByteBuffer entry) throws SerializerException, ClassNotFoundException { ByteBufferInputStream bin = new ByteBufferInputStream(entry); try { try (OIS ois = new OIS(bin, classLoader)) { return (T) ois.readObject(); } } catch (IOException e) { throw new SerializerException(e); } finally { try { bin.close(); } catch (IOException e) { throw new AssertionError(e); } } }
private ByteBufferInputStream createStream(boolean prePad, boolean postPad) { int prePadSize = prePad ? RANDOM.nextInt(32) : 0; int postPadSize = postPad ? RANDOM.nextInt(32) : 0; ByteBuffer buffer = ByteBuffer.allocate(64 + prePadSize + postPadSize); for (int i = 0; i < 64; i++) { buffer.put(i + prePadSize, (byte) i); } ByteBufferInputStream bin = new ByteBufferInputStream(buffer); for (int i = 0; i < prePadSize; i++) { assertThat(bin.read(), is(0)); } return bin; } }
@Override public SoftLock<T> read(ByteBuffer entry) throws SerializerException, ClassNotFoundException { ByteBufferInputStream bin = new ByteBufferInputStream(entry); try { try (OIS ois = new OIS(bin, classLoader)) { return uncheckedCast(ois.readObject()); } } catch (IOException e) { throw new SerializerException(e); } finally { try { bin.close(); } catch (IOException e) { throw new AssertionError(e); } } }
@SuppressWarnings("unchecked") @Override public T read(ByteBuffer entry) throws SerializerException, ClassNotFoundException { ByteBufferInputStream bin = new ByteBufferInputStream(entry); try { try (OIS ois = new OIS(bin, classLoader)) { return (T) ois.readObject(); } } catch (IOException e) { throw new SerializerException(e); } finally { try { bin.close(); } catch (IOException e) { throw new AssertionError(e); } } }
@SuppressWarnings("unchecked") @Override public T read(ByteBuffer entry) throws SerializerException, ClassNotFoundException { ByteBufferInputStream bin = new ByteBufferInputStream(entry); try { try (OIS ois = new OIS(bin, classLoader)) { return (T) ois.readObject(); } } catch (IOException e) { throw new SerializerException(e); } finally { try { bin.close(); } catch (IOException e) { throw new AssertionError(e); } } }