We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 76bde6c commit fe1eecfCopy full SHA for fe1eecf
src/main/java/com/programmers/springweekly/repository/voucher/MemoryVoucherRepository.java
@@ -30,9 +30,12 @@ public void update(Voucher voucher) {
30
31
@Override
32
public Optional<Voucher> findById(UUID voucherId) {
33
- Voucher voucher = voucherMap.get(voucherId);
34
-
35
- return Optional.ofNullable(voucher);
+ try {
+ Voucher voucher = voucherMap.get(voucherId);
+ return Optional.of(voucher);
36
+ } catch (NullPointerException e) {
37
+ return Optional.empty();
38
+ }
39
}
40
41
0 commit comments