From 2b975cfac04372b7e20ecb916a52c5e8c8dd6bf9 Mon Sep 17 00:00:00 2001 From: Daniel Prueitt Date: Thu, 29 Feb 2024 15:56:25 +0900 Subject: [PATCH] fix(protobuf): Use the current thread classloader when deserializing to pojo. Use the current thread classloader rather than Class.forName when deserializing protobuf to pojo. Closes #186 --- .../deserializers/protobuf/ProtobufWireFormatDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/deserializers/protobuf/ProtobufWireFormatDecoder.java b/serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/deserializers/protobuf/ProtobufWireFormatDecoder.java index 97fbf20c..09a17d33 100644 --- a/serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/deserializers/protobuf/ProtobufWireFormatDecoder.java +++ b/serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/deserializers/protobuf/ProtobufWireFormatDecoder.java @@ -69,7 +69,7 @@ private DynamicMessage deserializeToDynamicMessage(final Descriptors.Descriptor private Object deserializeToPojo(final Descriptors.Descriptor descriptor, final CodedInputStream codedInputStream) { final String className = ProtobufClassName.from(descriptor); try { - final Class classType = Class.forName(className); + final Class classType = Thread.currentThread().getContextClassLoader().loadClass(className); final Method parseMethod = classType.getMethod("parseFrom", CodedInputStream.class); return parseMethod.invoke(classType, codedInputStream); } catch (Exception e) {