Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public DefaultDeserializer(@Nullable ClassLoader classLoader) {
}


/**
* Return the {@link ClassLoader} to use for deserialization, or {@code null}
* to use the "latest user-defined ClassLoader" of {@link ObjectInputStream}.
* @since 7.1
* @see ConfigurableObjectInputStream#ConfigurableObjectInputStream(InputStream, ClassLoader)
*/
public @Nullable ClassLoader getClassLoader() {
return this.classLoader;
}


/**
* Read from the supplied {@code InputStream} and deserialize the contents
* into an object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ public String deserialize(InputStream inputStream) {
assertThat(deserializer.expectedInputStream).isNotNull();
}

@Test
void defaultDeserializerExposesNullClassLoaderByDefault() {
assertThat(new DefaultDeserializer().getClassLoader()).isNull();
}

@Test
void defaultDeserializerExposesConfiguredClassLoader() {
ClassLoader classLoader = getClass().getClassLoader();
assertThat(new DefaultDeserializer(classLoader).getClassLoader()).isSameAs(classLoader);
}

@Test
void serializationDelegateWithExplicitSerializerAndDeserializer() throws IOException {
SerializationDelegate delegate = new SerializationDelegate(new DefaultSerializer(), new DefaultDeserializer());
Expand Down