use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.
the class AbstractSerializationService method toObject.
@Override
public final <T> T toObject(final Object object) {
if (!(object instanceof Data)) {
return (T) object;
}
Data data = (Data) object;
if (isNullData(data)) {
return null;
}
final int typeId = data.getType();
final SerializerAdapter serializer = serializerFor(typeId);
if (serializer == null) {
if (active) {
throw newHazelcastSerializationException(typeId);
}
throw notActiveExceptionSupplier.get();
}
Object obj = null;
BufferPool pool = bufferPoolThreadLocal.get();
BufferObjectDataInput in = pool.takeInputBuffer(data);
try {
ClassLocator.onStartDeserialization();
obj = serializer.read(in);
if (managedContext != null) {
obj = managedContext.initialize(obj);
}
return (T) obj;
} catch (Throwable e) {
throw handleException(e);
} finally {
ClassLocator.onFinishDeserialization();
serializer.conditionallyReturnInputBufferToPool(obj, in, pool);
}
}
use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.
the class PortableSerializer method readAsInternalGenericRecord.
public InternalGenericRecord readAsInternalGenericRecord(ObjectDataInput in) throws IOException {
int factoryId = in.readInt();
int classId = in.readInt();
int version = in.readInt();
BufferObjectDataInput input = (BufferObjectDataInput) in;
ClassDefinition cd = setupPositionAndDefinition(input, factoryId, classId, version);
return new PortableInternalGenericRecord(this, input, cd, true);
}
use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.
the class PortableSerializer method read.
@Override
public Object read(ObjectDataInput in) throws IOException {
if (!(in instanceof BufferObjectDataInput)) {
throw new IllegalArgumentException("ObjectDataInput must be instance of BufferObjectDataInput!");
}
int factoryId = in.readInt();
int classId = in.readInt();
BufferObjectDataInput input = (BufferObjectDataInput) in;
return read(input, factoryId, classId);
}
use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.
the class CompactStreamSerializer method readGenericRecord.
public GenericRecord readGenericRecord(ObjectDataInput in, boolean schemaIncludedInBinary) throws IOException {
Schema schema = getOrReadSchema(in, schemaIncludedInBinary);
BufferObjectDataInput input = (BufferObjectDataInput) in;
return new DefaultCompactReader(this, input, schema, null, schemaIncludedInBinary);
}
use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.
the class AbstractSerializationServiceTest method testReadObject_ServiceInactive.
@Test
public void testReadObject_ServiceInactive() throws Exception {
expectedException.expect(HazelcastInstanceNotActiveException.class);
abstractSerializationService.register(StringBuffer.class, new StringBufferSerializer(false));
Data data = abstractSerializationService.toData(new StringBuffer());
abstractSerializationService.dispose();
BufferObjectDataInput in = abstractSerializationService.createObjectDataInput(data);
in.position(HeapData.TYPE_OFFSET);
abstractSerializationService.readObject(in);
}
Aggregations