Fix HadoopFs token lock behavior for DBFS filesystem#603
Conversation
WalkthroughThe changes update file utility and locking logic. The file write method now accepts an overwrite flag, file reading is made more robust, and error handling is improved. Lock release synchronization is minimized, and test mocks are adjusted for the new method signature. No core logic or control flow is fundamentally changed. Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (8)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR updates file write behavior by adding an overwrite flag, refines file-reading logic, and corrects token-lock release synchronization to address issues on DBFS.
- Introduces an
overwriteparameter inwriteFileand updates its callers - Changes
readFileto allocate based on actual file size and log read errors - Improves
TokenLockBase.releaseand shutdown hook to track prior acquisition before releasing
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| FsUtils.scala | Added overwrite flag to writeFile, updated callers, improved readFile |
| TokenLockBase.scala | Refined release and shutdown hook synchronization to respect previous state |
| JournalHadoopCsv.scala | Updated write call to pass overwrite = false |
| BookkeeperText.scala | Updated write call to pass overwrite = false |
Comments suppressed due to low confidence (1)
pramen/core/src/main/scala/za/co/absa/pramen/core/utils/FsUtils.scala:322
- [nitpick] Use
StandardCharsets.UTF_8instead of a string literal to avoid typos and improve readability.
new String(content, "UTF-8")
| */ | ||
| def writeFile(filePath: Path, content: String): Unit = { | ||
| val out = fs.create(filePath) | ||
| def writeFile(filePath: Path, content: String, overwrite: Boolean = false): Unit = { |
There was a problem hiding this comment.
Defaulting overwrite to false changes the previous behavior (which always overwrote). Consider setting the default to true or documenting this behavioral change explicitly to avoid unexpected failures.
| def writeFile(filePath: Path, content: String, overwrite: Boolean = false): Unit = { | |
| def writeFile(filePath: Path, content: String, overwrite: Boolean = true): Unit = { |
Unit Test Coverage
Files
|
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests