Skip to content

Commit

Permalink
Fix ErrorProne warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Sep 12, 2024
1 parent 1e1dbba commit a466f69
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/test/java/edu/hm/hafner/util/SerializableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class SerializableTest<T extends Serializable> extends ResourceT
@Test
@DisplayName("should be serializable: instance -> byte array -> instance")
void shouldBeSerializable() {
T serializableInstance = createSerializable();
var serializableInstance = createSerializable();

var bytes = toByteArray(serializableInstance);

Expand Down Expand Up @@ -84,16 +84,13 @@ protected void assertThatRestoredInstanceEqualsOriginalInstance(final T original
*/
@SuppressWarnings({"unchecked", "BanSerializableRead"})
protected T restore(final byte[] serializedInstance) {
Object object;

try (var inputStream = new ObjectInputStream(new ByteArrayInputStream(serializedInstance))) {
object = inputStream.readObject();
var object = inputStream.readObject();
return (T) object;
}
catch (IOException | ClassNotFoundException e) {
throw new AssertionError("Can't resolve instance from byte array", e);
}

return (T) object;
}

/**
Expand Down

0 comments on commit a466f69

Please sign in to comment.