Skip to content

Commit

Permalink
If serialization fails when serializing a throwable, then log it befo…
Browse files Browse the repository at this point in the history
…re it is discarded.
  • Loading branch information
tommyk-gears committed May 3, 2024
1 parent 4002193 commit 77e859f
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.hazelcast.internal.serialization.InternalSerializationService;
import com.hazelcast.internal.serialization.SerializableByConvention;
import com.hazelcast.internal.util.collection.PartitionIdSet;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.ByteArraySerializer;
Expand Down Expand Up @@ -61,6 +63,8 @@ public final class SerializationUtil {

static final PartitioningStrategy<?> EMPTY_PARTITIONING_STRATEGY = new EmptyPartitioningStrategy();

private static final ILogger LOGGER = Logger.getLogger(SerializationUtil.class);

private SerializationUtil() {
}

Expand Down Expand Up @@ -129,6 +133,10 @@ static RuntimeException handleSerializeException(Object rootObject, Throwable e)
return exception;
}
String clazz = rootObject == null ? "null" : rootObject.getClass().getName();
if (rootObject instanceof Throwable throwable) {
LOGGER.warning("Failed to serialize '" + clazz + "'. It will be logged here and "
+ "then ignored and replaced with a HazelcastSerializationException.", throwable);
}
return new HazelcastSerializationException("Failed to serialize '" + clazz + '\'', e);
}

Expand Down

0 comments on commit 77e859f

Please sign in to comment.