File tree 4 files changed +11
-18
lines changed
dao/src/main/java/com/iluwatar/dao
special-case/src/main/java/com/iluwatar/specialcase
transaction-script/src/main/java/com/iluwatar/transactionscript
4 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public DbCustomerDao(DataSource dataSource) {
67
67
public Stream <Customer > getAll () throws Exception {
68
68
try {
69
69
var connection = getConnection ();
70
- var statement = connection .prepareStatement ("SELECT * FROM CUSTOMERS" );
70
+ var statement = connection .prepareStatement ("SELECT * FROM CUSTOMERS" ); // NOSONAR
71
71
var resultSet = statement .executeQuery (); // NOSONAR
72
72
return StreamSupport .stream (new Spliterators .AbstractSpliterator <Customer >(Long .MAX_VALUE ,
73
73
Spliterator .ORDERED ) {
Original file line number Diff line number Diff line change @@ -38,16 +38,13 @@ public class Db {
38
38
*
39
39
* @return singleton instance of Db class
40
40
*/
41
- public static Db getInstance () {
41
+ public static synchronized Db getInstance () {
42
42
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 ;
51
48
}
52
49
return instance ;
53
50
}
Original file line number Diff line number Diff line change @@ -38,13 +38,9 @@ public class MaintenanceLock {
38
38
*
39
39
* @return singleton instance of MaintenanceLock
40
40
*/
41
- public static MaintenanceLock getInstance () {
41
+ public static synchronized MaintenanceLock getInstance () {
42
42
if (instance == null ) {
43
- synchronized (MaintenanceLock .class ) {
44
- if (instance == null ) {
45
- instance = new MaintenanceLock ();
46
- }
47
- }
43
+ instance = new MaintenanceLock ();
48
44
}
49
45
return instance ;
50
46
}
@@ -55,6 +51,6 @@ public boolean isLock() {
55
51
56
52
public void setLock (boolean lock ) {
57
53
this .lock = lock ;
58
- LOGGER .info ("Maintenance lock is set to: " + lock );
54
+ LOGGER .info ("Maintenance lock is set to: " , lock );
59
55
}
60
56
}
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public HotelDaoImpl(DataSource dataSource) {
49
49
public Stream <Room > getAll () throws Exception {
50
50
try {
51
51
var connection = getConnection ();
52
- var statement = connection .prepareStatement ("SELECT * FROM ROOMS" );
52
+ var statement = connection .prepareStatement ("SELECT * FROM ROOMS" ); // NOSONAR
53
53
var resultSet = statement .executeQuery (); // NOSONAR
54
54
return StreamSupport .stream (new Spliterators .AbstractSpliterator <Room >(Long .MAX_VALUE ,
55
55
Spliterator .ORDERED ) {
You can’t perform that action at this time.
0 commit comments