Fix FlexibleThreadPoolWrapper checkstyle
[controller.git] / opendaylight / config / threadpool-config-impl / src / main / java / org / opendaylight / controller / config / threadpool / util / FlexibleThreadPoolWrapper.java
index 9949e36d3714f55b6936e66d3d596ef9a5b9b96c..6fb1adcb699c7056776961b27b67ab5346b54ec7 100644 (file)
@@ -52,9 +52,8 @@ public class FlexibleThreadPoolWrapper implements ThreadPool, Closeable {
      * This impl saturates threadpool first, then queue. When both are full caller will get blocked.
      */
     private static ForwardingBlockingQueue getQueue(final OptionalInt capacity) {
-        final BlockingQueue<Runnable> delegate = capacity.isPresent() ? new LinkedBlockingQueue<>(capacity.getAsInt())
-                : new LinkedBlockingQueue<>();
-        return new ForwardingBlockingQueue(delegate);
+        return new ForwardingBlockingQueue(
+            capacity.isPresent() ? new LinkedBlockingQueue<>(capacity.orElseThrow()) : new LinkedBlockingQueue<>());
     }
 
     @Override
@@ -103,7 +102,7 @@ public class FlexibleThreadPoolWrapper implements ThreadPool, Closeable {
     /**
      * if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
      */
-    private static class FlexibleRejectionHandler implements RejectedExecutionHandler {
+    private static final class FlexibleRejectionHandler implements RejectedExecutionHandler {
         @Override
         @SuppressWarnings("checkstyle:parameterName")
         public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
@@ -115,7 +114,7 @@ public class FlexibleThreadPoolWrapper implements ThreadPool, Closeable {
         }
     }
 
-    private static class ForwardingBlockingQueue
+    private static final class ForwardingBlockingQueue
             extends com.google.common.util.concurrent.ForwardingBlockingQueue<Runnable> {
         private final BlockingQueue<Runnable> delegate;