auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void executeCommand() { switch (getDisk().getDiskStorageType()) { case IMAGE: if (getDisk().getContentType() == DiskContentType.MEMORY_DUMP_VOLUME || getDisk().getContentType() == DiskContentType.MEMORY_METADATA_VOLUME) { removeMemoryDiskFromSnapshotIfNeeded(); } ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, buildRemoveImageParameters(getDiskImage())); if (actionReturnValue.getSucceeded()) { incrementVmsGeneration(); getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList()); setSucceeded(true); } break; case LUN: removeLunDisk(); break; case CINDER: RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(getParameters().getDiskId()); params.setEndProcedure(EndProcedure.COMMAND_MANAGED); Future<ActionReturnValue> future = CommandCoordinatorUtil.executeAsyncCommand( ActionType.RemoveCinderDisk, params, cloneContextAndDetachFromParent()); try { setReturnValue(future.get()); setSucceeded(getReturnValue().getSucceeded()); } catch (InterruptedException | ExecutionException e) { log.error("Error removing Cinder disk '{}': {}", getDiskImage().getDiskAlias(), e.getMessage()); log.debug("Exception", e); } break; } }

Target:
protected void executeCommand() { switch (getDisk().getDiskStorageType()) { case IMAGE: ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, buildRemoveImageParameters(getDiskImage())); if (actionReturnValue.getSucceeded()) { if (getDisk().getContentType() == DiskContentType.MEMORY_DUMP_VOLUME || getDisk().getContentType() == DiskContentType.MEMORY_METADATA_VOLUME) { removeMemoryDiskFromSnapshotIfNeeded(); } incrementVmsGeneration(); getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList()); setSucceeded(true); } break; case LUN: removeLunDisk(); break; case CINDER: RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(getParameters().getDiskId()); params.setEndProcedure(EndProcedure.COMMAND_MANAGED); Future<ActionReturnValue> future = CommandCoordinatorUtil.executeAsyncCommand( ActionType.RemoveCinderDisk, params, cloneContextAndDetachFromParent()); try { setReturnValue(future.get()); setSucceeded(getReturnValue().getSucceeded()); } catch (InterruptedException | ExecutionException e) { log.error("Error removing Cinder disk '{}': {}", getDiskImage().getDiskAlias(), e.getMessage()); log.debug("Exception", e); } break; } }
Source:
public HostNetworkQos selectQos(NetworkAttachment networkAttachment, HostNetworkQos daoHostNetworkQos) { return networkAttachment != null && networkAttachment.isQosOverridden() ? HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos()) : daoHostNetworkQos; }

Target:
HostNetworkQos selectQos(NetworkAttachment networkAttachment, HostNetworkQos daoHostNetworkQos) { return networkAttachment != null && networkAttachment.isQosOverridden() ? HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos()) : daoHostNetworkQos; }
Source:
public void add(double value, double weight) { final Map<Double, Long> breakdown = breakdowns.get(getIndexForValue(value)); breakdown.put( weight, breakdown.getOrDefault(weight, Long.valueOf(0)) + Long.valueOf(1)); }

Target:
public void add(double value, double weight) { System.out.println(this + " adding " + value + " -> " + weight + "; " + getIndexForValue(value)); breakdowns[getIndexForValue(value)].add(weight, 1); }
Source:
private void commitEntries() { context.checkThread(); long globalMatchIndex = context.getCluster().getMembers().stream().mapToLong(MemberState::getMatchIndex).min().orElse(context.getLog().lastIndex()); context.setGlobalIndex(Math.min(globalMatchIndex - 1, 0)); List<MemberState> members = context.getCluster().getActiveMembers((m1, m2) -> Long.compare(m2.getMatchIndex() != 0 ? m2.getMatchIndex() : 0l, m1.getMatchIndex() != 0 ? m1.getMatchIndex() : 0l)); if (members.isEmpty()) { context.setCommitIndex(context.getLog().lastIndex()); for (Map.Entry<Long, CompletableFuture<Long>> entry : commitFutures.entrySet()) { entry.getValue().complete(entry.getKey()); } commitFutures.clear(); return; } long commitIndex = members.get(quorumIndex()).getMatchIndex(); if (commitIndex > 0 && commitIndex > context.getCommitIndex() && (leaderIndex > 0 && commitIndex >= leaderIndex)) { context.setCommitIndex(commitIndex); SortedMap<Long, CompletableFuture<Long>> futures = commitFutures.headMap(commitIndex, true); for (Map.Entry<Long, CompletableFuture<Long>> entry : futures.entrySet()) { entry.getValue().complete(entry.getKey()); } futures.clear(); } }

Target:
private void commitEntries() { context.checkThread(); long globalMatchIndex = context.getCluster().getMembers().stream().mapToLong(MemberState::getMatchIndex).min().orElse(context.getLog().lastIndex()); context.setGlobalIndex(Math.max(globalMatchIndex - 1, 0)); List<MemberState> members = context.getCluster().getActiveMembers((m1, m2) -> Long.compare(m2.getMatchIndex() != 0 ? m2.getMatchIndex() : 0l, m1.getMatchIndex() != 0 ? m1.getMatchIndex() : 0l)); if (members.isEmpty()) { context.setCommitIndex(context.getLog().lastIndex()); for (Map.Entry<Long, CompletableFuture<Long>> entry : commitFutures.entrySet()) { entry.getValue().complete(entry.getKey()); } commitFutures.clear(); return; } long commitIndex = members.get(quorumIndex()).getMatchIndex(); if (commitIndex > 0 && commitIndex > context.getCommitIndex() && (leaderIndex > 0 && commitIndex >= leaderIndex)) { context.setCommitIndex(commitIndex); SortedMap<Long, CompletableFuture<Long>> futures = commitFutures.headMap(commitIndex, true); for (Map.Entry<Long, CompletableFuture<Long>> entry : futures.entrySet()) { entry.getValue().complete(entry.getKey()); } futures.clear(); } }
Source:
public DefaultUrlSanitizer(Collection<String> protocols) { this.protocols = protocols; }

