Probable race condition involving TGFileStore.fetchInfo() / TextGridObject.getLastModified() on new objects with prepared URIs [was #8831]
Sometimes importing a file fails with a bunch of exceptions that boil down to a ObjectNotFound exception on the new URI and a NullPointerException in TextGridObject.getLastModified(). This does not happen always so I suspect a race condition. I've attached a log file containing the errors and stack traces.
The following steps lead to the problem:
- File -> Import
- Select a target project
- Drop a simple object onto the import field
- Click import
The problem does not occurr always.
What the import process does is
- for each file added to the list, a new TextGridObject instance is created and pre-filled with metadata
- after clicking Import, first a set of URIs is fetched from TG-crud for all new objects (using TextGridObject.fetchURIs)
- then, for each file to import,
- we fix links in the metadata, if applicable
- we use the adapter manager to obtain an IFile for the object associated with the file. To this time, the object is new and has a prepared URI.
- we set the IFile's content, causing it to be written to the Repository.
If I understand the logs correctly, step 3.2 somehow triggers a readMetadata() which tries to read from the prepared URI and fails (ObjectNotFoundFault). After that attempts on getLastModified fail with an NPE since the metadata isn't there.