From 89b6d07bfc4f1a218b608141781911e042f3ca21 Mon Sep 17 00:00:00 2001 From: pierantoniomerlino Date: Tue, 3 Sep 2024 16:19:40 +0200 Subject: [PATCH] Fixed some sonar issues Signed-off-by: pierantoniomerlino --- .../internal/db/h2db/provider/H2DbHelper.java | 4 +++- .../db/h2db/provider/H2DbServiceImpl.java | 4 +++- .../db/h2db/provider/H2DbServiceOptions.java | 22 +++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java index d451e02445e..8df309e72e2 100644 --- a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbHelper.java @@ -31,7 +31,9 @@ protected void setConfigurationService(ConfigurationService configurationService } protected void unsetConfigurationService(ConfigurationService configurationService) { - this.configurationService = null; + if (this.configurationService.equals(configurationService)) { + this.configurationService = null; + } } private void startDefaultDbServiceInstance() { diff --git a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java index 8bafd1ae2ce..2ce1cabdb44 100644 --- a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceImpl.java @@ -114,7 +114,9 @@ public void setCryptoService(CryptoService cryptoService) { } public void unsetCryptoService(CryptoService cryptoService) { - this.cryptoService = null; + if (this.cryptoService.equals(cryptoService)) { + this.cryptoService = null; + } } // ---------------------------------------------------------------- diff --git a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java index 209d31bd5ad..e033f86cefa 100644 --- a/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java +++ b/kura/org.eclipse.kura.db.h2db.provider/src/main/java/org/eclipse/kura/internal/db/h2db/provider/H2DbServiceOptions.java @@ -106,15 +106,7 @@ private void computeUrlParts() { } } - if ("mem".equals(protocol)) { - this.isInMemory = true; - } else if ("file".equals(protocol)) { - this.isFileBased = true; - } else if ("zip".equals(protocol)) { - this.isZipBased = true; - } else { - this.isRemote = true; - } + parseProtocol(protocol); this.baseUrl = "jdbc:h2:" + protocol + ':' + url; @@ -130,6 +122,18 @@ private void computeUrlParts() { this.isFileBasedLogLevelSpecified = FILE_LOG_LEVEL_PATTERN.matcher(this.dbUrl).find(); } + private void parseProtocol(String protocol) { + if ("mem".equals(protocol)) { + this.isInMemory = true; + } else if ("file".equals(protocol)) { + this.isFileBased = true; + } else if ("zip".equals(protocol)) { + this.isZipBased = true; + } else { + this.isRemote = true; + } + } + public String getDbUrl() { return this.dbUrl; }