Skip to content

Commit

Permalink
fix(protobuf): Use the current thread classloader when deserializing …
Browse files Browse the repository at this point in the history
…to pojo.

Use the current thread classloader rather than Class.forName when deserializing protobuf to pojo.

Closes awslabs#186
  • Loading branch information
danprueitt committed Feb 29, 2024
1 parent 8596e42 commit 2b975cf
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2b975cf

Please sign in to comment.