@Override public Object objectFromInputStream(InputStream is) throws IOException, ClassNotFoundException { return marshaller.objectFromInputStream(is); }
@SuppressWarnings("unchecked") private KeyValuePair<ByteBuffer, ByteBuffer> unmarshall(InputStream inputStream) throws PersistenceException { try { return (KeyValuePair<ByteBuffer, ByteBuffer>) marshaller.objectFromInputStream(inputStream); } catch (IOException e) { throw new PersistenceException("I/O error while unmarshalling from stream", e); } catch (ClassNotFoundException e) { throw new PersistenceException(e); } } }
private Map<Object, MarshalledEntry> unmarshallBucketEntries(InputStream inputStream) { try { return (Map<Object, MarshalledEntry>) marshaller.objectFromInputStream(inputStream); } catch (IOException e) { throw new PersistenceException("I/O error while unmarshalling from stream", e); } catch (ClassNotFoundException e) { throw new PersistenceException(e); } } }
@SuppressWarnings("unchecked") private <T> T unmarshall(InputStream inputStream) throws PersistenceException { try { return (T) marshaller.objectFromInputStream(inputStream); } catch (IOException e) { log.ioErrorUnmarshalling(e); throw new PersistenceException("I/O error while unmarshalling from stream", e); } catch (ClassNotFoundException e) { log.unexpectedClassNotFoundException(e); throw new PersistenceException("*UNEXPECTED* ClassNotFoundException. This should not happen as Bucket class exists", e); } }
public void testErrorUnmarshallInputStreamAvailable() throws Exception { byte[] bytes = marshaller.objectToByteBuffer("23"); Object o = marshaller.objectFromInputStream(new ByteArrayInputStream(bytes){ @Override public int available() { return 0; } }); assertEquals("23", o); }