Fix checkstyle in Kryo{IO,Input,Output}Pool
[controller.git] / atomix-storage / src / main / java / io / atomix / utils / serializer / KryoOutputPool.java
index 6b1737fd12942e06c4fb90243a611a6a821a8bdd..e77316c932f4eec79944faf14e68a3372a6e1f48 100644 (file)
  */
 package io.atomix.utils.serializer;
 
-class KryoOutputPool extends KryoIOPool<ByteArrayOutput> {
+final class KryoOutputPool extends KryoIOPool<ByteArrayOutput> {
+    private static final int MAX_BUFFER_SIZE = 768 * 1024;
+    static final int MAX_POOLED_BUFFER_SIZE = 512 * 1024;
 
-  private static final int MAX_BUFFER_SIZE = 768 * 1024;
-  static final int MAX_POOLED_BUFFER_SIZE = 512 * 1024;
-
-  @Override
-  protected ByteArrayOutput create(int bufferSize) {
-    return new ByteArrayOutput(bufferSize, MAX_BUFFER_SIZE, new BufferAwareByteArrayOutputStream(bufferSize));
-  }
+    @Override
+    ByteArrayOutput create(final int bufferSize) {
+        return new ByteArrayOutput(bufferSize, MAX_BUFFER_SIZE, new BufferAwareByteArrayOutputStream(bufferSize));
+    }
 
-  @Override
-  protected boolean recycle(ByteArrayOutput output) {
-    if (output.getByteArrayOutputStream().getBufferSize() < MAX_POOLED_BUFFER_SIZE) {
-      output.getByteArrayOutputStream().reset();
-      output.clear();
-      return true;
+    @Override
+    boolean recycle(final ByteArrayOutput output) {
+        final var baos = output.getByteArrayOutputStream();
+        if (baos.getBufferSize() >= MAX_POOLED_BUFFER_SIZE) {
+            // discard
+            return false;
+        }
+        baos.reset();
+        output.clear();
+        return true;
     }
-    return false; // discard
-  }
 }