Fix checkstyle in Kryo{IO,Input,Output}Pool
[controller.git] / atomix-storage / src / main / java / io / atomix / utils / serializer / KryoIOPool.java
index 6324631d6ccedc563f1c6015ca9ce436d85749b8..acd33e5194c53c6fdd3ee7aaeefac8519d5b9df5 100644 (file)
@@ -20,32 +20,31 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.function.Function;
 
 abstract class KryoIOPool<T> {
+    private final ConcurrentLinkedQueue<SoftReference<T>> queue = new ConcurrentLinkedQueue<>();
 
-  private final ConcurrentLinkedQueue<SoftReference<T>> queue = new ConcurrentLinkedQueue<>();
-
-  private T borrow(final int bufferSize) {
-    T element;
-    SoftReference<T> reference;
-    while ((reference = queue.poll()) != null) {
-      if ((element = reference.get()) != null) {
-        return element;
-      }
+    private T borrow(final int bufferSize) {
+        T element;
+        SoftReference<T> reference;
+        while ((reference = queue.poll()) != null) {
+            if ((element = reference.get()) != null) {
+                return element;
+            }
+        }
+        return create(bufferSize);
     }
-    return create(bufferSize);
-  }
 
-  protected abstract T create(final int bufferSize);
+    abstract T create(int bufferSize);
 
-  protected abstract boolean recycle(final T element);
+    abstract boolean recycle(T element);
 
-  <R> R run(final Function<T, R> function, final int bufferSize) {
-    final T element = borrow(bufferSize);
-    try {
-      return function.apply(element);
-    } finally {
-      if (recycle(element)) {
-        queue.offer(new SoftReference<>(element));
-      }
+    <R> R run(final Function<T, R> function, final int bufferSize) {
+        final T element = borrow(bufferSize);
+        try {
+            return function.apply(element);
+        } finally {
+            if (recycle(element)) {
+                queue.offer(new SoftReference<>(element));
+            }
+        }
     }
-  }
 }