#vulnerable code 
                             public <T> Iterable<Key<T>> insert(Iterable<T> entities, WriteConcern wc) {
		ArrayList<DBObject> ents = entities instanceof List ? new ArrayList<DBObject>(((List<T>)entities).size()) : new ArrayList<DBObject>();

		Map<Object, DBObject> involvedObjects = new LinkedHashMap<Object, DBObject>();
		T lastEntity = null;
		for (T ent : entities) {
			ents.add(entityToDBObj(ent, involvedObjects));
			lastEntity = ent;
		}
		
		DBCollection dbColl = getCollection(lastEntity);
		WriteResult wr = null;
		
		DBObject[] dbObjs = new DBObject[ents.size()];
		dbColl.insert(ents.toArray(dbObjs), wc);
		
		throwOnError(wc, wr);
		
		ArrayList<Key<T>> savedKeys = new ArrayList<Key<T>>();
		Iterator<T> entitiesIT = entities.iterator();
		Iterator<DBObject> dbObjsIT = ents.iterator();
		
		while (entitiesIT.hasNext()) {
			T entity = entitiesIT.next();
			DBObject dbObj = dbObjsIT.next();
			savedKeys.add(postSaveGetKey(entity, dbObj, dbColl, involvedObjects));
		}
		
		return savedKeys;
	} 
                            #location 15 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             public <T> Iterable<Key<T>> insert(Iterable<T> entities, WriteConcern wc) {
		//TODO: Do this without creating another iterator
		DBCollection dbColl = getCollection(entities.iterator().next());
		return insert(dbColl, entities, wc);
	}