Target:
public DefaultUrlSanitizer(Collection<String> protocols) { this.protocols = new HashSet<>(protocols); }
Source:
public File createCompressedSegmentDataFile(final File indexFilesDir) throws IOException { final File zipOutFile = File.createTempFile(TEMP_DIR, AzureStorageDruidModule.INDEX_ZIP_FILE_NAME); CompressionUtils.zip(indexFilesDir, zipOutFile); return zipOutFile; }

Target:
public File createCompressedSegmentDataFile(final File indexFilesDir) throws IOException { final File zipOutFile = File.createTempFile("index", ".zip"); CompressionUtils.zip(indexFilesDir, zipOutFile); return zipOutFile; }
Source:
private void handleNextRun() { if (m_state != SchedulerWrapperState.RUNNING) { return; } SchedulerResult result; try { result = m_scheduler.nextRun(m_procedure); } catch (RuntimeException e) { errorOccurred("Scheduler encountered unexpected error", e); return; } if (result == null) { errorOccurred("Scheduler returned a null result"); return; } synchronized (this) { if (m_state != SchedulerWrapperState.RUNNING) { return; } Runnable runnable; switch (result.getStatus()) { case EXIT: exitRequested(result.getMessage()); return; case ERROR: if (result.hasMessage()) { log.warn(generateLogMessage(result.getMessage())); } errorOccurred(null); return; case RERUN: runnable = this::handleNextRun; break; case PROCEDURE: runnable = this::executeProcedure; break; default: throw new IllegalStateException("Unknown status: " + result.getStatus()); } m_procedure = result.getScheduledProcedure(); try { m_scheduledFuture = addExceptionListener( m_wrapperExecutor.schedule(runnable, calculateDelay(), TimeUnit.NANOSECONDS)); m_procedure.scheduled(); } catch (RejectedExecutionException e) { if (log.isDebugEnabled()) { log.debug(generateLogMessage( "Could not schedule next procedure scheduler shutdown: " + m_procedure.getProcedure())); } } } }

Target:
private void handleNextRun() { Scheduler scheduler; synchronized (this) { if (m_state != SchedulerWrapperState.RUNNING) { return; } scheduler = m_scheduler; } long startTime = System.nanoTime(); long waitTime = startTime - m_expectedExecutionTime; SchedulerResult result; try { result = scheduler.nextRun(m_procedure); } catch (RuntimeException e) { errorOccurred("Scheduler encountered unexpected error", e); return; } finally { m_stats.addSchedulerCall(System.nanoTime() - startTime, waitTime); } if (result == null) { errorOccurred("Scheduler returned a null result"); return; } synchronized (this) { if (m_state != SchedulerWrapperState.RUNNING) { return; } Runnable runnable; switch (result.getStatus()) { case EXIT: exitRequested(result.getMessage()); return; case ERROR: if (result.hasMessage()) { log.warn(generateLogMessage(result.getMessage())); } errorOccurred(null); return; case RERUN: runnable = this::handleNextRun; break; case PROCEDURE: runnable = this::executeProcedure; break; default: throw new IllegalStateException("Unknown status: " + result.getStatus()); } m_procedure = result.getScheduledProcedure(); try { long delay = calculateDelay(); m_expectedExecutionTime = System.nanoTime() + delay; m_procedure.expectedExecutionTime(m_expectedExecutionTime); m_scheduledFuture = addExceptionListener( m_wrapperExecutor.schedule(runnable, delay, TimeUnit.NANOSECONDS)); } catch (RejectedExecutionException e) { if (log.isDebugEnabled()) { log.debug(generateLogMessage( "Could not schedule next procedure scheduler shutdown: " + m_procedure.getProcedure())); } } } }
Source:
public void selectField(Long id, String username, String fieldName) { Entity entity = getEntity(id); UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username); userPreferences = checkPreferences(userPreferences, entity, username); Field field = entity.getField(fieldName); assertField(field); List<Field> fields = userPreferences.getVisibleFields(); fields.add(field); userPreferences.setVisibleFields(fields); allUserPreferences.update(userPreferences); }

Target:
public void selectField(Long id, String username, String fieldName) { Entity entity = getEntity(id); UserPreferences userPreferences = allUserPreferences.retrieveByClassNameAndUsername(entity.getClassName(), username); userPreferences = checkPreferences(userPreferences, entity, username); Field field = entity.getField(fieldName); assertField(field); userPreferences.selectField(field); allUserPreferences.update(userPreferences); }
Source:
public FenceOperationResult fence(FenceActionType action, FenceAgent agent) { FenceOperationResult result; VDS proxyHost = getProxyLocator().findProxyHost(isRetryEnabled(action)); if (proxyHost == null) { return new FenceOperationResult( Status.ERROR, HostPowerStatus.UNKNOWN, String.format( "Failed to run Power Management command on Host '%s', no proxy was found", fencedHost.getHostName())); } try { result = runFenceAction(action, agent, proxyHost); if (result.getStatus() == Status.ERROR) { log.warn( "Fence operation failed with proxy host '{}', trying another proxy", proxyHost.getHostName()); VDS alternativeProxy = getProxyLocator().findProxyHost( isRetryEnabled(action), proxyHost.getId()); if (alternativeProxy != null) { result = runFenceAction(action, agent, alternativeProxy); } else { log.warn( "Failed to find another proxy to re-run failed fence operation, " + "retrying with the same proxy '{}'", proxyHost.getHostName()); result = runFenceAction(action, agent, proxyHost); } } } catch (VdcBLLException e) { log.debug("Exception", e); result = new FenceOperationResult( FenceOperationResult.Status.ERROR, HostPowerStatus.UNKNOWN, e.getMessage()); } return result; }

Target:
public FenceOperationResult fence(FenceActionType action, FenceAgent agent) { FenceOperationResult result; VDS proxyHost = getProxyLocator().findProxyHost(isRetryEnabled(action)); if (proxyHost == null) { return new FenceOperationResult( Status.ERROR, PowerStatus.UNKNOWN, String.format( "Failed to run Power Management command on Host '%s', no proxy was found", fencedHost.getHostName())); } try { result = runFenceAction(action, agent, proxyHost); if (result.getStatus() == Status.ERROR) { log.warn( "Fence operation failed with proxy host '{}', trying another proxy", proxyHost.getHostName()); VDS alternativeProxy = getProxyLocator().findProxyHost( isRetryEnabled(action), proxyHost.getId()); if (alternativeProxy != null) { result = runFenceAction(action, agent, alternativeProxy); } else { log.warn( "Failed to find another proxy to re-run failed fence operation, " + "retrying with the same proxy '{}'", proxyHost.getHostName()); result = runFenceAction(action, agent, proxyHost); } } } catch (VdcBLLException e) { log.debug("Exception", e); result = new FenceOperationResult( FenceOperationResult.Status.ERROR, PowerStatus.UNKNOWN, e.getMessage()); } return result; }
Source:
static <T> Try.CheckedSupplier<T> decorateCheckedSupplier(Timer timer, Try.CheckedSupplier<T> supplier){ return () -> { Timer.Context context = timer.time(); try { return supplier.get(); } finally{ context.stop(); } }; }

Target:
static <T> Try.CheckedSupplier<T> decorateCheckedSupplier(Timer timer, Try.CheckedSupplier<T> supplier){ return () -> { try (Timer.Context context = timer.time()) { return supplier.get(); } }; }
Source:
private void setActionIconBackground(int color) { GradientDrawable shape = new GradientDrawable(); shape.setCornerRadius(actionBackground.getResources() .getDimensionPixelSize(R.dimen.list_feed_action_icon_corner_radius)); shape.setColor(color); actionBackground.setBackground(shape); }

Target:
private void setActionIconBackground(int color) { GradientDrawable shape = new GradientDrawable(); shape.setShape(GradientDrawable.OVAL); shape.setColor(color); actionIcon.setBackground(shape); }
Source:
private void execute(UnmodifiableTestPlan unmodifiableTestPlan, TestExecutionListener[] listeners) { Root root = unmodifiableTestPlan.getRoot(); ConfigurationParameters configurationParameters = root.getConfigurationParameters(); TestExecutionListenerRegistry listenerRegistry = buildListenerRegistryForExecution(listeners); withInterceptedStreams(configurationParameters, listenerRegistry, testExecutionListener -> { TestPlan testPlan = unmodifiableTestPlan.getDelegate(); testExecutionListener.testPlanExecutionStarted(testPlan); ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener); for (TestEngine testEngine : root.getTestEngines()) { TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine); execute(testEngine, new ExecutionRequest(testDescriptor, engineExecutionListener, configurationParameters)); } testExecutionListener.testPlanExecutionFinished(testPlan); }); }

Target:
private void execute(UnmodifiableTestPlan unmodifiableTestPlan, TestExecutionListener[] listeners) { Root root = unmodifiableTestPlan.getRoot(); ConfigurationParameters configurationParameters = root.getConfigurationParameters(); TestExecutionListenerRegistry listenerRegistry = buildListenerRegistryForExecution(listeners); withInterceptedStreams(configurationParameters, listenerRegistry, testExecutionListener -> { TestPlan testPlan = unmodifiableTestPlan.getDelegate(); testExecutionListener.testPlanExecutionStarted(unmodifiableTestPlan); ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener); for (TestEngine testEngine : root.getTestEngines()) { TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine); execute(testEngine, new ExecutionRequest(testDescriptor, engineExecutionListener, configurationParameters)); } testExecutionListener.testPlanExecutionFinished(unmodifiableTestPlan); }); }
Source:
public void afterDelivery() throws ApplicationServerInternalException, UnavailableException { switch (state) { case RELEASED: throw new IllegalStateException("Message endpoint factory has been released"); case NONE: throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call"); } boolean exceptionThrown = false; try { container.afterDelivery(instance); } catch (final SystemException se) { exceptionThrown = true; final Throwable throwable = se.getRootCause() != null ? se.getRootCause() : se; throwable.printStackTrace(); throw new ApplicationServerInternalException(throwable); } finally { if (state == State.SYSTEM_EXCEPTION) { recreateInstance(exceptionThrown); } state = State.NONE; } }

Target:
public void afterDelivery() throws ApplicationServerInternalException, UnavailableException { switch (state) { case RELEASED: throw new IllegalStateException("Message endpoint factory has been released"); case NONE: throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call"); } boolean exceptionThrown = false; try { container.afterDelivery(instance); } catch (final SystemException se) { exceptionThrown = true; final Throwable throwable = se.getRootCause() != null ? se.getRootCause() : se; throw new ApplicationServerInternalException(throwable); } finally { if (state == State.SYSTEM_EXCEPTION) { recreateInstance(exceptionThrown); } state = State.NONE; } }
Source:
private Composite createDirectionGroup(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; panel.setLayout(layout); Group group = new Group(panel, SWT.SHADOW_ETCHED_IN); group.setText("Direction"); GridLayout groupLayout = new GridLayout(); group.setLayout(groupLayout); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); SelectionListener selectionListener = new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; fForwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT); fForwardRadioButton.setText("F&orward"); setGridData(fForwardRadioButton, SWT.LEFT, false, SWT.CENTER, false); fForwardRadioButton.addSelectionListener(selectionListener); storeButtonWithMnemonicInMap(fForwardRadioButton); Button backwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT); backwardRadioButton.setText("&Backward"); setGridData(backwardRadioButton, SWT.LEFT, false, SWT.CENTER, false); backwardRadioButton.addSelectionListener(selectionListener); storeButtonWithMnemonicInMap(backwardRadioButton); backwardRadioButton.setSelection(!fForwardInit); fForwardRadioButton.setSelection(fForwardInit); return panel; }

Target:
private Composite createDirectionGroup(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; panel.setLayout(layout); Group group = new Group(panel, SWT.SHADOW_ETCHED_IN); group.setText(Messages.TimeGraphFindDialog_Direction); GridLayout groupLayout = new GridLayout(); group.setLayout(groupLayout); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); SelectionListener selectionListener = new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; fForwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT); fForwardRadioButton.setText(Messages.TimeGraphFindDialog_ForwardRadioButton_label); setGridData(fForwardRadioButton, SWT.LEFT, false, SWT.CENTER, false); fForwardRadioButton.addSelectionListener(selectionListener); storeButtonWithMnemonicInMap(fForwardRadioButton); Button backwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT); backwardRadioButton.setText(Messages.TimeGraphFindDialog_BackwardRadioButton_label); setGridData(backwardRadioButton, SWT.LEFT, false, SWT.CENTER, false); backwardRadioButton.addSelectionListener(selectionListener); storeButtonWithMnemonicInMap(backwardRadioButton); backwardRadioButton.setSelection(!fForwardInit); fForwardRadioButton.setSelection(fForwardInit); return panel; }
Source:
public void init(String host, int port) throws Exception { if(host.contains("0.0.0.0")) { uri = new URI("http://" + host + ":" + port + "/"); } else { uri = new URI("http://" + "localhost" + ":" + port + "/"); } openBrowser(); }

Target:
public void init(String host, int port) throws Exception { String cleanedHost = host; if("0.0.0.0".equals(host)) { cleanedHost = "localhost"; } uri = new URI("http://" + cleanedHost + ":" + port + "/"); openBrowser(); }
Source:
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_new_tab: providerListener.onNewTabRequested(); return true; case R.id.menu_close_all_tabs: AlertDialog.Builder alert = new AlertDialog.Builder(fragment.getContext()); alert.setMessage(R.string.close_all_tabs_confirm); alert.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); providerListener.onCloseAllTabs(); } }); alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert.create().show(); return true; default: return false; } }

Target:
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_new_tab: providerListener.onNewTabRequested(); return true; case R.id.menu_close_all_tabs: AlertDialog.Builder alert = new AlertDialog.Builder(fragment.getContext()); alert.setMessage(R.string.close_all_tabs_confirm); alert.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { providerListener.onCloseAllTabs(); } }); alert.setNegativeButton(R.string.no, null); alert.create().show(); return true; default: return false; } }
Source:
public double approximatedForwardAccumulation() { double accumulatedInterest = 0.0d; int nbPeriodNotCutOff = nbPeriods - cutoffOffset + 1; if (fixedPeriod < nbPeriodNotCutOff) { LocalDate startDateApprox = onRatePeriodEffectiveDates.get(fixedPeriod); LocalDate endDateApprox = onRatePeriodMaturityDates.get(nbPeriodNotCutOff - 1); accumulatedInterest = approximatedInterest(env, index, startDateApprox, endDateApprox); } return accumulatedInterest; }

Target:
public double approximatedForwardAccumulation() { int nbPeriodNotCutOff = nbPeriods - cutoffOffset + 1; if (fixedPeriod < nbPeriodNotCutOff) { LocalDate startDateApprox = onRatePeriodEffectiveDates.get(fixedPeriod); LocalDate endDateApprox = onRatePeriodMaturityDates.get(nbPeriodNotCutOff - 1); return approximatedInterest(env, index, startDateApprox, endDateApprox); } return 0.0d; }
Source:
void collectExpectedIssues(String comment, int line) { if (NONCOMPLIANT_COMMENT.matcher(comment).find()) { IssueAndFlows issueAndFlows = parseIssue(comment, line); if (issueAndFlows.parsed()) { issues.put(LINE.get(issueAndFlows.issue), issueAndFlows.issue); issueAndFlows.flows.forEach(f -> flows.put(f.id, f)); } else { LOG.warn("Comment on line not parsed", comment, line); } } if (FLOW_COMMENT.matcher(comment).find()) { parseFlows(comment, line).forEach(f -> flows.put(f.id, f)); } }

Target:
void collectExpectedIssues(String comment, int line) { if (NONCOMPLIANT_COMMENT.matcher(comment).find()) { ParsedComment parsedComment = parseIssue(comment, line); issues.put(LINE.get(parsedComment.issue), parsedComment.issue); parsedComment.flows.forEach(f -> flows.put(f.id, f)); } if (FLOW_COMMENT.matcher(comment).find()) { parseFlows(comment, line).forEach(f -> flows.put(f.id, f)); } }
Source:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); context.record( TransformLineageRecorderUtils.oneToOneIn(TransformLineageRecorderUtils.getFields(outSchema), "compress", "Use the specified algorithm to compress the field.")); }

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); parseConfiguration(config.compressor, context.getFailureCollector()); List<String> inFields = TransformLineageRecorderUtils.getFields(context.getInputSchema()); List<String> outFields = TransformLineageRecorderUtils.getFields(context.getOutputSchema()); List<String> identityFields = outFields.stream() .filter(field -> !compMap.containsKey(field) || compMap.get(field) == CompressorType.NONE) .collect(Collectors.toList()); List<String> processedFields = new ArrayList<>(outFields); processedFields.removeAll(identityFields); List<String> droppedFields = new ArrayList<>(inFields); droppedFields.removeAll(outFields); List<FieldOperation> output = new ArrayList<>(); output.addAll(TransformLineageRecorderUtils.generateOneToOnes(processedFields, "compress", "Used the specified algorithm to compress the field.")); output.addAll(TransformLineageRecorderUtils.generateDrops(droppedFields)); output.addAll(TransformLineageRecorderUtils.generateOneToOnes(identityFields, "identity", TransformLineageRecorderUtils.IDENTITY_TRANSFORM_DESCRIPTION)); context.record(output); }
Source:
Map<String, List<PipelineTemplate>> list( @RequestParam(required = false, value = "scopes") List<String> scopes) { PipelineTemplateDAO pipelineTemplateDAO = getPipelineTemplateDAO(); Collection<PipelineTemplate> pipelineTemplates = pipelineTemplateDAO.getPipelineTemplatesByScope(scopes).stream() .filter(pt -> pt.getOrDefault("schema", "").equals("v2")) .collect(Collectors.toList()); return pipelineTemplateDAO.groupPipelineTemplatesById(pipelineTemplates); }

Target:
List<PipelineTemplate> list( @RequestParam(required = false, value = "scopes") List<String> scopes) { return (List<PipelineTemplate>) getPipelineTemplateDAO().getPipelineTemplatesByScope(scopes); }
Source:
public void lock() throws InterruptedException, TimeoutException { Exception exception = null; ExceptionType exceptionType = ExceptionType.NONE; for (ExtendedLockPromise lockPromise : lockPromiseList) { try { lockPromise.lock(); } catch (InterruptedException e) { if (exception == null) { exception = e; exceptionType = ExceptionType.INTERRUPTED; } } catch (TimeoutException e) { if (exception == null) { exception = e; exceptionType = ExceptionType.TIMEOUT; } } catch (DeadlockDetectedException e) { if (exception == null) { exception = e; exceptionType = ExceptionType.DEADLOCK; } } catch (RuntimeException e) { if (exception == null) { exception = e; exceptionType = ExceptionType.RUNTIME; } } } if (exception != null) { switch (exceptionType) { case INTERRUPTED: throw (InterruptedException) exception; case TIMEOUT: throw (TimeoutException) exception; case RUNTIME: throw (RuntimeException) exception; case DEADLOCK: throw (DeadlockDetectedException) exception; default: break; } } }

Target:
public void lock() throws InterruptedException, TimeoutException { InterruptedException interruptedException = null; TimeoutException timeoutException = null; DeadlockDetectedException deadlockException = null; RuntimeException runtimeException = null; for (ExtendedLockPromise lockPromise : lockPromiseList) { try { lockPromise.lock(); } catch (InterruptedException e) { interruptedException = e; } catch (TimeoutException e) { timeoutException = e; } catch (DeadlockDetectedException e) { deadlockException = e; } catch (RuntimeException e) { runtimeException = e; } } if (interruptedException != null) { throw interruptedException; } else if (timeoutException != null) { throw timeoutException; } else if (deadlockException != null) { throw deadlockException; } else if (runtimeException != null) { throw runtimeException; } }
Source:
public void testAfterApplicationName() throws Exception { String baseDS = ".credentials/talend-googledrive"; String appName = ""; assertThat(properties.datastorePath.getValue(), endsWith(baseDS)); appName = "GoogleDriveTests"; properties.applicationName.setValue(appName); properties.afterApplicationName(); assertThat(properties.datastorePath.getValue(), endsWith(baseDS + "/" + appName)); }

Target:
public void testAfterApplicationName() throws Exception { String baseDS = ".credentials" + File.separator + "talend-googledrive"; String appName = ""; assertThat(properties.datastorePath.getValue(), endsWith(baseDS)); appName = "GoogleDriveTests"; properties.applicationName.setValue(appName); properties.afterApplicationName(); assertThat(properties.datastorePath.getValue(), endsWith(baseDS + File.separator + appName)); }
Source:
public MetricsMode toggle() { do { currentMode = modeIterator.next(); } while (!getCurrentMode().isAvailable()); return this.getCurrentMode(); }

Target:
public MetricsMode toggle() { do { cursor = (cursor + 1) % modes.size(); currentMode = modes.get(cursor); } while (!currentMode.isAvailable()); return currentMode; }
Source:
public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; final PatchSet.Id pId = patchSet.getId(); try { final ReviewDb db = schema.open(); try { p.parents = new ArrayList<String>(); for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( patchSet.getId())) { p.parents.add(a.getAncestorRevision().get()); } Account.Id authorId = psInfoFactory.get(db, pId).getAuthor().getAccount(); if (authorId == null) { p.author = new AccountAttribute(); p.author.email = psInfoFactory.get(db, pId).getAuthor().getEmail(); p.author.name = psInfoFactory.get(db, pId).getAuthor().getName(); p.author.username = ""; } else { p.author = asAccountAttribute(authorId); } Change change = db.changes().get(pId.getParentKey()); List<Patch> list = patchListCache.get(change, patchSet).toPatchList(pId); for (Patch pe : list) { if (!Patch.COMMIT_MSG.equals(pe.getFileName())) { p.sizeDeletions -= pe.getDeletions(); p.sizeInsertions += pe.getInsertions(); } } } finally { db.close(); } } catch (OrmException e) { log.error("Cannot load patch set data for " + patchSet.getId(), e); } catch (PatchSetInfoNotAvailableException e) { log.error(String.format("Cannot get authorEmail for %s.", pId), e); } catch (PatchListNotAvailableException e) { log.error(String.format("Cannot get size information for %s.", pId), e); } return p; }

Target:
public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; final PatchSet.Id pId = patchSet.getId(); try { final ReviewDb db = schema.open(); try { p.parents = new ArrayList<String>(); for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( patchSet.getId())) { p.parents.add(a.getAncestorRevision().get()); } UserIdentity author = psInfoFactory.get(db, pId).getAuthor(); if (author.getAccount() == null) { p.author = new AccountAttribute(); p.author.email = author.getEmail(); p.author.name = author.getName(); p.author.username = ""; } else { p.author = asAccountAttribute(author.getAccount()); } Change change = db.changes().get(pId.getParentKey()); List<Patch> list = patchListCache.get(change, patchSet).toPatchList(pId); for (Patch pe : list) { if (!Patch.COMMIT_MSG.equals(pe.getFileName())) { p.sizeDeletions -= pe.getDeletions(); p.sizeInsertions += pe.getInsertions(); } } } finally { db.close(); } } catch (OrmException e) { log.error("Cannot load patch set data for " + patchSet.getId(), e); } catch (PatchSetInfoNotAvailableException e) { log.error(String.format("Cannot get authorEmail for %s.", pId), e); } catch (PatchListNotAvailableException e) { log.error(String.format("Cannot get size information for %s.", pId), e); } return p; }
Source:
public void checkFullyInitialized() throws IllegalStateException { if (fullyInitialized) { return; } if (!initialized) { throw new IllegalStateException("Metadata not yet initialized"); } fullyInitialized = true; try { for (Field field : fields) { if (field instanceof StructField) { ((StructField) field).getMetadata().checkFullyInitialized(); } } } catch (RuntimeException e) { fullyInitialized = false; throw e; } }

Target:
public void checkFullyInitialized() throws IllegalStateException { if (initializationFullyChecked || Boolean.TRUE.equals(checkingForFullInitialization.get())) { return; } if (!initialized) { throw new IllegalStateException("Metadata not yet initialized"); } checkingForFullInitialization.set(Boolean.TRUE); try { for (Field field : fields) { if (field instanceof StructField) { ((StructField) field).getMetadata().checkFullyInitialized(); } } initializationFullyChecked = true; } finally { checkingForFullInitialization.remove(); } }
Source:
public SpongeCommandData setLastOutput(Text message) { if (message.isEmpty()) { this.lastOutput = null; } else { this.lastOutput = message; } return this; }

Target:
public SpongeCommandData setLastOutput(Text message) { if (checkNotNull(message, "message").isEmpty()) { this.lastOutput = null; } else { this.lastOutput = message; } return this; }
Source:
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length != 2) { return false; } final Player player = getPlayer(args[0]); if (player == null) { playerMsg(TFM_Command.PLAYER_NOT_FOUND); return true; } smite(player); return true; }

Target:
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length != 1) { return false; } final Player player = getPlayer(args[0]); if (player == null) { playerMsg(TFM_Command.PLAYER_NOT_FOUND); return true; } smite(player); return true; }
Source:
protected void setAuthentication(final Builder builder) { if (tokenManager != null) { String accessToken = tokenManager.getToken(); builder.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken); } else if (getApiKey() == null) { if (skipAuthentication) { return; } throw new IllegalArgumentException("apiKey or username and password were not specified"); } else { builder.addHeader(HttpHeaders.AUTHORIZATION, apiKey.startsWith(BASIC) ? apiKey : BASIC + apiKey); } }

Target:
protected void setAuthentication(final Builder builder) { if (tokenManager != null) { String accessToken = tokenManager.getToken(); builder.addHeader(HttpHeaders.AUTHORIZATION, BEARER + accessToken); } else if (getApiKey() == null) { if (skipAuthentication) { return; } throw new IllegalArgumentException("apiKey or username and password were not specified"); } else { builder.addHeader(HttpHeaders.AUTHORIZATION, apiKey.startsWith(BASIC) ? apiKey : BASIC + apiKey); } }
Source:
private MessageFormatInputStream getPutMessage(StoreKey key, BlobProperties blobProperties, byte[] usermetadata, byte[] blob, int blobSize, short blobVersion, BlobType blobType) throws MessageFormatException { switch (blobVersion) { case MessageFormatRecord.Blob_Version_V1: return new PutMessageFormatBlobV1InputStream(key, blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), blobSize, blobType); case MessageFormatRecord.Blob_Version_V2: return new PutMessageFormatInputStream(key, blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), blobSize, blobType); default: throw new IllegalStateException("Unsupported Blob version " + blobVersion); } }

Target:
private MessageFormatInputStream getPutMessage(StoreKey key, BlobProperties blobProperties, byte[] usermetadata, byte[] blob, int blobSize, short blobVersion, BlobType blobType) throws MessageFormatException { if (blobVersion == MessageFormatRecord.Blob_Version_V2) { return new PutMessageFormatInputStream(key, blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), blobSize, blobType); } else { return new PutMessageFormatBlobV1InputStream(key, blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), blobSize, blobType); } }
Source:
private VmPayload getPayloadModel() { VmPayload payload = new VmPayload(); payload.setType(VmDeviceType.CDROM); payload.getFiles().put("payloadFile", PAYLOAD_COMTENT); return payload; }

Target:
private VmPayload getPayloadModel() { VmPayload payload = new VmPayload(); payload.setType(VmDeviceType.CDROM); payload.getFiles().put("payloadFile", new String(Base64.decodeBase64(PAYLOAD_COMTENT))); return payload; }
Source:
int writeBytes(InputStream input, int bytesToRead) throws IOException; static ChannelStateByteBuffer wrap(Buffer buffer) { return new ChannelStateByteBuffer() { private ByteBuf byteBuf = buffer.asByteBuf(); @Override public boolean isWritable() { return byteBuf.isWritable(); } @Override public int writableBytes() { return byteBuf.writableBytes(); } @Override public int writeBytes(InputStream input, int bytesToRead) throws IOException { return byteBuf.writeBytes(input, Math.min(bytesToRead, byteBuf.writableBytes())); } }; }

Target:
int writeBytes(InputStream input, int bytesToRead) throws IOException; static ChannelStateByteBuffer wrap(Buffer buffer) { return new ChannelStateByteBuffer() { private final ByteBuf byteBuf = buffer.asByteBuf(); @Override public boolean isWritable() { return byteBuf.isWritable(); } @Override public int writeBytes(InputStream input, int bytesToRead) throws IOException { return byteBuf.writeBytes(input, Math.min(bytesToRead, byteBuf.writableBytes())); } }; }
Source:
void handlePendingNotices() { if (stateRef.get().pendingNotices.isEmpty()) { return; } LookupUpdateState swappedState = atomicallyUpdateStateRef( oldState -> { return new LookupUpdateState(oldState.lookupMap, ImmutableList.of(), oldState.pendingNotices); } ); Map<String, LookupExtractorFactoryContainer> lookupMap = new HashMap<>(swappedState.lookupMap); for (Notice notice : swappedState.noticesBeingHandled) { try { notice.handle(lookupMap); } catch (Exception ex) { LOG.error(ex, "Exception occured while handling lookup notice [%s].", notice); LOG.makeAlert("Exception occured while handling lookup notice, with message [%s].", ex.getMessage()).emit(); } } takeSnapshot(lookupMap); ImmutableMap<String, LookupExtractorFactoryContainer> immutableLookupMap = ImmutableMap.copyOf(lookupMap); atomicallyUpdateStateRef( oldState -> { return new LookupUpdateState(immutableLookupMap, oldState.pendingNotices, ImmutableList.of()); } ); }

Target:
void handlePendingNotices() { if (stateRef.get().pendingNotices.isEmpty()) { return; } LookupUpdateState swappedState = atomicallyUpdateStateRef( oldState -> new LookupUpdateState(oldState.lookupMap, ImmutableList.of(), oldState.pendingNotices) ); Map<String, LookupExtractorFactoryContainer> lookupMap = new HashMap<>(swappedState.lookupMap); for (Notice notice : swappedState.noticesBeingHandled) { try { notice.handle(lookupMap); } catch (Exception ex) { LOG.error(ex, "Exception occured while handling lookup notice [%s].", notice); LOG.makeAlert("Exception occured while handling lookup notice, with message [%s].", ex.getMessage()).emit(); } } takeSnapshot(lookupMap); ImmutableMap<String, LookupExtractorFactoryContainer> immutableLookupMap = ImmutableMap.copyOf(lookupMap); atomicallyUpdateStateRef( oldState -> new LookupUpdateState(immutableLookupMap, oldState.pendingNotices, ImmutableList.of()) ); }
Source:
private Broker findNewLeader(Broker oldLeader) throws InterruptedException { long retryCnt = 0; while (true) { PartitionMetadata metadata = findLeader(); if (metadata != null) { replicaBrokers.clear(); for (Broker replica : metadata.replicas()) { replicaBrokers.add(new KafkaBroker(replica.host(), replica.port())); } log.debug("findNewLeader - metadata[%s], previous leader[%s]", metadata, oldLeader); Broker newLeader = metadata.leader(); if (newLeader != null) { if (oldLeader == null || !isCurrLeader(newLeader) || retryCnt != 0) { return newLeader; } } } Thread.sleep(1000L); retryCnt++; if (retryCnt >= 3 && (retryCnt - 3) % 5 == 0) { log.warn("cannot find leader for [%s] - [%s] after [%s] retries", topic, partitionId, retryCnt); replicaBrokers.clear(); replicaBrokers.addAll(allBrokers); } } }

Target:
private Broker findNewLeader(Broker oldLeader) throws InterruptedException { long retryCnt = 0; while (true) { PartitionMetadata metadata = findLeader(); if (metadata != null) { replicaBrokers.clear(); for (Broker replica : metadata.replicas()) { replicaBrokers.add(new KafkaBroker(replica.host(), replica.port())); } log.debug("Got new Kafka leader metadata : [%s], previous leader : [%s]", metadata, oldLeader); Broker newLeader = metadata.leader(); if (newLeader != null) { if (oldLeader == null || isValidNewLeader(newLeader) || retryCnt != 0) { return newLeader; } } } Thread.sleep(RETRY_INTERVAL); retryCnt++; if (retryCnt >= 3 && (retryCnt - 3) % 5 == 0) { log.warn("cannot find leader for [%s] - [%s] after [%s] retries", topic, partitionId, retryCnt); replicaBrokers.clear(); replicaBrokers.addAll(allBrokers); } } }
Source:
private void checkSessionExpiration() { if ( (currentConnectionState == ConnectionState.SUSPENDED) && (startOfSuspendedEpoch != 0) ) { long elapsedMs = System.currentTimeMillis() - startOfSuspendedEpoch; int useSessionTimeoutMs = getUseSessionTimeoutMs(); if ( elapsedMs >= useSessionTimeoutMs ) { startOfSuspendedEpoch = System.currentTimeMillis(); log.warn(String.format("Session timeout has elapsed while SUSPENDED. Injecting a session expiration. Elapsed ms: %d. Adjusted session timeout ms: %d", elapsedMs, useSessionTimeoutMs)); try { client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration(); } catch ( Exception e ) { log.error("Could not inject session expiration", e); } } } else if ( currentConnectionState == ConnectionState.LOST ) { try { if ( client.getZookeeperClient().isConnected() ) { log.warn("ConnectionState is LOST but isConnected() is true. Resetting connection."); client.getZookeeperClient().reset(); } else { client.getZookeeperClient().getZooKeeper(); } } catch ( Exception e ) { log.error("Could not get ZooKeeper", e); } } }

Target:
private void checkSessionExpiration() { if ( (currentConnectionState == ConnectionState.SUSPENDED) && (startOfSuspendedEpoch != 0) ) { long elapsedMs = System.currentTimeMillis() - startOfSuspendedEpoch; int useSessionTimeoutMs = getUseSessionTimeoutMs(); if ( elapsedMs >= useSessionTimeoutMs ) { startOfSuspendedEpoch = System.currentTimeMillis(); log.warn(String.format("Session timeout has elapsed while SUSPENDED. Injecting a session expiration. Elapsed ms: %d. Adjusted session timeout ms: %d", elapsedMs, useSessionTimeoutMs)); try { client.getZookeeperClient().getZooKeeper().getTestable().injectSessionExpiration(); } catch ( Exception e ) { log.error("Could not inject session expiration", e); } } } else if ( currentConnectionState == ConnectionState.LOST ) { try { client.getZookeeperClient().getZooKeeper(); } catch ( Exception e ) { log.error("Could not get ZooKeeper", e); } } }
Source:
protected IDialogSettings getPersistentPropertyStore() { IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(fViewId); if (section == null) { section = settings.addNewSection(fViewId); if (section == null) { throw new IllegalStateException("The persistent property section could not be added"); } } if (fViewName == null) { System.out.println(getClass().getName() + ": name is null"); return section; } IDialogSettings subSection = section.getSection(fViewName); if (subSection == null) { subSection = section.addNewSection(fViewName); if (subSection == null) { throw new IllegalStateException("The persistent property section could not be added"); } } return subSection; }

