This is an automated email from the ASF dual-hosted git repository.

edcoleman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit d443a9729e98aaf8086f2605bca431c09074db67
Merge: 7921425c04 0612a2d675
Author: Ed Coleman <edcole...@apache.org>
AuthorDate: Thu Jan 4 20:55:19 2024 +0000

    Merge remote-tracking branch 'upstream/2.1'

 .../main/java/org/apache/accumulo/core/fate/ZooStore.java    | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --cc core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
index c8922a1493,ff7a2971f5..feecda66a7
--- a/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
@@@ -69,15 -69,12 +69,12 @@@ public class ZooStore<T> implements TSt
  
    private byte[] serialize(Object o) {
  
-     try {
-       ByteArrayOutputStream baos = new ByteArrayOutputStream();
-       ObjectOutputStream oos = new ObjectOutputStream(baos);
+     try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+         ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        oos.writeObject(o);
-       oos.close();
- 
        return baos.toByteArray();
      } catch (IOException e) {
 -      throw new RuntimeException(e);
 +      throw new UncheckedIOException(e);
      }
    }
  
@@@ -85,14 -82,11 +82,13 @@@
        justification = "unsafe to store arbitrary serialized objects like 
this, but needed for now"
            + " for backwards compatibility")
    private Object deserialize(byte[] ser) {
-     try {
-       ByteArrayInputStream bais = new ByteArrayInputStream(ser);
-       ObjectInputStream ois = new ObjectInputStream(bais);
+     try (ByteArrayInputStream bais = new ByteArrayInputStream(ser);
+         ObjectInputStream ois = new ObjectInputStream(bais)) {
        return ois.readObject();
 -    } catch (Exception e) {
 -      throw new RuntimeException(e);
 +    } catch (IOException e) {
 +      throw new UncheckedIOException(e);
 +    } catch (ReflectiveOperationException e) {
 +      throw new IllegalStateException(e);
      }
    }
  

Reply via email to