X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Ftestingservices%2Fthreadpool%2FTestingFixedThreadPoolModule.java;h=8ac0c322231b8d29ed9213b4090280e9ba07d366;hp=464f786e6f61c55ade0b3047b58e95fc43720515;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=2294805f83434db1d248e629767da6a563ce595f diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModule.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModule.java index 464f786e6f..8ac0c32223 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModule.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/TestingFixedThreadPoolModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -27,18 +27,17 @@ public class TestingFixedThreadPoolModule implements private int threadCount = 0; private boolean triggerNewInstanceCreation; - TestingFixedThreadPoolModule(ModuleIdentifier name, - @Nullable AutoCloseable oldCloseable, - @Nullable TestingFixedThreadPool oldInstance) { + TestingFixedThreadPoolModule(final ModuleIdentifier name, + @Nullable final AutoCloseable oldCloseable, + @Nullable final TestingFixedThreadPool oldInstance) { this.name = name; this.oldCloseable = oldCloseable; this.oldInstance = oldInstance; } - // attributes @Override - public void setThreadCount(int threadCount) { + public void setThreadCount(final int threadCount) { this.threadCount = threadCount; } @@ -53,7 +52,7 @@ public class TestingFixedThreadPoolModule implements } @Override - public void setTriggerNewInstanceCreation(boolean triggerNewInstanceCreation) { + public void setTriggerNewInstanceCreation(final boolean triggerNewInstanceCreation) { this.triggerNewInstanceCreation = triggerNewInstanceCreation; } @@ -70,6 +69,12 @@ public class TestingFixedThreadPoolModule implements } @Override + public boolean canReuse(final Module oldModule) { + return isReusable() && triggerNewInstanceCreation == false; + } + + @Override + @SuppressWarnings("IllegalCatch") public Closeable getInstance() { if (instance == null) { if (isReusable() && triggerNewInstanceCreation == false) { // simulate @@ -83,7 +88,7 @@ public class TestingFixedThreadPoolModule implements if (oldCloseable != null) { try { oldCloseable.close(); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } }