ACLEntry, where are thou?

Thursday, July 23, 2015 at 6:05 AM UTC

Yesterday I stumbled upon a nasty thing in the Java Notes API. I had a loop through all ACL enties of a database I wanted to collect and "pimp" with my own class to get a readable info per entry for levels and user types. I also wanted to collect the options for each entry e.g. DBACL_CREATE_DOCUMENTS. My code looked similar to this one:

import lotus.domino.ACL;
import lotus.domino.ACLEntry;
import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;

public class ACLEntryTest {

    public static void main(String[] args) {
        try {
            Session session = NotesFactory.createSession();
            Database db = session.getDatabase("", "names.nsf");
            ACL acl = db.getACL();
            ACLEntry entry = acl.getFirstEntry();

            while (entry != null) {
                // do something with the entry
                System.out.println(entry.getName() + " - " + entry.getLevel());

                // access other ACL infos
                // int options = db.queryAccessPrivileges(entry.getName());

                // get the next one
                entry = acl.getNextEntry(entry);

        } catch (NotesException e) {
        } finally {

Notice the commented line where I access the ACL options for the current entry. This code will run and loop through all entries. If you uncomment the line to get the options the loop will fail after the first entry with this exception:

-Default- - 0
NotesException: Argument has been removed or recycled
    at lotus.domino.local.ACL.getNextEntry(Unknown Source)
    at ACLEntryTest.main(

Where the heck is the entry gone? It seems that the entry object is also used when calling the query method of the database - afterwards the pointer is lost and I get the problem. 

Latest comments to this post

René Winkelmeyer wrote on 23.07.2015, 09:21

Hi Oliver,

it's the ACL that gets recycled (here: newly created for the db object by the queryAccessPrivileges() call), not the entry.

You cannot use that method in an ACL related loop when querying the same database.

-- René





 Link to this comment

Leave a comment right here