use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class DataSerializableSerializer method readInternal.
private DataSerializable readInternal(ObjectDataInput in, Class aClass) throws IOException {
DataSerializable ds = null;
if (null != aClass) {
try {
ds = (DataSerializable) aClass.newInstance();
} catch (Exception e) {
throw new HazelcastSerializationException("Requested class " + aClass + " could not be instantiated.", e);
}
}
final byte header = in.readByte();
int id = 0;
int factoryId = 0;
String className = null;
try {
// BasicOperationService::extractOperationCallId
if (isFlagSet(header, IDS_FLAG)) {
factoryId = in.readInt();
final DataSerializableFactory dsf = factories.get(factoryId);
if (dsf == null) {
throw new HazelcastSerializationException("No DataSerializerFactory registered for namespace: " + factoryId);
}
id = in.readInt();
if (null == aClass) {
ds = dsf.create(id);
if (ds == null) {
throw new HazelcastSerializationException(dsf + " is not be able to create an instance for id: " + id + " on factoryId: " + factoryId);
}
}
} else {
className = in.readUTF();
if (null == aClass) {
ds = ClassLoaderUtil.newInstance(in.getClassLoader(), className);
}
}
if (isFlagSet(header, EE_FLAG)) {
in.readByte();
in.readByte();
}
ds.readData(in);
return ds;
} catch (Exception e) {
throw rethrowReadException(id, factoryId, className, e);
}
}
use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class PortableNavigatorContext method initFinalPositionAndOffset.
/**
* Initialises the finalPosition and offset and validates the fieldCount against the given class definition
*/
private void initFinalPositionAndOffset(BufferObjectDataInput in, ClassDefinition cd) {
int fieldCount;
try {
// final position after portable is read
finalPosition = in.readInt();
fieldCount = in.readInt();
} catch (IOException e) {
throw new HazelcastSerializationException(e);
}
if (fieldCount != cd.getFieldCount()) {
throw new IllegalStateException("Field count[" + fieldCount + "] in stream does not match " + cd);
}
offset = in.position();
}
Aggregations