use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class SerializerHookLoader method load.
private void load() {
try {
final Iterator<SerializerHook> hooks = ServiceLoader.iterator(SerializerHook.class, FACTORY_ID, classLoader);
while (hooks.hasNext()) {
final SerializerHook hook = hooks.next();
final Class serializationType = hook.getSerializationType();
if (serializationType != null) {
serializers.put(serializationType, hook);
}
}
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
if (serializerConfigs != null) {
for (SerializerConfig serializerConfig : serializerConfigs) {
Serializer serializer = serializerConfig.getImplementation();
Class serializationType = serializerConfig.getTypeClass();
if (serializationType == null) {
try {
serializationType = ClassLoaderUtil.loadClass(classLoader, serializerConfig.getTypeClassName());
} catch (ClassNotFoundException e) {
throw new HazelcastSerializationException(e);
}
}
if (serializer == null) {
serializer = createSerializerInstance(serializerConfig, serializationType);
}
register(serializationType, serializer);
}
}
}
use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class AbstractSerializationService method writeObject.
@Override
public final void writeObject(final ObjectDataOutput out, final Object obj) {
if (obj instanceof Data) {
throw new HazelcastSerializationException("Cannot write a Data instance, use writeData() instead");
}
SerializerAdapter serializer = serializerFor(obj, false);
try {
out.writeInt(serializer.getTypeId());
serializer.write(out, obj);
} catch (Throwable e) {
throw handleSerializeException(obj, e);
}
}
use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class Edge method readData.
@Override
public void readData(@Nonnull ObjectDataInput in) throws IOException {
sourceName = in.readUTF();
sourceOrdinal = in.readInt();
destName = in.readUTF();
destOrdinal = in.readInt();
priority = in.readInt();
distributedTo = in.readObject();
routingPolicy = RoutingPolicy.valueOf(in.readString());
config = in.readObject();
try {
partitioner = CustomClassLoadedObject.read(in);
comparator = CustomClassLoadedObject.read(in);
} catch (HazelcastSerializationException e) {
throw new HazelcastSerializationException("Error deserializing edge '" + sourceName + "' -> '" + destName + "': " + e, e);
}
}
use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class StreamEventJournalP method init.
@Override
protected void init(@Nonnull Context context) throws Exception {
@SuppressWarnings("unchecked") CompletableFuture<EventJournalInitialSubscriberState>[] futures = new CompletableFuture[partitionIds.length];
Arrays.setAll(futures, i -> eventJournalReader.subscribeToEventJournal(partitionIds[i]));
for (int i = 0; i < futures.length; i++) {
emitOffsets[i] = readOffsets[i] = getSequence(futures[i].get());
}
if (!isRemoteReader) {
// try to serde projection/predicate to fail fast if they aren't known to IMDG
HazelcastInstanceImpl hzInstance = Util.getHazelcastInstanceImpl(context.hazelcastInstance());
InternalSerializationService ss = hzInstance.getSerializationService();
try {
deserializeWithCustomClassLoader(ss, hzInstance.getClass().getClassLoader(), ss.toData(predicate));
deserializeWithCustomClassLoader(ss, hzInstance.getClass().getClassLoader(), ss.toData(projection));
} catch (HazelcastSerializationException e) {
throw new JetException("The projection or predicate classes are not known to IMDG. It's not enough to " + "add them to the job class path, they must be deployed using User code deployment: " + e, e);
}
}
}
use of com.hazelcast.nio.serialization.HazelcastSerializationException in project hazelcast by hazelcast.
the class AsyncOperation method doSendResponse.
private void doSendResponse(Object value) {
try {
final JetServiceBackend service = getJetServiceBackend();
service.getLiveOperationRegistry().deregister(this);
} finally {
try {
sendResponse(value);
} catch (Exception e) {
Throwable ex = peel(e);
if (value instanceof Throwable && ex instanceof HazelcastSerializationException) {
// Sometimes exceptions are not serializable, for example on
// https://github.com/hazelcast/hazelcast-jet/issues/1995.
// When sending exception as a response and the serialization fails,
// the response will not be sent and the operation will hang.
// To prevent this from happening, replace the exception with
// another exception that can be serialized.
sendResponse(new JetException(stackTraceToString(ex)));
} else {
throw e;
}
}
}
}
Aggregations