You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CSV connector: update and delete fail on a thread whose interrupt flag is set #199
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
[OpenIdentityPlatform#199] Pin that a rewrite whose copy fails to syn…
[OpenIdentityPlatform#199] Assert the interrupt flag after the operat…
[OpenIdentityPlatform#199] Make CSV update and delete succeed on an i…