Why my programming error crashes server?!

Simpe Java agent will crash your server if instead of dbname String parameter it will receive null in getDatabase method.Why?!

For example:

import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {



	try {

		Session session = getSession();

		AgentContext agentContext = session.getAgentContext();

		Database thisdb = agentContext.getCurrentDatabase();

		String server = thisdb.getServer();		

		

		System.out.println("before getDatabase");



		String dbname = ...//somehow you receive null here

		Database thatdb = session.getDatabase(server, dbname);



		System.out.println("after getDatabase");

	

	} catch(Exception e) {

		e.printStackTrace();

	}

}

}

Is it expected Domino behaviour?

Regards,

Y.M.

Subject: Why my programming error crashes server?!

The server should not crash, but the agent should fail with a NullPointerException. I suggest you open up a case with IBM with this error.

  • Johan Känngård

http://johankanngard.net

Subject: Why my programming error crashes server?!

We got around that problem as we experienced it since Domino 6.0 by doing a verification for nulls. Its pretty simple but has worked good for us. Here is a sample using your code.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {



	try {

		Session session = getSession();

		AgentContext agentContext = session.getAgentContext();

		Database thisdb = agentContext.getCurrentDatabase();

		String server = thisdb.getServer();		

		

		System.out.println("before getDatabase");



		String dbname = ...//somehow you receive null here

                                             if ( dbname == null )

                                                            {

			System.out.println( "Aborted processing due to null values" );

                                                             }

                                            else

                                                             {

		                 Database thatdb = session.getDatabase(server, dbname);

                                                             }

		System.out.println("after getDatabase");

	

	} catch(Exception e) {

		e.printStackTrace();

	}

}

}