Skip to content

Commit 22b51db

Browse files
committed
BAEL-3855
1 parent 34bfe41 commit 22b51db

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/SingleLock.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,21 @@ protected Supplier<?> putSupplier(Map<String,String> map, int key) {
1616
return (()-> {
1717
try {
1818
lock.lock();
19-
map.put("key" + key, "value" + key);
19+
return map.put("key" + key, "value" + key);
2020
} finally {
2121
lock.unlock();
2222
}
23-
return null;
2423
});
2524
}
2625

2726
protected Supplier<?> getSupplier(Map<String,String> map, int key) {
2827
return (()-> {
2928
try {
3029
lock.lock();
31-
map.get("key" + key);
30+
return map.get("key" + key);
3231
} finally {
3332
lock.unlock();
3433
}
35-
return null;
3634
});
3735
}
3836
}

core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/StripedLock.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ protected Supplier<?> putSupplier(Map<String,String> map, int key) {
1919
Lock lock = stripedLock.get(bucket);
2020
try {
2121
lock.lock();
22-
map.put("key" + key, "value" + key);
22+
return map.put("key" + key, "value" + key);
2323
} finally {
2424
lock.unlock();
2525
}
26-
return null;
2726
});
2827
}
2928

@@ -33,11 +32,10 @@ protected Supplier<?> getSupplier(Map<String,String> map, int key) {
3332
Lock lock = stripedLock.get(bucket);
3433
try {
3534
lock.lock();
36-
map.get("key" + key);
35+
return map.get("key" + key);
3736
} finally {
3837
lock.unlock();
3938
}
40-
return null;
4139
});
4240
}
4341
}

0 commit comments

Comments
 (0)