use of java.io.ObjectInputStream in project carat by amplab.
the class CaratDataStorage method readObject.
public Object readObject(String fname) {
FileInputStream fin = getFin(fname);
if (fin == null)
return null;
try {
ObjectInputStream din = new ObjectInputStream(fin);
Object o = din.readObject();
din.close();
return o;
} catch (IOException e) {
Log.e(this.getClass().getName(), "Could not read object from " + fname + "!");
e.printStackTrace();
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getName(), "Could not find class: " + e.getMessage() + " reading from " + fname + "!");
e.printStackTrace();
} catch (Throwable th) {
Log.e(this.getClass().getName(), "Problem reading object", th);
}
return null;
}
use of java.io.ObjectInputStream in project camel by apache.
the class RabbitMQMessageConverter method deserializeBody.
private void deserializeBody(final Exchange camelExchange, final Message message, final byte[] body) {
Object messageBody = null;
try (InputStream b = new ByteArrayInputStream(body);
ObjectInputStream o = new ObjectInputStream(b)) {
messageBody = o.readObject();
} catch (IOException | ClassNotFoundException e) {
LOG.warn("Could not deserialize the object");
camelExchange.setException(e);
}
if (messageBody instanceof Throwable) {
LOG.debug("Reply was an Exception. Setting the Exception on the Exchange");
camelExchange.setException((Throwable) messageBody);
} else {
message.setBody(messageBody);
}
}
use of java.io.ObjectInputStream in project jstorm by alibaba.
the class AutoTGT method getTGT.
public static KerberosTicket getTGT(Map<String, String> credentials) {
KerberosTicket ret = null;
if (credentials != null && credentials.containsKey("TGT")) {
try {
ByteArrayInputStream bin = new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(credentials.get("TGT")));
ObjectInputStream in = new ObjectInputStream(bin);
ret = (KerberosTicket) in.readObject();
in.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return ret;
}
use of java.io.ObjectInputStream in project flink by apache.
the class FileSerializableStateHandle method getState.
@Override
@SuppressWarnings("unchecked")
public T getState(ClassLoader classLoader) throws Exception {
ensureNotClosed();
try (FSDataInputStream inStream = getFileSystem().open(getFilePath())) {
// make sure any deserialization can be aborted
registerCloseable(inStream);
ObjectInputStream ois = new MigrationInstantiationUtil.ClassLoaderObjectInputStream(inStream, classLoader);
return (T) ois.readObject();
}
}
use of java.io.ObjectInputStream in project flink by apache.
the class KeyedOneInputStreamOperatorTestHarness method restore.
/**
*
*/
@Override
public void restore(StreamStateHandle snapshot) throws Exception {
try (FSDataInputStream inStream = snapshot.openInputStream()) {
if (operator instanceof StreamCheckpointedOperator) {
((StreamCheckpointedOperator) operator).restoreState(inStream);
}
byte keyedStatePresent = (byte) inStream.read();
if (keyedStatePresent == 1) {
ObjectInputStream ois = new ObjectInputStream(inStream);
this.restoredKeyedState = Collections.singletonList((KeyGroupsStateHandle) ois.readObject());
}
}
}
Aggregations