Skip to content

Commit 462b581

Browse files
ohbusiluwatar
andauthored
clearing Sonar Blockers (iluwatar#1633)
* update gitignore .checkstyle files are being tracked which should not be * NOSONAR for statement excluded from SONAR analysis as it is already dealt using functional approach https://sonarcloud.io/project/issues?id=iluwatar_java-design-patterns&issues=AW8FwRBhm8eoEVQR-x0f&open=AW8FwRBhm8eoEVQR-x0f * achieved thread safety with lazy initialization https://sonarcloud.io/project/issues?fileUuids=AXb6t0PKusn4P8Tm-LmM&id=iluwatar_java-design-patterns&open=AXb6t19yusn4P8Tm-Lmo&resolved=false * remove double checked locking and initialize before using https://sonarcloud.io/project/issues?fileUuids=AXb6t0PKusn4P8Tm-LmK&id=iluwatar_java-design-patterns&open=AXb6t19qusn4P8Tm-Lmk&resolved=false * NOSONAR for the line https://sonarcloud.io/project/issues?id=iluwatar_java-design-patterns&issues=AXPd3iSe46HRSze7cz3D&open=AXPd3iSe46HRSze7cz3D Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
1 parent 9abfd57 commit 462b581

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

dao/src/main/java/com/iluwatar/dao/DbCustomerDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public DbCustomerDao(DataSource dataSource) {
6767
public Stream<Customer> getAll() throws Exception {
6868
try {
6969
var connection = getConnection();
70-
var statement = connection.prepareStatement("SELECT * FROM CUSTOMERS");
70+
var statement = connection.prepareStatement("SELECT * FROM CUSTOMERS"); // NOSONAR
7171
var resultSet = statement.executeQuery(); // NOSONAR
7272
return StreamSupport.stream(new Spliterators.AbstractSpliterator<Customer>(Long.MAX_VALUE,
7373
Spliterator.ORDERED) {

special-case/src/main/java/com/iluwatar/specialcase/Db.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ public class Db {
3838
*
3939
* @return singleton instance of Db class
4040
*/
41-
public static Db getInstance() {
41+
public static synchronized Db getInstance() {
4242
if (instance == null) {
43-
synchronized (Db.class) {
44-
if (instance == null) {
45-
instance = new Db();
46-
instance.userName2User = new HashMap<>();
47-
instance.user2Account = new HashMap<>();
48-
instance.itemName2Product = new HashMap<>();
49-
}
50-
}
43+
Db newInstance = new Db();
44+
newInstance.userName2User = new HashMap<>();
45+
newInstance.user2Account = new HashMap<>();
46+
newInstance.itemName2Product = new HashMap<>();
47+
instance = newInstance;
5148
}
5249
return instance;
5350
}

special-case/src/main/java/com/iluwatar/specialcase/MaintenanceLock.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ public class MaintenanceLock {
3838
*
3939
* @return singleton instance of MaintenanceLock
4040
*/
41-
public static MaintenanceLock getInstance() {
41+
public static synchronized MaintenanceLock getInstance() {
4242
if (instance == null) {
43-
synchronized (MaintenanceLock.class) {
44-
if (instance == null) {
45-
instance = new MaintenanceLock();
46-
}
47-
}
43+
instance = new MaintenanceLock();
4844
}
4945
return instance;
5046
}
@@ -55,6 +51,6 @@ public boolean isLock() {
5551

5652
public void setLock(boolean lock) {
5753
this.lock = lock;
58-
LOGGER.info("Maintenance lock is set to: " + lock);
54+
LOGGER.info("Maintenance lock is set to: ", lock);
5955
}
6056
}

transaction-script/src/main/java/com/iluwatar/transactionscript/HotelDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public HotelDaoImpl(DataSource dataSource) {
4949
public Stream<Room> getAll() throws Exception {
5050
try {
5151
var connection = getConnection();
52-
var statement = connection.prepareStatement("SELECT * FROM ROOMS");
52+
var statement = connection.prepareStatement("SELECT * FROM ROOMS"); // NOSONAR
5353
var resultSet = statement.executeQuery(); // NOSONAR
5454
return StreamSupport.stream(new Spliterators.AbstractSpliterator<Room>(Long.MAX_VALUE,
5555
Spliterator.ORDERED) {

0 commit comments

Comments
 (0)