Java RichTextItem AppendText Method Crashes or Causes a Red Box and Hang when String Value Parameter is Null
I've not run into this myself, but I see how it could easily ruin your day if you did... :-) From the KnowledgeBase...
Java RichTextItem AppendText Method Crashes or Causes a Red Box and Hang when String Value Parameter is Null
Document Number:
1111025
Problem
Calling the Java appendString method
(of the RichTextItem class) with a null String value parameter results
in either a Red Box and hang or a crash.
In the case where the Notes Client hangs,
the following Red Box error appears beforehand:
"Sorry, an uncorrectable error
has occurred.
LookupHandle: null handle
Press ENTER to abort the application"
When the system crashes, the Fatal Thread
will be one of the following:
(Note: the first example can occur on
a Notes client or Domino server, the second example has only been observed
on a Domino server)
jvm._IBM_GetInterface
or
nnotes._Panic
nnotes._LockHandle
nnotes._OSLockObject
nlsxbe.ANotes::ANUnicodeToLMBCSLong
nlsxbe._Java_lotus_domino_local_RichTextItem_NappendText
The crash issue where the single fatal
thread entry jvm._IBM_GetInterface is observed occurs in Notes 6.0 and
6.0.1 when the String value parameter passed is derived from a field, for
example when using the getItemValueString method (of the Document class).
For example:
string2 = udoc.getItemValueString("somefield");
ubody.appendText(string2);
The Red Box hang and crash issue containing the fatal thread entry nlsxbe._Java_lotus_domino_local_RichTextItem_NappendText
is observed in Notes 6.x when the parameter is derived from a String object
which is derived using the substring method (it is unknown if the issue
will also occur when the String is based on values returned by other methods).
For example:
string1 = stuff.substring(0, 0);
ubody.appendText(string1);
Content
This issue has been reported to Lotus
software Quality Engineering in two separate Software Problem Reports (SPRs):
SPR TDON5M6NBH
covers the portion of the issue where getTextItemString was used to provide
the string value and the appendText call resulted in a crash. This
issue has been addressed in Notes/Domino 6.0.2.
Excerpt from the Lotus Notes and
Domino Release 6.0.2 MR fix list (available at http://www.ibm.com/developerworks/lotus):
Java
- SPR# TDON5M6NBH - Fixed a server crash when the Java RichTextItem class executed the appendText method with a NULL parameter.
SPR MKIN5XETBB covers the portion of the issue where the string value was derived from the substring method and the appendText call resulted in a Red Box error and a system hang.
Workaround:
In order to avoid these issues, add a check to first see if the returned string value is null (this avoids the issue in SPR TDON5M6NBH) and then check if the value is a length of 0 (this avoids the issue in SPR MKIN5XETBB).
For example:
if (stringx != null) {
if (stringx.length() != 0) {
ubody.appendText(stringx);
}
}
Supporting Information:
Here is a full example of the code that recreates the issue described in SPR MKIN5XETBB:
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
String stuffx = "123";
String string1 = null;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Document uMemo = db.createDocument();
RichTextItem ubody = uMemo.createRichTextItem("Body");
string1 = stuffx.substring(0, 0);
ubody.appendText(string1);
} catch(Exception e) {
e.printStackTrace();
}
}
}



Comments
Posted by null At 08:40:58 On 27/02/2008 | - Website - |