Source:
<code>private void populateStatus(final List<GlusterGeoRepSessionDetails> details) { if(getConfirmWindow() != null) { closeConfirmWindow(); } if(getWindow() != null) { closeWindow(); } final VolumeGeoRepSessionDetailsModel windowModel = new VolumeGeoRepSessionDetailsModel(); windowModel.setHelpTag(HelpTag.geo_replication_status_detail); windowModel.setHashName("geo_replication_status_detail"); final UIConstants constants = ConstantsManager.getInstance().getConstants(); windowModel.setTitle(constants.geoReplicationSessionDetailsTitle()); UICommand okCommand = new UICommand("closeWindow", this); okCommand.setIsCancel(true); okCommand.setTitle(constants.ok()); windowModel.getCommands().add(okCommand); List<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>(); for(GlusterGeoRepSessionDetails detail : details) { queryParamsList.add(new IdQueryParameters(detail.getMasterBrickId())); } final List<EntityModel<GeoRepSessionDetailsSummary>> detailRows = new ArrayList<>(); Frontend.getInstance().runMultipleQueries(Collections.singletonList(VdcQueryType.GetGlusterBrickById), queryParamsList , new IFrontendMultipleQueryAsyncCallback() { @Override public void executed(FrontendMultipleQueryAsyncResult result) { <START> for (VdcQueryReturnValue returnValue : result.getReturnValues()) { for (GlusterGeoRepSessionDetails sessionDetail : details) { <END> GlusterBrickEntity currentBrick = (GlusterBrickEntity) returnValue.getReturnValue(); if (sessionDetail.getMasterBrickId().equals(currentBrick.getId())) { detailRows.add(new EntityModel<VolumeGeoRepSessionDetailsModel.GeoRepSessionDetailsSummary>(new GeoRepSessionDetailsSummary(currentBrick.getServerName(), sessionDetail))); } } } if(detailRows.size() == details.size()) { windowModel.getGeoRepSessionSummary().setItems(detailRows, detailRows.get(0)); setWindow(windowModel); } } }); }</code><technical_language>avoid this nested loop iterating index. Entries in result.getReturnValues in order of queryParameter</technical_language>

Target:
private void populateStatus(final List<GlusterGeoRepSessionDetails> details) { if(getConfirmWindow() != null) { closeConfirmWindow(); } if(getWindow() != null) { closeWindow(); } final VolumeGeoRepSessionDetailsModel windowModel = new VolumeGeoRepSessionDetailsModel(); windowModel.setHelpTag(HelpTag.geo_replication_status_detail); windowModel.setHashName("geo_replication_status_detail"); final UIConstants constants = ConstantsManager.getInstance().getConstants(); windowModel.setTitle(constants.geoReplicationSessionDetailsTitle()); UICommand okCommand = new UICommand("closeWindow", this); okCommand.setIsCancel(true); okCommand.setTitle(constants.ok()); windowModel.getCommands().add(okCommand); List<VdcQueryParametersBase> queryParamsList = new ArrayList<VdcQueryParametersBase>(); for(GlusterGeoRepSessionDetails detail : details) { queryParamsList.add(new IdQueryParameters(detail.getMasterBrickId())); } final List<EntityModel<GeoRepSessionDetailsSummary>> detailRows = new ArrayList<>(); Frontend.getInstance().runMultipleQueries(Collections.singletonList(VdcQueryType.GetGlusterBrickById), queryParamsList , new IFrontendMultipleQueryAsyncCallback() { @Override public void executed(FrontendMultipleQueryAsyncResult result) { List<VdcQueryReturnValue> returnValues = result.getReturnValues(); for(int currentValue = 0; currentValue < returnValues.size(); currentValue++) { GlusterBrickEntity currentBrick = (GlusterBrickEntity) returnValues.get(currentValue).getReturnValue(); detailRows.add(new EntityModel<VolumeGeoRepSessionDetailsModel.GeoRepSessionDetailsSummary>(new GeoRepSessionDetailsSummary(currentBrick.getServerName(), details.get(currentValue)))); } windowModel.getGeoRepSessionSummary().setItems(detailRows, detailRows.get(0)); setWindow(windowModel); } }); }