Skip to content

Conversation

@NeatGuyCoding
Copy link

Fix writeHeader computation in RollingRandomAccessFileManager

The writeHeader boolean was computed after creating the RandomAccessFile, which creates the file if it doesn't exist. This made file.exists() always return true, causing incorrect header write decisions.

This change captures the file's pre-existing state before opening the RandomAccessFile by:

  • Declaring a fileExistedBefore boolean initialized to false
  • Setting it by checking fileName != null && new File(fileName).exists() before calling new RandomAccessFile(...)
  • Using !fileExistedBefore instead of !file.exists() in the writeHeader calculation

When fileName is null, fileExistedBefore remains false as expected.

@github-actions
Copy link

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

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.

1 participant