Skip to content

⚡ Bolt: 파일 존재 여부 검사(Files.exists) 제거로 I/O 성능 향상 및 TOCTOU 방지#190

Open
seonghobae wants to merge 1 commit into
mainfrom
bolt-remove-files-exists-checks-6588370891570200557
Open

⚡ Bolt: 파일 존재 여부 검사(Files.exists) 제거로 I/O 성능 향상 및 TOCTOU 방지#190
seonghobae wants to merge 1 commit into
mainfrom
bolt-remove-files-exists-checks-6588370891570200557

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: Files.exists() 호출을 제거하고 NoSuchFileException 예외 처리로 대체했습니다.
🎯 Why: 파일을 읽기 전에 Files.exists()를 호출하면 디스크 I/O가 2번 발생하며, 검사와 사용 사이에 파일 상태가 변경될 수 있는 TOCTOU 취약점이 존재하기 때문입니다.
📊 Impact: 디스크 I/O 횟수 1회 감소(파일 미존재 시 빠른 반환은 예외 처리로 대체), TOCTOU 경쟁 조건 방지.
🔬 Measurement: 단위 테스트를 실행하여 정상 동작 여부를 확인했습니다.


PR created automatically by Jules for task 6588370891570200557 started by @seonghobae

파일을 읽기 직전에 `Files.exists()`를 호출하여 존재 여부를 확인하는 로직을 제거하고,
파일을 직접 읽은 후 `NoSuchFileException`을 잡아내어 처리하도록 수정했습니다.
이를 통해 불필요한 디스크 I/O를 줄이고 TOCTOU(Time-Of-Check to Time-Of-Use) 경쟁 조건을 방지합니다.

- `FileSystemArtifactStore.java`: `getPdf` 메서드에서 I/O 성능 향상.
- `KpiSnapshotLedger.java`, `ArtifactLinkLedger.java`: 시작 시 파일 로드 메서드에서 I/O 성능 향상.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 21, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Files.exists() 사전 검사로 인한 추가 디스크 I/O와 TOCTOU(검사-사용 간 경쟁 조건) 가능성을 제거하기 위해, 파일 읽기 시 NoSuchFileException을 처리하는 방식으로 전환한 PR입니다. 파일 기반(옵션) 저장소/레저 로딩 로직에서 “존재 확인 후 사용” 패턴을 없애고 “사용 시도 후 예외 처리”로 일관화합니다.

Changes:

  • FileSystemArtifactStore#getPdf에서 Files.exists() 체크 제거 후 NoSuchFileExceptionOptional.empty()로 처리
  • ArtifactLinkLedger#load, KpiSnapshotLedger#load에서 Files.exists() 체크 제거 후 NoSuchFileException을 무시(빈 레저로 취급)
  • I/O 예외 래핑 메시지 포맷(줄바꿈) 정리

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java PDF 조회 시 exists 사전 검사 제거, 누락 파일은 NoSuchFileException 기반으로 empty 처리
src/main/java/com/clearfolio/viewer/artifact/ArtifactLinkLedger.java 레저 로딩에서 exists 사전 검사 제거, 누락 파일은 로딩 스킵 처리
src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java KPI 레저 로딩에서 exists 사전 검사 제거, 누락 파일은 로딩 스킵 처리

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants