Fix new Sonar smell and some other in JMX module (#2716)

* Fix new Sonar smell and some other in JMX module

* * Fix issues after testing
This commit is contained in:
Artem Bilan
2019-01-24 11:55:46 -05:00
committed by Gary Russell
parent bac3565dfd
commit 9ab6779dc2
7 changed files with 350 additions and 277 deletions

View File

@@ -79,18 +79,28 @@ public abstract class IntegrationComponentSpec<S extends IntegrationComponentSpe
}
@Override
protected T createInstance() throws Exception {
protected T createInstance() {
T instance = get();
if (instance instanceof InitializingBean) {
((InitializingBean) instance).afterPropertiesSet();
try {
((InitializingBean) instance).afterPropertiesSet();
}
catch (Exception e) {
throw new IllegalStateException("Cannot initialize bean: " + instance, e);
}
}
return instance;
}
@Override
protected void destroyInstance(T instance) throws Exception {
protected void destroyInstance(T instance) {
if (instance instanceof DisposableBean) {
((DisposableBean) instance).destroy();
try {
((DisposableBean) instance).destroy();
}
catch (Exception e) {
throw new IllegalStateException("Cannot destroy bean: " + instance, e);
}
}
}
@@ -145,7 +155,7 @@ public abstract class IntegrationComponentSpec<S extends IntegrationComponentSpe
}
@SuppressWarnings("unchecked")
protected final S _this() {
protected final S _this() { // NOSONAR
return (S) this;
}