I ran the various tests again.. and here are the steps in a more concise scenario-based descriptions:
Sequences to reproduce issue:
Original file: a.json
[1] open viewer pane to a.json
[2] run program that
--- renames a.json to a.json.backup
--- creates a (now) new file a.json
--- program exits
[3] delete file a.json
[4] try to rename a.json.backup to a.json
==> Fails (file in use]
[5] try to rename a.json.backup to a.json.backup2
--- this actually works
[6] try to then rename a.json.backup2 to a.json
==> this still fails
CONCLUSION: there is a lock on the resource: a.json
The above scenario without the Viewer pane works fine
Scenario:
Original file: a.json
[1] open viewer pane to a.json
[2] run program that
--- renames a.json to a.json.backup
--- creates a (now) new file a.json
--- program exits
[3] CLOSE Viewer pane
[4] delete file a.json
--- this works
Scenario:
Original file: a.json
[1] open viewer pane to a.json
[2] run program that
--- renames a.json to a.json.backup
--- creates a (now) new file a.json
--- program exits
[3] Click on another file in folder so Viewer pane now displays an unrelated file
[4] delete file a.json
==> Fails (file in use)
CONCLUSION: there is a lock on the resource: a.json
=================================
Observation:
!! I don't think this has anything to do with AV
!! I don't think this anything to do with the file extension... it could easily have been a.txt instead of a.json.