Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log non-serialisable exception before it is discarded #26323

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 "
Comment on lines +136 to +137
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
if (rootObject instanceof Throwable throwable) {
LOGGER.warning("Failed to serialize '" + clazz + "'. It will be logged here and "
if (rootObject instanceof Throwable throwable) {
LOGGER.warning("Failed to serialize throwable '" + 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