@@ -0,0 +1,3001 @@
+package org.mapdb;%0A%0Aimport org.junit.Test;%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Aimport static org.junit.Assert.assertTrue;%0A%0Apublic class Issue164Test %7B%0A%0A    public static class Scenario implements Serializable %7B%0A        private static final long serialVersionUID = 1L;%0A        protected String id = null;%0A        protected String brief = null;%0A        protected String headNodeId = null;%0A        protected HashSet nodeIdSet = null;%0A        public Scenario() %7B%0A            id = Long.toHexString(System.nanoTime());%0A            brief = null;%0A            headNodeId = null;%0A            nodeIdSet = null;%0A        %7D%0A        public void setId(String arg_id) %7B%0A            synchronized(this) %7B%0A                id = arg_id;%0A            %7D%0A        %7D%0A        public String getId() %7B%0A            synchronized(this) %7B%0A                return id;%0A            %7D%0A        %7D%0A        public void setBrief(String arg_brief) %7B%0A            synchronized(this) %7B%0A                brief = arg_brief;%0A            %7D%0A        %7D%0A        public String getBrief() %7B%0A            synchronized(this) %7B%0A                return brief;%0A            %7D%0A        %7D%0A        public String getHeadNodeId() %7B%0A            synchronized(this) %7B%0A                return headNodeId;%0A            %7D%0A        %7D%0A        public void setHeadNodeId(String arg_header_node_id) %7B%0A            synchronized(this) %7B%0A                headNodeId = arg_header_node_id;%0A                if (!nodeIdSet.contains(arg_header_node_id))%0A                    nodeIdSet.add(arg_header_node_id);%0A            %7D%0A        %7D%0A        public void addConversationNodeId(String arg_conversation_node_id) throws Exception %7B%0A            synchronized(this) %7B%0A                if (headNodeId == null) %7B%0A                    headNodeId = arg_conversation_node_id;%0A                    nodeIdSet.add(arg_conversation_node_id);%0A                %7D%0A                else%0A                    throw new Exception();%0A            %7D // of synchronized(this)%0A        %7D%0A        public void removeConversationNodeId(String arg_conversation_node_id) %7B%0A            synchronized(this) %7B%0A                if (headNodeId != null) %7B%0A                    nodeIdSet.remove(arg_conversation_node_id);%0A                    if (arg_conversation_node_id.equals(headNodeId))%0A                        headNodeId = null; // the set is empty now%0A                %7D%0A            %7D // of synchronized(this)%0A        %7D%0A    %7D%0A%0A%0A    @Test%0A    public void main() %7B%0A        int rc = 0;%0A        BTreeMap map=null;%0A        try %7B%0A            DB db = DBMaker.newMemoryDB()%0A                    .closeOnJvmShutdown()%0A                    .make();%0A// the following test shows that the db is opened if it always exists%0A            map = db.getTreeMap(%22test%22);%0A            if (!map.containsKey(%22t1%22)) %7B%0A                map.put(%22t1%22, new Scenario());%0A                db.commit();%0A            %7D%0A            rc = 1;%0A        %7D catch(Exception ex) %7B%0A            rc = -1;%0A        %7D%0A        assertTrue(map.get(%22t1%22)!=null);%0A        assertTrue(rc %3E 0);%0A%0A    %7D%0A%7D

Add test case for #164