use of com.esotericsoftware.kryo.KryoException in project apex-core by apache.
the class Journal method setOutputStream.
public void setOutputStream(@Nullable final OutputStream out) throws IOException {
final Output output;
if (out != null) {
output = new Output(4096, -1) {
@Override
public void flush() throws KryoException {
super.flush();
// Kryo does not flush internal output stream during flush. We need to flush it explicitly.
try {
getOutputStream().flush();
} catch (IOException e) {
throw new KryoException(e);
}
}
};
output.setOutputStream(out);
} else {
output = null;
}
final Output oldOut = this.output.getAndSet(output);
if (oldOut != null && oldOut.getOutputStream() != out) {
synchronized (oldOut) {
oldOut.close();
}
}
}
use of com.esotericsoftware.kryo.KryoException in project cas by apereo.
the class CasKryoTranscoderTests method verifyEncodeDecodeNonRegisteredClass.
@Test
public void verifyEncodeDecodeNonRegisteredClass() {
final TicketGrantingTicket tgt = new MockTicketGrantingTicket(USERNAME);
final MockServiceTicket expectedST = new MockServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), tgt);
// This class is not registered with Kryo
final UnregisteredServiceTicketExpirationPolicy step = new UnregisteredServiceTicketExpirationPolicy(1, 600);
expectedST.setExpiration(step);
try {
transcoder.encode(expectedST);
throw new AssertionError("Unregistered class is not allowed by Kryo");
} catch (final KryoException e) {
} catch (final Exception e) {
throw new AssertionError("Unexpected exception due to not resetting Kryo between de-serializations with unregistered class.");
}
}
use of com.esotericsoftware.kryo.KryoException in project apex-malhar by apache.
the class KryoJavaSerializer method read.
@Override
public Object read(Kryo kryo, Input input, Class type) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
if (objectStream == null) {
objectStream = new ObjectInputStreamWithKryoClassLoader(input, kryo);
graphContext.put(this, objectStream);
}
return objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
use of com.esotericsoftware.kryo.KryoException in project flink by apache.
the class NoFetchingInput method readBytes.
@Override
public void readBytes(byte[] bytes, int offset, int count) throws KryoException {
if (bytes == null) {
throw new IllegalArgumentException("bytes cannot be null.");
}
try {
int bytesRead = 0;
int c;
while (true) {
c = inputStream.read(bytes, offset + bytesRead, count - bytesRead);
if (c == -1) {
throw new KryoException(new EOFException("No more bytes left."));
}
bytesRead += c;
if (bytesRead == count) {
break;
}
}
} catch (IOException ex) {
throw new KryoException(ex);
}
}
use of com.esotericsoftware.kryo.KryoException in project flink by apache.
the class JavaSerializer method read.
@SuppressWarnings("unchecked")
@Override
public T read(Kryo kryo, Input input, Class aClass) {
try {
ObjectMap graphContext = kryo.getGraphContext();
ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
if (objectStream == null) {
// make sure we use Kryo's classloader
objectStream = new InstantiationUtil.ClassLoaderObjectInputStream(input, kryo.getClassLoader());
graphContext.put(this, objectStream);
}
return (T) objectStream.readObject();
} catch (Exception ex) {
throw new KryoException("Error during Java deserialization.", ex);
}
}
Aggregations