I have a Java agent that runs on WebQuerySave. This agent creates a document, saves it, passes it to a LotusScript agent using runWithDocumentContext, then attempts to read the value of a field the LS agent has changed (bascially a success/failure field).
Currently, the Java agent is unable to see the field change. After the runWithDocumentContext, I am recycling the object, setting it to null, and then re-opening it by NoteID. I have done something similar with one LS agent passing a document to another LS agent. In that case, deleting the variable and re-opening it works.
My theory is that Domino hasn't yet recycled the C object by the time I re-open the document, that re-opening it re-uses the old object and cancels the recycle. To test this, I added a Thread.sleep(5000) after the recycle(), to no effect. My guess is that it isn't doing the recycle due to batching.
As per case description, issue seems to be with Java agent and runWithDocumentContext method.
You have mentioned that -->
I have done something similar with one LS agent passing a document to another LS agent. In that case, deleting the variable and re-opening it works.
Can you confirm if in this scenario as well you are using runWithDocumentContext method or not.
If not, then to isolate please check while using runWithDocumentContext method, whether in the Security section of the Properties tab for the Agent, checkbox "Run as Web user" is selected.
If runWithDocumentContext method is being used with LS agent and its working fine, then can you compare the Java and LS agent settings in term of security settings and how they are being triggered.
You are correct that the LS version did not use runWithDocumentContext. I don't believe this method exists in LS. Instead, I was passing the NoteID in the agent's ParameterDocId. I'll rewrite these agents to do it this way and see if it helps.
Run as Web user is not selected in either of these agents.
If rewriting the agent to use ParameterDocId doesn't help, I will see if I can reproduce it with minimal agents using both LS->LS and Java->LS, with the same security settings.
Interestingly enough, I do not need to "Run as Web user" in order to use runWithDocumentContext. Perhaps that issue is only related to XPages, which I am not using here.
Do you recycle the document by calling the recycle method or by setting it to null? In Lotusscript, this works. Not in Java, because the C-API backend needs the recycle method to be called to free the C-API backend object, and setting the pointer to null does not do this.
Investigate https://github.com/OpenNTF/org.openntf.domino or https://github.com/klehmann/domino-jna for efforts to enable using java without (mostly) having to worry about recycle().
I have solved this problem. It turns out that the issue was related to something entirely different.
Specifically, I was setting a date field in the LS child agent, and reading it in the Java parent agent using getItemValueString. I did not realize that getItemValueString returns an empty string for date/time fields.
My parent agent was in fact seeing the updated document all along, I was just reading it incorrectly.