Source:
private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); if (volumeEntity == null) { return; } ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); if (replaceBrickModel == null) { return; } GlusterBrickEntity existingBrick = getSelectedItem(); if (existingBrick == null) { return; } String selectedHost = replaceBrickModel.getServers().getSelectedItem().getHostName(); AsyncDataProvider.getInstance().getGlusterBricksForServer(new AsyncQuery<>(bricks -> { List<GlusterBrickEntity> brickDirectories = new ArrayList<>(); for (GlusterBrickEntity brick : bricks) { brickDirectories.add(brick); } boolean isMultipleBricks = false; for (String brick : volumeEntity.getBrickDirectories()) { if (brick.contains(selectedHost) && selectedHost != existingBrick.getServerName() && brickDirectories.size() > 1) { isMultipleBricks = true; } } if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }), replaceBrickModel.getServers().getSelectedItem().getId()); }

Target:
private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); GlusterBrickEntity existingBrick = getSelectedItem(); if (volumeEntity == null && replaceBrickModel == null && existingBrick == null) { return; } VDS server = replaceBrickModel.getServers().getSelectedItem(); if (server == null) { return; } String selectedHost = server.getHostName(); boolean isMultipleBricks = volumeEntity.getBrickDirectories() .stream().filter(brick -> brick.contains(selectedHost) && selectedHost != existingBrick.getServerName()) .findAny().isPresent(); if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }