Skip to content

Commit

Permalink
🔧 fix: 修复 CaptchaController.java 文件中的异常处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed May 30, 2024
1 parent 433f399 commit 090a3fb
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public Mono<ResponseEntity<DataBuffer>> getCaptcha(ServerWebExchange exchange) {
.publishOn(Schedulers.boundedElastic()).flatMap(captchaToken -> {
try (OutputStream outputStream = dataBuffer.asOutputStream()) {
outputStream.write(captchaToken.getCaptcha().getBytes());
return Mono.just(ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(dataBuffer))
.delayUntil((a) -> this.captchaTokenRepository.saveToken(exchange, captchaToken));
} catch (IOException e) {
return Mono.just(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.contentType(MediaType.TEXT_PLAIN)
.body(dataBuffer.read(e.getMessage().getBytes(StandardCharsets.UTF_8))));
}
});
return Mono.just(ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(dataBuffer))
.delayUntil((a) -> this.captchaTokenRepository.saveToken(exchange, captchaToken));
} catch (IOException e) {
return Mono.just(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.contentType(MediaType.TEXT_PLAIN)
.body(dataBuffer.read(e.getMessage().getBytes(StandardCharsets.UTF_8))));
}
});
}

}

0 comments on commit 090a3fb

Please sign in to comment.