Target:
protected IDialogSettings getPersistentPropertyStore() { IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(fViewId); if (section == null) { section = settings.addNewSection(fViewId); if (section == null) { throw new IllegalStateException("The persistent property section could not be added"); } } return section; }
Source:
public void unsubscribeFrom(final String channelName) { if (channelName == null) { throw new IllegalArgumentException("Cannot unsubscribe from null channel"); } final InternalChannel channel = channelNameToChannelMap.remove(channelName); if (channel == null) { return; } if (connection.getState() == ConnectionState.CONNECTED) { if (channel instanceof PrivateEncryptedChannelImpl) { ((PrivateEncryptedChannelImpl) channel).tearDownChannel(); } sendUnsubscribeMessage(channel); } }

Target:
public void unsubscribeFrom(final String channelName) { if (channelName == null) { throw new IllegalArgumentException("Cannot unsubscribe from null channel"); } final InternalChannel channel = channelNameToChannelMap.remove(channelName); if (channel == null) { return; } if (connection.getState() == ConnectionState.CONNECTED) { sendUnsubscribeMessage(channel); } }
Source:
public void setAutoDisable(Boolean autoDisable) { this.autoDisable = autoDisable; this.addServoEventListener(this); log.info("setAutoDisable : " + autoDisable); delayDisable(); broadcastState(); }

Target:
public void setAutoDisable(Boolean autoDisable) { this.autoDisable = autoDisable; addServoEventListener(this); log.info("setAutoDisable : " + autoDisable); delayDisable(); broadcastState(); }
Source:
public void testLastValueIgnoreNulls() { String query = "WITH T AS (" + " SELECT" + " p," + " v" + " FROM (" + " VALUES" + " (2, 2)," + " (1, 1)," + " (3, NULL)" + " ) T(p, v)" + ")" + "SELECT" + " LAST_VALUE(v) IGNORE NULLS OVER (" + " PARTITION BY 1" + " ORDER BY" + " p ASC" + " )" + "FROM T"; MaterializedResult actual = computeActual(query); for (MaterializedRow row : actual.getMaterializedRows()) { assertNotEquals(row.getField(0), null); } }

Target:
public void testLastValueIgnoreNulls() { assertQuery( "WITH T AS (" + " SELECT" + " p," + " v" + " FROM (" + " VALUES" + " (2, 2)," + " (1, 1)," + " (3, NULL)" + " ) T(p, v)" + ")" + "SELECT" + " LAST_VALUE(v) IGNORE NULLS OVER (" + " PARTITION BY 1" + " ORDER BY" + " p ASC" + " )" + "FROM T", "Values 1, 2, 2"); }
Source:
public String toString() { return super.toString() + "!"; }

Target:
public String toString() { return super.toString() + "_" + exceptionType.fullyQualifiedName() + "!"; }
Source:
public void onBreakBlock(Block block, World worldIn, BlockPos pos) { IMixinWorld spongeWorld = (IMixinWorld) worldIn; final CauseTracker causeTracker = spongeWorld.getCauseTracker(); final boolean isBlockAlready = causeTracker.getPhases().current() != TrackingPhases.BLOCK; if (isBlockAlready) { causeTracker.switchToPhase(TrackingPhases.BLOCK, BlockPhase.State.BLOCK_DECAY); } block.beginLeavesDecay(worldIn, pos); if (isBlockAlready) { causeTracker.pop(); } }

Target:
public void onBreakBlock(Block block, World worldIn, BlockPos pos) { IMixinWorldServer spongeWorld = (IMixinWorldServer) worldIn; final CauseTracker causeTracker = spongeWorld.getCauseTracker(); final boolean isBlockAlready = causeTracker.getStack().current() != TrackingPhases.BLOCK; final IBlockState blockState = worldIn.getBlockState(pos); final IBlockState actualState = blockState.getBlock().getActualState(blockState, worldIn, pos); if (isBlockAlready) { causeTracker.switchToPhase(TrackingPhases.BLOCK, BlockPhase.State.BLOCK_DECAY, PhaseContext.start() .add(NamedCause.source(spongeWorld.createSpongeBlockSnapshot(blockState, actualState, pos, 3))) .addCaptures() .complete()); } block.beginLeavesDecay(worldIn, pos); if (isBlockAlready) { causeTracker.completePhase(); } }
Source:
public HiveMetastoreClient createMetastoreClient(String token) throws TException { List<HostAndPort> metastores = new ArrayList<>(addresses); if (isMultipleMetastore) { Collections.shuffle(metastores); } else { Collections.shuffle(metastores.subList(1, metastores.size())); } TException lastException = null; for (HostAndPort metastore : metastores) { try { HiveMetastoreClient client; client = clientFactory.create(metastore, token); if (!isNullOrEmpty(metastoreUsername)) { client.setUGI(metastoreUsername); } return client; } catch (TException e) { lastException = e; } } throw new TException("Failed connecting to Hive metastore: " + addresses, lastException); }

Target:
public HiveMetastoreClient createMetastoreClient(String token) throws TException { List<HostAndPort> metastores = new ArrayList<>(addresses); if (isMultipleMetastore) { Collections.shuffle(metastores); } else { Collections.shuffle(metastores.subList(1, metastores.size())); } TException lastException = null; for (HostAndPort metastore : metastores) { try { HiveMetastoreClient client = clientFactory.create(metastore, token); if (!isNullOrEmpty(metastoreUsername)) { client.setUGI(metastoreUsername); } return client; } catch (TException e) { lastException = e; } } throw new TException("Failed connecting to Hive metastore: " + addresses, lastException); }