LANG-1722: Rethrow NegativeArraySizeException as SerializationException in SerilizationUtils.deserialize(InputStream) (#1141)
* LANG-1722: Catch NegativeArraySizeException Signed-off-by: Arthur Chan <arthur.chan@adalogics.com> * Fix unit test formatting Signed-off-by: Arthur Chan <arthur.chan@adalogics.com> --------- Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
This commit is contained in:
parent
3760ad0838
commit
c3f5f3204b
|
@ -207,7 +207,7 @@ public class SerializationUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
final T obj = (T) in.readObject();
|
||||
return obj;
|
||||
} catch (final ClassNotFoundException | IOException ex) {
|
||||
} catch (final ClassNotFoundException | IOException | NegativeArraySizeException ex) {
|
||||
throw new SerializationException(ex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,4 +360,13 @@ public class SerializationUtilsTest extends AbstractLangTest {
|
|||
assertThrows(SerializationException.class, () -> SerializationUtils.serialize(iMap, streamTest));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNegativeByteArray() throws IOException {
|
||||
final byte[] byteArray = {
|
||||
(byte) -84, (byte) -19, (byte) 0, (byte) 5, (byte) 125, (byte) -19, (byte) 0,
|
||||
(byte) 5, (byte) 115, (byte) 114, (byte) -1, (byte) 97, (byte) 122, (byte) -48, (byte) -65
|
||||
};
|
||||
|
||||
assertThrows(SerializationException.class, () -> SerializationUtils.deserialize(new ByteArrayInputStream(byteArray)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue