Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean isDjpDisconnected() {
- CompletableFuture<String> timeStamp = djpService.getTimeStamp();
- try {
- return timeStamp.get(3, TimeUnit.SECONDS).isEmpty();
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- log.warn("DJP connection can't be established", e.getCause());
- // dari sonar saranin handlenya gini
- // Thread.currentThread().interrupt();
- // tapi masalahnya exceptionnya itu kena di async thread punya si completableFuture,
- // bukan di thread yang manggil method isDjpDisconnected() ini
- // si async thread completableFuture jadinya masih di interruptedException, alias ngegantung gitu
- // ga pernah masuk ke .handle() maupun .whenComplete()
- return true;
- }
- }
- @Override
- public CompletableFuture<String> getTimeStamp() {
- return CompletableFuture
- .supplyAsync(() -> postRequest(
- djpGatewayConfig.getTimestampPath(),
- null,
- String.class
- ), taskExecutor)
- // ga masuk ke handle() sini waktu 3 exception di atas kejadian
- .handle(mappingError("getTimeStamp"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement