This
problem and solution were found by my esteemed colleague Andrew "Andy
C” Cunliffe.
The problem
In Lotus Notes
8.5 java agents that worked fine in past versions was causing server
crashes. Specifically when working with richtextitem class in a java
agent.
The code being effectively this (taken from the
help)
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
RichTextItem rti = (RichTextItem)doc.getFirstItem("Body");
RichTextNavigator rtnav = rti.createNavigator;
rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH);
rti.beginInsert(rtnav);
rti.appendText("Beginning text.");
rti.addNewLine(1);
rti.endInsert();
doc.save(true,true);
} catch(Exception e) {
e.printStackTrace();
}
}
(Quite
distressing that the actual example given in the help causes a server
crash.)
Investigation
Andy, was able to
find that the command beginInsert was causing the crash. This command
has been recently changed it now accepts an optional Boolean argument
that works as below. · true to put the
insertion position at the end of the element ·
false (default) to put the insertion position at the beginning of the
element Now this is the sticking point, in previous notes
versions there was no option and the behaviour of the beginInsert
command was to put the insertion point at the end of the
element.
So you can see they have changed the behaviour
of the command having the new function be the default and the
original function be the alternative function. This was further
exasperated by the realisation that the setting of the optional
argument to true (i.e. to pick the original function) stops the
server crashing.
The Solution
So to
conclude the solution to this problem is to change the beginInsert
command from
rti.beginInsert(rtnav);
to
rti.beginInsert(rtnav
, true);
|
I
can only think that the new "insertion position at the beginning
of the element” is massively resource hungry or not properly
garbage collected. Our more high spec servers were able to survive
this code. While the server in question could only run the code in
"insertion position at the end of the element” mode.
|