Today I stumbled upon a very strange behaviour of some Java code, and I do not have any clue about the why.
I am parsing the response (text) file from the “tell traveler show user” command.
The response file is written to the system temp directory and contains all information that you would also see when you invoke the command on the server console. No problem so far.
The response file contains a section that lists all mail file replicas for the user.
IBM Traveler has validated that it can access the database mail/ukrause.nsf.
Monitoring of the database for changes is enabled.
Encrypting, decrypting and signing messages are enabled because the Notes ID is in the mail file or the ID vault.
Canonical Name: CN=Ulrich Krause/O=singultus
Internet Address: ulrich.krause@eknori.de
Home Mail Server: CN=serv01/O=singultus
Home Mail File: mail/ukrause.nsf
Current Monitor Server: CN=serv01/O=singultus Release 9.0.1FP8
Current Monitor File: mail/ukrause.nsf
Mail File Replicas:
[CN=serv02/O=singultus, mail/ukrause.nsf] is reachable.
ACL for Ulrich Krause/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
ACL for serv01/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
[CN=serv01/O=singultus, mail/ukrause.nsf] is reachable.
ACL for Ulrich Krause/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
ACL for serv01/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
Notes ID: Mail File contains the Notes ID which was last updated by CN=serv01/O=singultus on Tuesday, June 16, 2015 1:09:16 PM CEST.
If a server for a replica is down or not reachable the output looks like this
IBM Traveler has validated that it can access the database mail/ukrause.nsf.
Monitoring of the database for changes is enabled.
Encrypting, decrypting and signing messages are enabled because the Notes ID is in the mail file or the ID vault.
Canonical Name: CN=Ulrich Krause/O=singultus
Internet Address: ulrich.krause@eknori.de
Home Mail Server: CN=serv01/O=singultus
Home Mail File: mail/ukrause.nsf
Current Monitor Server: CN=serv01/O=singultus Release 9.0.1FP8
Current Monitor File: mail/ukrause.nsf
Mail File Replicas:
[CN=serv01/O=singultus, mail/ukrause.nsf] is reachable.
ACL for Ulrich Krause/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
ACL for serv01/singultus: Access=Manager Capabilities=create,update,read,delete,copy Missing Capabilities=none
[CN=serv02/O=singultus, mail/ukrause.nsf] is not reachable, status(0x807) “The server is not responding. The server may be down or you may be experiencing network problems. Contact your system administrator if this problem persists.”.
Notes ID: Mail File contains the Notes ID which was last updated by CN=serv01/O=singultus on Tuesday, June 16, 2015 1:09:16 PM CEST.
Here is the code fragment that I use to parse the response file. I am using a LineIterator.
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
public class UserFileParser {
private String filename;
private LineIterator lineIterator;
public void process() {
try {
lineIterator = FileUtils.lineIterator(new File(filename));
while (lineIterator.hasNext()) {
String line = lineIterator.nextLine().trim();
System.out.println(line);
The expected behaviour is that the code will print every line inside the response file to the server console. So far for the theory.
BUT … the code behaves different if the response file contains information about not reachable replicas or not.
I have tested the code in Eclipse on a Windows 10 client without any issues. The problem only exists on the server when the code is executed from within a DOTS task.
If the response file lists all replicas as reachable, the code works as expected. I can see all lines printed to the console.
If the response file contains information about a replica that is not reachable, the code stops after reading
Current Monitor File: mail/ukrause.nsf
It does not get to
Mail File Replicas:
By the way, it does not make any difference, if I use any other kind of reader.
I have changed my code to
public void process() {
String line = "";
try {
br = new BufferedReader(new FileReader(new File(filename)));
while ((line = br.readLine().trim()) != null) {
System.out.println(line);
lines.add(line);
Now I get a NullPointerException, but also the code stops at exact the same line in the response file. I all replicas are reachable, no NPE.
java.lang.NullPointerException
at de.eknori.dots.provider.parser.UserFileParser.process(UserFileParser.java:65)
I have already investigated the 2 response files for hidden characters and stuff, but cannot see anything that would explain this behaviour.
From the data in the response file you can see that I have FP8 (Beta) installed; I have not yet checked with FP7, but I expect the same weirdness.
U P D A T E:
FP7 shows the same behaviour.
I have tried reading the file char by char
Reader reader = new InputStreamReader(new FileInputStream(filename), "UTF-8");
Integer i;
while ((i = reader.read()) != -1) {
System.out.println(i);
}
and, indeed, there is a -1 value for i in the middle of the file.
105
99
97
115
58
32
13
10
-1
So, no surprise, that all readers stop to read past this char.