Skip to content

CSV connector: update and delete fail on a thread whose interrupt flag is set #199

Closed

Description

@vharseko

I found this while reviewing #198, which avoids the same call in the XML connector. Line references are to 95c8375.

Since #131, CSVFileConnector.finishRewrite syncs the rewritten copy with FileChannel.open(tmp, WRITE).force(true) (CSVFileConnector.java#L1353-L1354). force checks the thread's interrupt flag. If the flag is set, force closes the channel and throws ClosedByInterruptException. finishRewrite catches that as an IOException, deletes the copy and throws ConnectorIOException: Failed to replace <csv> with its rewritten copy (L1386-L1388). As a result, every update, addAttributeValues, removeAttributeValues and delete on such a thread fails, and the CSV file is left as it was. Before #131 these operations wrote the copy with FileWriter, which ignores the flag, so they succeeded.

Reproduced on 95c8375 with a TestNG test in org.forgerock.openicf.csvfile. The setup is the same as RewriteSafetyTest, and the test calls Thread.currentThread().interrupt() before connector.update(...) or connector.delete(...). Both calls fail:

ConnectorIOException: Failed to replace /var/folders/.../accounts.csv with its rewritten copy
Caused by: java.nio.channels.ClosedByInterruptException

The interrupt flag is still set afterwards.

The copy could be synced through its own stream instead: FileOutputStream.getFD().sync(), after the writer is flushed and before it is closed. FileDescriptor.sync() does not check the flag; #198 switched XmlDocumentWriter.write to it for this reason. The directory sync (syncDirectory, L1404-L1406) uses FileChannel.force too. It is best effort and logs a failure only at ok, so on such a thread the rename is skipped silently instead of being made durable.

Activity

  1. added
    bug
    connector:csvfile
    on Oct 20, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. added 2 commits that reference this issue on Oct 28, 2026
  4. added a commit that references this issue on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconnector:csvfile

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions