File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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) {
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 ) {
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments