Source:
<code>public Change insert() throws OrmException, IOException { ReviewDb db = dbProvider.get(); db.changes().beginTransaction(change.getId()); try { ChangeUtil.insertAncestors(db, patchSet.getId(), commit); db.patchSets().insert(Collections.singleton(patchSet)); db.changes().insert(Collections.singleton(change)); ChangeUtil.updateTrackingIds(db, change, trackingFooters, commit.getFooterLines()); LabelTypes labelTypes = refControl.getProjectControl().getLabelTypes(); approvalsUtil.addReviewers(db, labelTypes, change, patchSet, patchSetInfo, reviewers, Collections.<Account.Id> emptySet()); db.commit(); } finally { db.rollback(); } if (changeMessage != null) { db.changeMessages().insert(Collections.singleton(changeMessage)); } final CheckedFuture<Boolean, IOException> mergeableFuture = mergeabilityChecker.updateAsync(change); <START> mergeableFuture.addListener(new Runnable() { <END> @Override public void run() { try { if (!mergeableFuture.checkedGet()) { indexer.index(change); } } catch (IOException e) { log.error("Failed to update mergeable flag for change " + change.getChangeId(), e); throw new RuntimeException(e); } } }, MoreExecutors.sameThreadExecutor()); gitRefUpdated.fire(change.getProject(), patchSet.getRefName(), ObjectId.zeroId(), commit); if (runHooks) { hooks.doPatchsetCreatedHook(change, patchSet, db); } if (sendMail) { try { CreateChangeSender cm = createChangeSenderFactory.create(change); cm.setFrom(change.getOwner()); cm.setPatchSet(patchSet, patchSetInfo); cm.addReviewers(reviewers); cm.addExtraCC(extraCC); cm.send(); } catch (Exception err) { log.error("Cannot send email for new change " + change.getId(), err); } } try { mergeableFuture.checkedGet(); } catch (IOException e) { indexer.index(change); throw e; } return change; }</code><technical_language>Instead of a listener a chained future: Futures.chain(mergeabilityChecker.updateAsnc, new Function<>). This allows propagate exception function indexing caller thread line 219 wanted to</technical_language>

Target:
public Change insert() throws OrmException, IOException { ReviewDb db = dbProvider.get(); db.changes().beginTransaction(change.getId()); try { ChangeUtil.insertAncestors(db, patchSet.getId(), commit); db.patchSets().insert(Collections.singleton(patchSet)); db.changes().insert(Collections.singleton(change)); ChangeUtil.updateTrackingIds(db, change, trackingFooters, commit.getFooterLines()); LabelTypes labelTypes = refControl.getProjectControl().getLabelTypes(); approvalsUtil.addReviewers(db, labelTypes, change, patchSet, patchSetInfo, reviewers, Collections.<Account.Id> emptySet()); db.commit(); } finally { db.rollback(); } if (changeMessage != null) { db.changeMessages().insert(Collections.singleton(changeMessage)); } CheckedFuture<?, IOException> f = mergeabilityChecker.updateAndIndexAsync(change); gitRefUpdated.fire(change.getProject(), patchSet.getRefName(), ObjectId.zeroId(), commit); if (runHooks) { hooks.doPatchsetCreatedHook(change, patchSet, db); } if (sendMail) { try { CreateChangeSender cm = createChangeSenderFactory.create(change); cm.setFrom(change.getOwner()); cm.setPatchSet(patchSet, patchSetInfo); cm.addReviewers(reviewers); cm.addExtraCC(extraCC); cm.send(); } catch (Exception err) { log.error("Cannot send email for new change " + change.getId(), err); } } f.checkedGet(); return change; }