From 1d72a60844fdd75250f09f74fd493485092026fe Mon Sep 17 00:00:00 2001 From: Thomas Heigl Date: Wed, 26 May 2021 11:35:12 +0200 Subject: [PATCH] #829 Wrap allocation errors in `KryoException` when reading and writing fields --- .../esotericsoftware/kryo/serializers/FieldSerializer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/esotericsoftware/kryo/serializers/FieldSerializer.java b/src/com/esotericsoftware/kryo/serializers/FieldSerializer.java index 25380683f..72c3f3e92 100644 --- a/src/com/esotericsoftware/kryo/serializers/FieldSerializer.java +++ b/src/com/esotericsoftware/kryo/serializers/FieldSerializer.java @@ -108,7 +108,7 @@ public void write (Kryo kryo, Output output, T object) { fields[i].write(output, object); } catch (KryoException e) { throw e; - } catch (Exception e) { + } catch (OutOfMemoryError | Exception e) { throw new KryoException("Error writing " + fields[i] + " at position " + output.position(), e); } } @@ -128,8 +128,8 @@ public T read (Kryo kryo, Input input, Class type) { try { fields[i].read(input, object); } catch (KryoException e) { - throw e; - } catch (Exception e) { + throw e; + } catch (OutOfMemoryError | Exception e) { throw new KryoException("Error reading " + fields[i] + " at position " + input.position(), e); } }