text: public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException {Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);for (final IndexCommit ic : commits) {Map<String,String> map = ic.getUserData();String ud = null;if (map != null) {ud = map.get(USER_DATA);}if (ud != null && ud.equals(userData)) {return ic;}}throw new IOException("index does not contain commit with userData: " + userData);}