auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void decorate(Object element, IDecoration decoration) { ISarosSession currentSession = session; if (currentSession == null) return; IResource resource = (IResource) element; Set<IReferencePoint> referencePoints = session.getReferencePoints(); <START> saros.filesystem.IResource resourceWrapper = <END> ResourceConverter.convertToResource(referencePoints, resource); if (resourceWrapper == null || !currentSession.isShared(resourceWrapper)) return; decoration.addOverlay(SharedProjectDecorator.PROJECT_DESCRIPTOR, IDecoration.TOP_LEFT); if (resourceWrapper.getType() == Type.REFERENCE_POINT) { decoration.addSuffix(Messages.SharedProjectDecorator_shared); } }</code><technical_language>I right runtime changed O(1) O(n) ? hurt this is called in a background thread. some users pointed out sharing 40 projects (hopefully container 100000 files)</technical_language>

Target:
public void decorate(Object element, IDecoration decoration) { ISarosSession currentSession = session; if (currentSession == null) return; IResource resource = (IResource) element; saros.filesystem.IResource resourceWrapper = getSarosResource(resource); if (resourceWrapper == null || !currentSession.isShared(resourceWrapper)) return; decoration.addOverlay(SharedProjectDecorator.PROJECT_DESCRIPTOR, IDecoration.TOP_LEFT); if (resourceWrapper.getType() == Type.REFERENCE_POINT) { decoration.addSuffix(Messages.SharedProjectDecorator_shared); } }
Source:
<code>private Map<String, ResourceAssignment> getBaselineAssignment( AssignmentMetadataStore assignmentMetadataStore, CurrentStateOutput currentStateOutput, Set<String> resources) throws HelixRebalanceException { Map<String, ResourceAssignment> currentBaseline = new HashMap<>(); if (assignmentMetadataStore != null) { try { _stateReadLatency.startMeasuringLatency(); currentBaseline = new HashMap<>(assignmentMetadataStore.getBaseline()); _stateReadLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException( "Failed to get the current baseline assignment because of unexpected error.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } currentBaseline.keySet().retainAll(resources); if (!currentBaseline.keySet().containsAll(resources)) { <START> LOG.warn("The current baseline assignment record is empty. Use the current states instead."); <END> for (Map.Entry<String, ResourceAssignment> entry : currentStateOutput.getAssignment(resources) .entrySet()) { if (resources.contains(entry.getKey()) && !currentBaseline.containsKey(entry.getKey())) { currentBaseline.put(entry.getKey(), entry.getValue()); } } } return currentBaseline; }</code><technical_language>current baseline assignment record resources assignment...</technical_language>

Target:
private Map<String, ResourceAssignment> getBaselineAssignment( AssignmentMetadataStore assignmentMetadataStore, CurrentStateOutput currentStateOutput, Set<String> resources) throws HelixRebalanceException { Map<String, ResourceAssignment> currentBaseline = new HashMap<>(); if (assignmentMetadataStore != null) { try { _stateReadLatency.startMeasuringLatency(); currentBaseline = new HashMap<>(assignmentMetadataStore.getBaseline()); _stateReadLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException( "Failed to get the current baseline assignment because of unexpected error.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } currentBaseline.keySet().retainAll(resources); Set<String> missingResources = new HashSet<>(resources); missingResources.removeAll(currentBaseline.keySet()); currentBaseline.putAll(currentStateOutput.getAssignment(missingResources)); return currentBaseline; }
Source:
<code>public void tokenize(SourceCode sourceCode, Tokens tokenEntries) throws IOException { String filename = sourceCode.getFileName(); String fullCode = StringUtils.join(sourceCode.getCode(), "\n"); Input.VirtualFile vf = new Input.VirtualFile(filename, fullCode); ScalametaTokenizer tokenizer = new ScalametaTokenizer(vf, dialect); scala.meta.tokens.Tokens tokens = tokenizer.tokenize(); <START> List<scala.meta.tokens.Token> tokenList = JavaConverters.asJava(tokens.toList()); <END> ScalaTokenFilter filter = new ScalaTokenFilter(tokenList); scala.meta.tokens.Token token; while ((token = filter.getNextToken()) != null) { String tokenText = token.text() != null ? token.text() : token.name(); TokenEntry cpdToken = new TokenEntry(tokenText, filename, token.pos().startLine()); tokenEntries.add(cpdToken); } }</code><technical_language>Is this necessary load tokens a list? scala.meta.tokens.Tokens? need next token (kind of a iterator) complete list... sure, this a difference in end (depends impl of scalameta), this, for a higher memory footprint</technical_language>

Target:
public void tokenize(SourceCode sourceCode, Tokens tokenEntries) throws IOException { String filename = sourceCode.getFileName(); String fullCode = StringUtils.join(sourceCode.getCode(), "\n"); Input.VirtualFile vf = new Input.VirtualFile(filename, fullCode); ScalametaTokenizer tokenizer = new ScalametaTokenizer(vf, dialect); try { scala.meta.tokens.Tokens tokens = tokenizer.tokenize(); ScalaTokenFilter filter = new ScalaTokenFilter(tokens.iterator()); Token token; while ((token = filter.getNextToken()) != null) { String tokenText = token.text() != null ? token.text() : token.name(); TokenEntry cpdToken = new TokenEntry(tokenText, filename, token.pos().startLine()); tokenEntries.add(cpdToken); } } finally { tokenEntries.add(TokenEntry.getEOF()); } }
Source:
<code><START> public Optional<Serializable> getProperty(String propertyKey) { <END> return Optional.ofNullable(properties.get(propertyKey)); }</code><technical_language>Optional JS API intuitive cumbersome. remove Optional</technical_language>

Target:
public Serializable getProperty(String propertyKey) { return properties.get(propertyKey); }
Source:
<code><START> private boolean isRemoveLeaseNeeded(Guid srcLeaseDomainId, Guid dstLeaseDomainId) { <END> if (getParameters().getSnapshotAction() == SnapshotActionEnum.UNDO) { return isLeaseStorageDomainsEquals(srcLeaseDomainId, dstLeaseDomainId) || (srcLeaseDomainId == null && dstLeaseDomainId != null); } if (getParameters().getSnapshotAction() == SnapshotActionEnum.COMMIT) { return isLeaseStorageDomainsEquals(srcLeaseDomainId, dstLeaseDomainId) || (srcLeaseDomainId != null && dstLeaseDomainId == null); } return false; }</code><technical_language>please consider switch-case syntax, I this code nicer</technical_language>

Target:
private boolean isRemoveLeaseNeeded(Guid srcLeaseDomainId, Guid dstLeaseDomainId) { switch (getParameters().getSnapshotAction()) { case UNDO: return !Objects.equals(srcLeaseDomainId, dstLeaseDomainId) || (srcLeaseDomainId == null && dstLeaseDomainId != null); case COMMIT: return !Objects.equals(srcLeaseDomainId, dstLeaseDomainId) || (srcLeaseDomainId != null && dstLeaseDomainId == null); default: return false; } }
Source:
<code>public static Context setNewLocale(Context context, String language) { Locale newLocale = WPPrefUtils.languageLocale(language); <START> if (Locale.getDefault().toString().equals(newLocale.toString())) { <END> removePersistedLanguage(context); } else { saveLanguageToPref(context, language); } return updateResources(context, language); }</code><technical_language>I helper method isDifferentLanguage here</technical_language>

Target:
public static void setNewLocale(Context context, String language) { if (isSameLanguage(language)) { return; } saveLanguageToPref(context, language); updateResources(context, language); }
Source:
<code>public void testRestartWithAdvertisedAddressAsBookieID() throws Exception { String[] ledgerDirs = new String[] { newDirectory(), newDirectory(), newDirectory() }; String journalDir = newDirectory(); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration() .setZkServers(zkUtil.getZooKeeperConnectString()) .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs) .setBookiePort(bookiePort); conf.setUseHostNameAsBookieID(false); Bookie b = new Bookie(conf); b.start(); b.shutdown(); <START> conf.setAdvertisedAddress("test.bookkeeper.com"); <END> try { new Bookie(conf); fail("Should not start a bookie with ip if the bookie has been started with an ip"); } catch (InvalidCookieException e) { } }</code><technical_language>public DNS names, running test suite process invalid/suspicious network requests please change test.bookkeeper.com.localhost</technical_language>

Target:
public void testRestartWithAdvertisedAddressAsBookieID() throws Exception { String[] ledgerDirs = new String[] { newDirectory(), newDirectory(), newDirectory() }; String journalDir = newDirectory(); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration() .setZkServers(zkUtil.getZooKeeperConnectString()) .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs) .setBookiePort(bookiePort); conf.setUseHostNameAsBookieID(false); Bookie b = new Bookie(conf); b.start(); b.shutdown(); conf.setAdvertisedAddress("unknown"); try { new Bookie(conf); fail("Should not start a bookie with ip if the bookie has been started with an ip"); } catch (InvalidCookieException e) { } }
Source:
<code>private void registerErrorChannel() { if (!this.beanFactory.containsBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)) { if (logger.isInfoEnabled()) { logger.info("No bean named '" + IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME + "' has been explicitly defined. " + "Therefore, a default PublishSubscribeChannel will be created."); } this.registry.registerBeanDefinition(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, new RootBeanDefinition(PublishSubscribeChannel.class)); BeanDefinition loggingHandler = BeanDefinitionBuilder.genericBeanDefinition(LoggingHandler.class) .addConstructorArgValue("ERROR") .getBeanDefinition(); String errorLoggerBeanName = IntegrationContextUtils.ERROR_LOGGER_BEAN_NAME + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX; this.registry.registerBeanDefinition(errorLoggerBeanName, loggingHandler); BeanDefinitionBuilder loggingEndpointBuilder = BeanDefinitionBuilder.genericBeanDefinition(ConsumerEndpointFactoryBean.class) .addPropertyReference("handler", errorLoggerBeanName) .addPropertyValue("inputChannelName", IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME); BeanComponentDefinition componentDefinition = new BeanComponentDefinition(loggingEndpointBuilder.getBeanDefinition(), <START> "errorLogger", new String[] { IntegrationContextUtils.ERROR_LOGGER_BEAN_NAME }); <END> BeanDefinitionReaderUtils.registerBeanDefinition(componentDefinition, this.registry); } }</code><technical_language>Hmm... generic a name - collide a user bean. default_errorLogger integration_errorLogger si_errorLogger _si_errorLogger ... choices</technical_language>

Target:
private void registerErrorChannel() { if (!this.beanFactory.containsBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)) { if (logger.isInfoEnabled()) { logger.info("No bean named '" + IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME + "' has been explicitly defined. " + "Therefore, a default PublishSubscribeChannel will be created."); } this.registry.registerBeanDefinition(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, new RootBeanDefinition(PublishSubscribeChannel.class)); BeanDefinition loggingHandler = BeanDefinitionBuilder.genericBeanDefinition(LoggingHandler.class) .addConstructorArgValue("ERROR") .getBeanDefinition(); String errorLoggerBeanName = IntegrationContextUtils.ERROR_LOGGER_BEAN_NAME + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX; this.registry.registerBeanDefinition(errorLoggerBeanName, loggingHandler); BeanDefinitionBuilder loggingEndpointBuilder = BeanDefinitionBuilder.genericBeanDefinition(ConsumerEndpointFactoryBean.class) .addPropertyReference("handler", errorLoggerBeanName) .addPropertyValue("inputChannelName", IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME); BeanComponentDefinition componentDefinition = new BeanComponentDefinition(loggingEndpointBuilder.getBeanDefinition(), IntegrationContextUtils.ERROR_LOGGER_BEAN_NAME); BeanDefinitionReaderUtils.registerBeanDefinition(componentDefinition, this.registry); } }
Source:
<code>public Object processMessage(Message<?> message) { Object[] args = new Object[this.parameterTypes.length]; for (int i = 0; i < this.parameterTypes.length; i++) { Class<?> parameterType = this.parameterTypes[i]; if (Message.class.isAssignableFrom(parameterType)) { args[i] = message; } else if (Map.class.isAssignableFrom(parameterType)) { if (message.getPayload() instanceof Map && this.parameterTypes.length == 1) { args[i] = message.getPayload(); } else { args[i] = message.getHeaders(); } } else { if (this.payloadType != null && !ClassUtils.isAssignable(this.payloadType, message.getPayload().getClass())) { if (Message.class.isAssignableFrom(this.payloadType)) { args[i] = message; } else { args[i] = this.messageConverter.fromMessage(message, this.payloadType); } } else { args[i] = message.getPayload(); } } } try { return this.method.invoke(this.target, args); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof ClassCastException) { logger.error("Could not invoke the method due to a class cast exception, if using a lambda in the DSL, " + "consider using an overloaded EIP method that takes a Class<?> argument to explicitly " <START> + "specify the type", e.getCause()); <END> } throw new MessageHandlingException(message, e.getCause()); } catch (Exception e) { throw new MessageHandlingException(message, e); } }</code><technical_language>"... This is especially necessary if deal Message<?>". a hint</technical_language>

Target:
public Object processMessage(Message<?> message) { Object[] args = new Object[this.parameterTypes.length]; for (int i = 0; i < this.parameterTypes.length; i++) { Class<?> parameterType = this.parameterTypes[i]; if (Message.class.isAssignableFrom(parameterType)) { args[i] = message; } else if (Map.class.isAssignableFrom(parameterType)) { if (message.getPayload() instanceof Map && this.parameterTypes.length == 1) { args[i] = message.getPayload(); } else { args[i] = message.getHeaders(); } } else { if (this.payloadType != null && !ClassUtils.isAssignable(this.payloadType, message.getPayload().getClass())) { if (Message.class.isAssignableFrom(this.payloadType)) { args[i] = message; } else { args[i] = this.messageConverter.fromMessage(message, this.payloadType); } } else { args[i] = message.getPayload(); } } } try { return this.method.invoke(this.target, args); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof ClassCastException) { logger.error("Could not invoke the method due to a class cast exception, if using a lambda in the DSL, " + "consider using an overloaded EIP method that takes a Class<?> argument to explicitly " + "specify the type. An example of when this often occurs is if the lambda is configured to " + "receive a Message<?> argument.", e.getCause()); } throw new MessageHandlingException(message, e.getCause()); } catch (Exception e) { throw new MessageHandlingException(message, e); } }
Source:
<code>private void tryToUpdateForEndOfSequential(){ int curIndex = pager.getCurrentItem(); setCurrentUnit(pagerAdapter.getUnit(curIndex)); mPreviousBtn.setEnabled(curIndex > 0); mNextBtn.setEnabled(curIndex < pagerAdapter.getCount() - 1); findViewById(R.id.course_unit_nav_bar).requestLayout(); setTitle(selectedUnit.getDisplayName()); <START> String currentSubsection = selectedUnit.getParent().getName(); <END> if (curIndex + 1 <= pagerAdapter.getCount() - 1) { String nextUnitSubsection = unitList.get(curIndex + 1).getParent().getName(); if (currentSubsection.equalsIgnoreCase(nextUnitSubsection)) { mNextUnitLbl.setVisibility(View.GONE); mNextBtn.setText(R.string.assessment_next); } else { mNextUnitLbl.setText(nextUnitSubsection); mNextUnitLbl.setVisibility(View.VISIBLE); mNextBtn.setText(R.string.assessment_next_unit); } } else { mNextBtn.setText(R.string.assessment_next); mNextUnitLbl.setVisibility(View.GONE); } if (curIndex - 1 >= 0) { String prevUnitSubsection = unitList.get(curIndex - 1).getParent().getName(); if (currentSubsection.equalsIgnoreCase(prevUnitSubsection)) { mPreviousUnitLbl.setVisibility(View.GONE); mPreviousBtn.setText(R.string.assessment_previous); } else { mPreviousUnitLbl.setText(prevUnitSubsection); mPreviousUnitLbl.setVisibility(View.VISIBLE); mPreviousBtn.setText(R.string.assessment_previous_unit); } } else { mPreviousBtn.setText(R.string.assessment_previous); mPreviousUnitLbl.setVisibility(View.GONE); } }</code><technical_language>this do wrong if units name? comparing id instead</technical_language>

Target:
private void tryToUpdateForEndOfSequential(){ int curIndex = pager.getCurrentItem(); setCurrentUnit(pagerAdapter.getUnit(curIndex)); mPreviousBtn.setEnabled(curIndex > 0); mNextBtn.setEnabled(curIndex < pagerAdapter.getCount() - 1); findViewById(R.id.course_unit_nav_bar).requestLayout(); setTitle(selectedUnit.getDisplayName()); String currentSubsectionId = selectedUnit.getParent().getId(); if (curIndex + 1 <= pagerAdapter.getCount() - 1) { String nextUnitSubsectionId = unitList.get(curIndex + 1).getParent().getId(); if (currentSubsectionId.equalsIgnoreCase(nextUnitSubsectionId)) { mNextUnitLbl.setVisibility(View.GONE); mNextBtn.setText(R.string.assessment_next); } else { mNextUnitLbl.setText(unitList.get(curIndex + 1).getParent().getName()); mNextUnitLbl.setVisibility(View.VISIBLE); mNextBtn.setText(R.string.assessment_next_unit); } } else { mNextBtn.setText(R.string.assessment_next); mNextUnitLbl.setVisibility(View.GONE); } if (curIndex - 1 >= 0) { String prevUnitSubsectionId = unitList.get(curIndex - 1).getParent().getId(); if (currentSubsectionId.equalsIgnoreCase(prevUnitSubsectionId)) { mPreviousUnitLbl.setVisibility(View.GONE); mPreviousBtn.setText(R.string.assessment_previous); } else { mPreviousUnitLbl.setText(unitList.get(curIndex - 1).getParent().getName()); mPreviousUnitLbl.setVisibility(View.VISIBLE); mPreviousBtn.setText(R.string.assessment_previous_unit); } } else { mPreviousBtn.setText(R.string.assessment_previous); mPreviousUnitLbl.setVisibility(View.GONE); } }
Source:
<code>public void onNodeTimeout() { String dataNodeStr; try { <START> dataNodeStr = toJSONObject().toString(); <END> } catch (JSONException e) { dataNodeStr = null; } logger.info("Node [" + dataNodeStr + "] timed out, informing resource state"); if (dataNodeStatePolicy.onError()) { logger.info("Node [" + dataNodeStr + "] was determined to be down"); } }</code><technical_language>good avoid converting node a JSON a String is expensive. define a toString if is defined log(this)</technical_language>

Target:
public void onNodeTimeout() { dataNodeStatePolicy.onError(); }
Source:
<code>public final int formalKeyLookup(final String name) { <START> if(!naturalKeyTable.containsKey(name)) <END> { throw new IllegalArgumentException("Unrecognized formal key name: " + name); } return naturalKeyTable.get(name).intValue(); }</code><technical_language>below: previously code table lookup operation, performs lookups. Please consider get(name) check decide if is illegal not</technical_language>

Target:
public final int formalKeyLookup(final String name) { final Integer value = naturalKeyTable.get(name); if (value == null) { throw new IllegalArgumentException("Unrecognized formal key name: " + name); } return value.intValue(); }
Source:
<code>public SwitchUserWebFilter(ReactiveUserDetailsService userDetailsService, String successTargetUrl, @Nullable String failureTargetUrl) { Assert.notNull(userDetailsService, "userDetailsService must be specified"); Assert.notNull(successTargetUrl, "successTargetUrl must be specified"); this.userDetailsService = userDetailsService; this.successHandler = new RedirectServerAuthenticationSuccessHandler(successTargetUrl); <START> this.failureHandler = Optional.ofNullable(failureTargetUrl). <END> map(RedirectServerAuthenticationFailureHandler::new).orElse(null); this.securityContextRepository = new WebSessionServerSecurityContextRepository(); this.userDetailsChecker = new AccountStatusUserDetailsChecker(); }</code><technical_language>In order reduce overhead of creating additional objects, prefer null checks instead of Optional.ofNullable. For more information gh-7155</technical_language>

Target:
public SwitchUserWebFilter(ReactiveUserDetailsService userDetailsService, String successTargetUrl, @Nullable String failureTargetUrl) { Assert.notNull(userDetailsService, "userDetailsService must be specified"); Assert.notNull(successTargetUrl, "successTargetUrl must be specified"); this.userDetailsService = userDetailsService; this.successHandler = new RedirectServerAuthenticationSuccessHandler(successTargetUrl); if (failureTargetUrl != null) { this.failureHandler = new RedirectServerAuthenticationFailureHandler(failureTargetUrl); } else { this.failureHandler = null; } this.securityContextRepository = new WebSessionServerSecurityContextRepository(); this.userDetailsChecker = new AccountStatusUserDetailsChecker(); }
Source:
<code>public Stroll() { Gdx.app.log(TAG, "Started new stroll"); cRewards = 0; cEventGoing = false; cEventThreshold = BASE_THRESHOLD; cFinished = false; cEndStrollSubject = new Subject(); cNewEventSubject = new Subject(); cEndEventSubject = new Subject(); StandUp.getInstance().getUpdateSubject().addObserver(this); <START> StandUp.getInstance().getAccelerationStatus().getSubject().addObserver(cUpdateMovementObserver); <END> cStrollTimer = TimerStore.getInstance().getTimer(Timer.Global.STROLL.name()); cStrollTimer.getStopSubject().addObserver(cStrollStopObserver); cStrollTimer.reset(); }</code><technical_language>split lines for readabilty</technical_language>

Target:
public Stroll() { Gdx.app.log(TAG, "Started new stroll"); cRewards = new ArrayList<Integer>(); cEventGoing = false; cEventThreshold = getAmplifier(StandUp.getInstance(). getAccelerationStatus().getAccelerationState()); cFinished = false; cEndStrollSubject = new Subject(); cNewEventSubject = new Subject(); cEndEventSubject = new Subject(); StandUp.getInstance().getUpdateSubject().addObserver(this); StandUp.getInstance().getAccelerationStatus(). getSubject().addObserver(cUpdateMovementObserver); cStrollTimer = TimerStore.getInstance().getTimer(Timer.Global.STROLL.name()); cStrollTimer.getStopSubject().addObserver(cStrollStopObserver); cStrollTimer.reset(); }
Source:
<code><START> public Map<String, String> toConfig() { <END> HashMap<String, String> configs = new HashMap<>(super.toConfig()); String streamId = getStreamId(); getOffsetDefault().ifPresent(od -> configs.put(String.format(OFFSET_DEFAULT_CONFIG_KEY, streamId), od.name().toLowerCase())); isResetOffset().ifPresent(resetOffset -> configs.put(String.format(RESET_OFFSET_CONFIG_KEY, streamId), Boolean.toString(resetOffset))); getPriority().ifPresent(priority -> configs.put(String.format(PRIORITY_CONFIG_KEY, streamId), Integer.toString(priority))); isBootstrap().ifPresent(bootstrap -> configs.put(String.format(BOOTSTRAP_CONFIG_KEY, streamId), Boolean.toString(bootstrap))); isBounded().ifPresent(bounded -> configs.put(String.format(BOUNDED_CONFIG_KEY, streamId), Boolean.toString(bounded))); shouldDeleteCommittedMessages().ifPresent(deleteCommittedMessages -> configs.put(String.format(DELETE_COMMITTED_MESSAGES_CONFIG_KEY, streamId), Boolean.toString(deleteCommittedMessages))); return Collections.unmodifiableMap(configs); }</code><technical_language>helpful provide a ensure necessary config keys get put in (e.g. adding new configs)? option enum for configs instead of plain strings, do some validation enum values covered in map</technical_language>

Target:
public Map<String, String> toConfig() { HashMap<String, String> configs = new HashMap<>(super.toConfig()); String streamId = getStreamId(); this.offsetDefaultOptional.ifPresent(od -> configs.put(String.format(OFFSET_DEFAULT_CONFIG_KEY, streamId), od.name().toLowerCase())); this.resetOffsetOptional.ifPresent(resetOffset -> configs.put(String.format(RESET_OFFSET_CONFIG_KEY, streamId), Boolean.toString(resetOffset))); this.priorityOptional.ifPresent(priority -> configs.put(String.format(PRIORITY_CONFIG_KEY, streamId), Integer.toString(priority))); this.isBootstrapOptional.ifPresent(bootstrap -> configs.put(String.format(BOOTSTRAP_CONFIG_KEY, streamId), Boolean.toString(bootstrap))); this.isBoundedOptional.ifPresent(bounded -> configs.put(String.format(BOUNDED_CONFIG_KEY, streamId), Boolean.toString(bounded))); this.deleteCommittedMessagesOptional.ifPresent(deleteCommittedMessages -> configs.put(String.format(DELETE_COMMITTED_MESSAGES_CONFIG_KEY, streamId), Boolean.toString(deleteCommittedMessages))); return Collections.unmodifiableMap(configs); }
Source:
<code>public String getPrettyName() { <START> return prettyName == null ? "" : prettyName; <END> }</code><technical_language>need here, null is OK if pretty name specified</technical_language>

Target:
public String getPrettyName() { return prettyName; }
Source:
<code>public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() { <START> Map<String, TmfAnalysisRequirement> requirements = new HashMap<>(); <END> String eventNameType = TmfXmlStrings.TYPE_EVENT_NAME; requirements.put(eventNameType, new TmfAnalysisRequirement(eventNameType)); NodeList eventHandlerElements = fSourceElement.getElementsByTagName(TmfXmlStrings.EVENT_HANDLER); for (int i = 0; i < eventHandlerElements.getLength(); i++) { String eventName = ((Element) eventHandlerElements.item(i)).getAttribute(eventNameType); requirements.get(eventNameType).addValue(eventName, AnalysisRequirementValueLevel.MANDATORY); } return requirements.values(); }</code><technical_language>requirement put is type_event_name. a single requirement, add events it, return a Collections.singleton(requirement)</technical_language>

Target:
public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() { String eventNameType = TmfXmlStrings.TYPE_EVENT_NAME; TmfAnalysisRequirement requirement = new TmfAnalysisRequirement(eventNameType); for (Element eventHandler : XmlUtils.getChildElements(fSourceElement, TmfXmlStrings.EVENT_HANDLER)) { String eventName = eventHandler.getAttribute(eventNameType); requirement.addValue(eventName, ValuePriorityLevel.MANDATORY); } return Collections.singleton(requirement); }
Source:
<code>public void setPrettyPrinterInitializer(AsyncPrettyPrinterInitializer initializer) { <START> mPrettyPrinterInitializer = Util.throwIfNull(initializer); <END> }</code><technical_language>throw if mPrettyPrinterInitializer is null. Basically allow setPrettyPrinterInitializer called once</technical_language>

Target:
public void setPrettyPrinterInitializer(AsyncPrettyPrinterInitializer initializer) { Util.throwIfNotNull(mPrettyPrinterInitializer); mPrettyPrinterInitializer = Util.throwIfNull(initializer); }
Source:
<code>protected boolean validate() { NetworkValidator validator = new NetworkValidator(vmDao, getNetworkDao().get(getNetwork().getId())); ValidationResult <START> providerValidationResult = <END> validateRemoveExternalNetwork(); return validate(validator.networkIsSet(getParameters().getId())) && validate(validator.notRemovingManagementNetwork()) && validate(validator.notIscsiBondNetwork()) && validate(validator.networkNotUsedByVms()) && validate(validator.networkNotUsedByTemplates()) && validate(providerValidationResult); }</code><technical_language>if I understand correctly, this evaluated first, if networkIsSet is valid, reported. of that, rename 'validateRemoveExternalNetwork' provides information this is provider validation, inline this variable. this evaluated preceding validations #115-#119 succeeded</technical_language>

Target:
protected boolean validate() { NetworkValidator validator = new NetworkValidator(vmDao, getNetworkDao().get(getNetwork().getId())); return validate(validator.networkIsSet(getParameters().getId())) && validate(validator.notRemovingManagementNetwork()) && validate(validator.notIscsiBondNetwork()) && validate(validator.networkNotUsedByVms()) && validate(validator.networkNotUsedByTemplates()) && validate(getRemoveExternalNetworkValidationResult()); }
Source:
<code>public int hashCode() { if (elements == null) { return Objects.hash(comparer); } <START> int r = 1; <END> if (comparer != null) { r = 31 + comparer.hashCode(); for (Object e : elements) { r = 31 * r + (e == null ? 0 : comparer.hashCode(e)); } } else { Arrays.hashCode(elements); } return r; }</code><technical_language>assignment effect</technical_language>

Target:
public int hashCode() { if (elements == null) { return Objects.hash(comparer); } int r; if (comparer != null) { r = 31 + comparer.hashCode(); for (Object e : elements) { r = 31 * r + (e == null ? 0 : comparer.hashCode(e)); } } else { r = Arrays.hashCode(elements); } return r; }
Source:
<code>public String getCaptchaUrl(Site site) { <START> return site.getFullPath("index.php") + "?title=Special:Captcha/image&wpCaptchaId=" + captchaId; <END> }</code><technical_language>compile. "getFullUrl"</technical_language>

Target:
public String getCaptchaUrl(Site site) { return site.getFullUrl("index.php") + "?title=Special:Captcha/image&wpCaptchaId=" + captchaId; }
Source:
<code>public void visitMethod(MethodTree tree) { if (isConstructor(tree)) { final Set<String> methodParams = methodParams(tree); final Set<Tree> errors = Sets.newHashSet(); <START> tree.accept(new BaseTreeVisitor() { <END> @Override public void visitMemberSelectExpression(MemberSelectExpressionTree tree) { if (classVisitor.annotatedVariables.contains(tree.identifier().symbol().name())) { errors.add(tree); } super.visitMemberSelectExpression(tree); } @Override public void visitIdentifier(IdentifierTree tree) { if (tree.symbol().isVariableSymbol()) { if (!methodParams.contains(tree.symbol().name())) { if (classVisitor.annotatedVariables.contains(tree.symbol().name())) { errors.add(tree); } } } super.visitIdentifier(tree); } }); for (Tree error : errors) { context.addIssue(error, this, RULE_MESSAGE); } } super.visitMethod(tree); }</code><technical_language>I extract more readable</technical_language>

Target:
public void visitMethod(MethodTree tree) { if (tree.is(MethodTree.Kind.CONSTRUCTOR)) { CheckUsageInConstructorVisitor visitor = new CheckUsageInConstructorVisitor(methodParams(tree)); tree.accept(visitor); for (Tree error : visitor.getErrors()) { context.addIssue(error, this, RULE_MESSAGE); } } super.visitMethod(tree); }
Source:
<code>private void parse(File targetFile) throws IOException { BufferedReader br = new BufferedReader(new FileReader(targetFile)); String txt; while ((txt = br.readLine()) != null) { txt = txt.trim(); if (txt.length() > 0 && !txt.startsWith("#")) { rules.add(new IgnoreRule(txt)); } } <START> <END> }</code><technical_language>Close reader done it</technical_language>

Target:
private void parse(File targetFile) throws IOException { BufferedReader br = new BufferedReader(new FileReader(targetFile)); String txt; try { while ((txt = br.readLine()) != null) { txt = txt.trim(); if (txt.length() > 0 && !txt.startsWith("#")) { rules.add(new IgnoreRule(txt)); } } } catch (IOException e) { throw e; } finally { br.close(); } }
Source:
<code>public void initialize(Context context) { context.registerSyntaxNodeConsumer(Tree.Kind.FUNCDEF, ctx -> { FunctionDef functionDef = (FunctionDef) ctx.syntaxNode(); ControlFlowGraph cfg = ControlFlowGraph.build(functionDef, ctx.pythonFile()); if (cfg == null) { return; } LiveVariablesAnalysis lva = analyze(cfg); Set<CfgBlock> unreachableBlocks = CfgUtils.unreachableBlocks(cfg); cfg.blocks().forEach(block -> { List<DeadStoreUtils.UnnecessaryAssignment> unnecessaryAssignments = DeadStoreUtils.findUnnecessaryAssignments(block, lva.getLiveVariables(block), functionDef); unnecessaryAssignments.stream() .filter((assignment -> isParameter(assignment.element))) .filter(assignment -> assignment.symbol.usages().stream().filter(Usage::isBindingUsage).count() > 1) <START> .filter(assignment -> !isSymbolUsedInUnreachableBlocks(lva.getLiveVariables(block), unreachableBlocks, assignment.symbol)) <END> .filter((assignment -> !isUsedInSubFunction(assignment.symbol, functionDef))) .forEach(assignment -> ctx.addIssue(assignment.element, String.format(MESSAGE_TEMPLATE, assignment.symbol.name()))); }); }); }</code><technical_language>change rule in a PR is supposed rule S3827</technical_language>

Target:
public void initialize(Context context) { context.registerSyntaxNodeConsumer(Tree.Kind.FUNCDEF, ctx -> { FunctionDef functionDef = (FunctionDef) ctx.syntaxNode(); ControlFlowGraph cfg = ControlFlowGraph.build(functionDef, ctx.pythonFile()); if (cfg == null) { return; } LiveVariablesAnalysis lva = LiveVariablesAnalysis.analyze(cfg); Set<CfgBlock> unreachableBlocks = CfgUtils.unreachableBlocks(cfg); cfg.blocks().forEach(block -> { List<DeadStoreUtils.UnnecessaryAssignment> unnecessaryAssignments = DeadStoreUtils.findUnnecessaryAssignments(block, lva.getLiveVariables(block), functionDef); unnecessaryAssignments.stream() .filter((assignment -> isParameter(assignment.element))) .filter(assignment -> assignment.symbol.usages().stream().filter(Usage::isBindingUsage).count() > 1) .filter(assignment -> !isSymbolUsedInUnreachableBlocks(lva, unreachableBlocks, assignment.symbol)) .filter((assignment -> !isUsedInSubFunction(assignment.symbol, functionDef))) .forEach(assignment -> ctx.addIssue(assignment.element, String.format(MESSAGE_TEMPLATE, assignment.symbol.name()))); }); }); }
Source:
<code>protected void addPages() { try { gettingStartedPage = new GettingStartedHtmlPage(this); int index = addPage(gettingStartedPage); if (gettingStartedImage == null) { gettingStartedImage = JBossCentralActivator.getImageDescriptor( "/icons/gettingStarted.png").createImage(); } setPageImage(index, gettingStartedImage); <START> if (!new EclipseUserAgent().getApplicationName().contains("rh-eclipse")) { END> softwarePage = new SoftwarePage(this); index = addPage(softwarePage); if (softwareImage == null) { softwareImage = JBossCentralActivator.getImageDescriptor( "/icons/software.png").createImage(); } setPageImage(index, softwareImage); } } catch (PartInitException e) { JBossCentralActivator.log(e, "Error adding page"); } }</code><technical_language>pop alert right if check user (me) EclipseUserAgent().getApplicationName() contains? is "pop alert" do in javascript debugging? :D</technical_language>

Target:
protected void addPages() { try { gettingStartedPage = new GettingStartedHtmlPage(this); int index = addPage(gettingStartedPage); if (gettingStartedImage == null) { gettingStartedImage = JBossCentralActivator.getImageDescriptor( "/icons/gettingStarted.png").createImage(); } setPageImage(index, gettingStartedImage); String applicationName = JBossToolsUsageActivator.getDefault().getJBossToolsEclipseEnvironment().getEclipseUserAgent().getApplicationName(); if (!applicationName.contains("|Devstudio")) { softwarePage = new SoftwarePage(this); index = addPage(softwarePage); if (softwareImage == null) { softwareImage = JBossCentralActivator.getImageDescriptor( "/icons/software.png").createImage(); } setPageImage(index, softwareImage); } else { JBossCentralActivator.logWarning("JBoss Tools installed via a package manager. \"Software/Update\" is disabled for Red Hat Central. Detected application name with installed packages: \"" + applicationName + "\""); } } catch (PartInitException e) { JBossCentralActivator.log(e, "Error adding page"); } }
Source:
<code>public static ControlFlowGraph build(Tree tree, CheckContext context) { if (failedTrees.contains(tree)) { return null; } try { switch (tree.getKind()) { case FUNCTION_DECLARATION: return build(((FunctionDeclarationTree) tree).body()); case FUNCTION_EXPRESSION: return build(((FunctionExpressionTree) tree).body()); case METHOD_DECLARATION: Tree body = ((MethodDeclarationTree) tree).body(); if (body.is(Tree.Kind.BLOCK)) { return build(((BlockTree) body)); } else { return null; } case SCRIPT: return build(((ScriptTree) tree)); default: throw new IllegalStateException("Unexpected tree kind " + tree.getKind()); } } catch (Exception e) { <START> LOG.warn("Failed to build control flow graph for file at line caused by : {}", context.getPhpFile().toString(), ((PHPTree) tree).getLine(), e.getCause()); <END> LOG.debug(() -> Throwables.getStackTraceAsString(e)); failedTrees.add(tree); } return null; }</code><technical_language>e.getCause() returns a stacktrace of a root exception, want (as huge level give information). e.getMessage() do a job</technical_language>

Target:
public static ControlFlowGraph build(Tree tree, CheckContext context) { if (failedTrees.contains(tree)) { return null; } try { switch (tree.getKind()) { case FUNCTION_DECLARATION: return build(((FunctionDeclarationTree) tree).body()); case FUNCTION_EXPRESSION: return build(((FunctionExpressionTree) tree).body()); case METHOD_DECLARATION: Tree body = ((MethodDeclarationTree) tree).body(); if (body.is(Tree.Kind.BLOCK)) { return build(((BlockTree) body)); } else { return null; } case SCRIPT: return build(((ScriptTree) tree)); default: throw new IllegalStateException("Unexpected tree kind " + tree.getKind()); } } catch (Exception e) { LOG.warn("Failed to build control flow graph for file at line (activate debug logs for more details)", context.getPhpFile().toString(), ((PHPTree) tree).getLine()); LOG.debug(() -> Throwables.getStackTraceAsString(e)); failedTrees.add(tree); } return null; }
Source:
<code>void apply(File path, boolean delete, Properties templateProperties) throws IOException { if (path.getName().startsWith(".") || path.isHidden() || path.getName().endsWith("~")) { LOGGER.info("Skip {}", path.getAbsolutePath()); } if (path.isDirectory()) { File[] files = path.listFiles(); Arrays.sort(files); if (delete) { ArrayUtils.reverse(files); } for (File f : files) { apply(f, delete, templateProperties); } } else if (path.isFile()) { K8sSpecTemplate specTemplate = new K8sSpecTemplate(); <START> String template = specTemplate.render(path); <END> specTemplate.loadProperties(templateProperties); ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> k8sObjects = client.load(IOUtils.toInputStream(template, StandardCharsets.UTF_8)); LOGGER.info("Apply with K8s Objects", path.getAbsolutePath(), k8sObjects.get().size()); LOGGER.debug(template); if (delete) { k8sObjects.inNamespace(namespace).delete(); } else { k8sObjects.inNamespace(namespace).createOrReplace(); } } else { LOGGER.error("Can't apply {}", path.getAbsolutePath()); } }</code><technical_language>loadProperties() render()</technical_language>

Target:
void apply(File path, boolean delete, Properties templateProperties) throws IOException { if (path.getName().startsWith(".") || path.isHidden() || path.getName().endsWith("~")) { LOGGER.info("Skip {}", path.getAbsolutePath()); } if (path.isDirectory()) { File[] files = path.listFiles(); Arrays.sort(files); if (delete) { ArrayUtils.reverse(files); } for (File f : files) { apply(f, delete, templateProperties); } } else if (path.isFile()) { K8sSpecTemplate specTemplate = new K8sSpecTemplate(); specTemplate.loadProperties(templateProperties); String template = specTemplate.render(path); ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> k8sObjects = client.load(IOUtils.toInputStream(template, StandardCharsets.UTF_8)); LOGGER.info("Apply with K8s Objects", path.getAbsolutePath(), k8sObjects.get().size()); LOGGER.debug(template); if (delete) { k8sObjects.inNamespace(namespace).delete(); } else { k8sObjects.inNamespace(namespace).createOrReplace(); } } else { LOGGER.error("Can't apply {}", path.getAbsolutePath()); } }
Source:
<code>public static void CustomOfflineSnackbar(View view) { <START> Snackbar.make(view, "Offline Mode (No Internet)", Snackbar.LENGTH_INDEFINITE) <END> .setActionTextColor(Color.DKGRAY) .show(); }</code><technical_language>Please translatable</technical_language>

Target:
public static void CustomOfflineSnackbar(View view) { Snackbar.make(view, R.string.SnackbarOfflineText, Snackbar.LENGTH_INDEFINITE) .setActionTextColor(Color.DKGRAY) .show(); }
Source:
<code>public static HashCode buildTreeHashFromMap(Map<Integer, HashCode> map) { SortedMap<Integer, HashCode> sortedMap = ImmutableSortedMap.copyOf(map); ArrayList<HashCode> list = Lists.newArrayList(); <START> for (Map.Entry<Integer, HashCode> entry : sortedMap.entrySet()) { <END> list.add(entry.getValue()); } return hashList(list).remove(0); }</code><technical_language>write this more succinctly as: List<HashCode> list = Lists.newArrayList(ImmutableSortedMap.copyOf(map).values()); need ArrayList copy if change some of methods a Collection instead</technical_language>

Target:
public static HashCode buildTreeHashFromMap(Map<Integer, HashCode> map) { checkArgument(!map.isEmpty(), "The map cannot be empty."); return hashList(ImmutableSortedMap.copyOf(map).values()); }
Source:
<code>private void initContent() { setLayout(new FillLayout()); fGlobalPC = null; fTimeRangePC = null; mouseListenerGlobal = new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { PieChart pc = getGlobalPC(); switch (event.type) { case SWT.MouseMove: int sliceIndex = pc.getSliceIndexFromPosition(0, event.x, event.y); if (sliceIndex < 0) { pc.setToolTipText(null); break; } float percOfSlice = (float) pc.getSlicePercent(0, sliceIndex); String percent = String.format("%.1f", percOfSlice); Long nbEvents = Long.valueOf((long) pc.getSeriesSet().getSeries()[sliceIndex].getXSeries()[0]); <START> String text = "Name = " + pc.getSeriesSet().getSeries()[sliceIndex].getId() + "\n"; END> text += "Event Count = " + nbEvents.toString() + " (" + percent + "%)"; pc.setToolTipText(text); return; default: } } }; mouseListenerSelection = new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { PieChart pc = getTimeRangePC(); switch (event.type) { case SWT.MouseMove: int sliceIndex = pc.getSliceIndexFromPosition(0, event.x, event.y); if (sliceIndex < 0) { pc.setToolTipText(null); break; } float percOfSlice = (float) pc.getSlicePercent(0, sliceIndex); String percent = String.format("%.1f", percOfSlice); Long nbEvents = Long.valueOf((long) pc.getSeriesSet().getSeries()[sliceIndex].getXSeries()[0]); String text = "Name = " + pc.getSeriesSet().getSeries()[sliceIndex].getId() + "\n"; text += "Event Count = " + nbEvents.toString() + " (" + percent + "%)"; pc.setToolTipText(text); return; default: } } }; setCurrentState(new PieChartViewerStateNoContentSelected(this)); }</code><technical_language>Externalize strings for tooltip</technical_language>

Target:
private void initContent() { setLayout(new FillLayout()); fGlobalPC = null; fTimeRangePC = null; fMouseListener = new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { PieChart pc = (PieChart) event.widget; switch (event.type) { case SWT.MouseMove: int sliceIndex = pc.getSliceIndexFromPosition(0, event.x, event.y); if (sliceIndex < 0) { pc.setToolTipText(null); break; } float percOfSlice = (float) pc.getSlicePercent(0, sliceIndex); String percent = String.format("%.1f", percOfSlice); Long nbEvents = Long.valueOf((long) pc.getSeriesSet().getSeries()[sliceIndex].getXSeries()[0]); String text = Messages.TmfStatisticsView_PieChartToolTipTextName + " = " + pc.getSeriesSet().getSeries()[sliceIndex].getId() + "\n"; text += Messages.TmfStatisticsView_PieChartToolTipTextEventCount + " = " + nbEvents.toString() + " (" + percent + "%)"; pc.setToolTipText(text); return; default: } } }; setCurrentState(new PieChartViewerStateNoContentSelected(this)); }
Source:
<code>public void testSetsTextViewCharSequence() { final PublishSubject<String> subject = PublishSubject.create(); subject.subscribe(ViewActions.setText(textView)); subject.onNext("Hello"); <START> verify(textView, times(1)).setText("Hello"); <END> subject.onNext("World"); verify(textView, times(1)).setText("World"); }</code><technical_language>times(1) is default, omitted</technical_language>

Target:
public void testSetsTextViewCharSequence() { final PublishSubject<String> subject = PublishSubject.create(); subject.subscribe(ViewActions.setText(textView)); subject.onNext("Hello"); verify(textView).setText("Hello"); subject.onNext("World"); verify(textView).setText("World"); }
Source:
<code>public void handleData(final ITmfEvent event) { super.handleData(event); if (isCancelled()) { return; } try { if (fFilter == null || fFilter.matches(event)) { if (fTable != null) { ITmfEventField[] fields = fTable.extractItemFields(event); boolean needTab = false; for (ITmfEventField field: fields) { if (needTab) { fWriter.write('\t'); } <START> fWriter.write(field.getValue().toString()); <END> needTab = true; } } else { fWriter.write(event.getTimestamp().toString()); fWriter.write('\t'); fWriter.write(event.getSource()); fWriter.write('\t'); fWriter.write(event.getType().getName()); fWriter.write('\t'); fWriter.write(event.getReference()); fWriter.write('\t'); ITmfEventField content = event.getContent(); String value = content.getFormattedValue(); fWriter.write(value); } fWriter.write('\n'); } } catch (IOException ex) { fIOException = ex; fail(); } }</code><technical_language>I a trace fields field.getValue() returns null. Please add a null check for it. if is null write empty string. fWriter.write((field.getValue() != null) ? field.getValue().toString() : ""); //$NON-NLS-1$</technical_language>

Target:
public void handleData(final ITmfEvent event) { super.handleData(event); if (isCancelled()) { return; } try { if (fFilter == null || fFilter.matches(event)) { if (fTable != null) { ITmfEventField[] fields = fTable.getItemFields(event); boolean needTab = false; for (ITmfEventField field: fields) { if (needTab) { fWriter.write('\t'); } Object value = field.getValue(); printValue(value); needTab = true; } } else { fWriter.write(event.getTimestamp().toString()); fWriter.write('\t'); fWriter.write(event.getSource()); fWriter.write('\t'); fWriter.write(event.getType().getName()); fWriter.write('\t'); fWriter.write(event.getReference()); fWriter.write('\t'); ITmfEventField content = event.getContent(); printValue(content.getValue()); } fWriter.write('\n'); } } catch (IOException ex) { fIOException = ex; fail(); } }
Source:
<code>public MachineSource saveToSnapshot(String owner) throws MachineException { try { final String repository = generateRepository(); String comment = format("Suspended at %1$ta %1$tb %1$td %1$tT %1$tZ %1$tY", System.currentTimeMillis()); if (owner != null) { comment = comment + " by " + owner; } final String LATEST_TAG = "latest"; docker.commit(container, registry + '/' + repository, LATEST_TAG, comment, owner); Thread.sleep(2000); final ProgressLineFormatterImpl progressLineFormatter = new ProgressLineFormatterImpl(); String digest = docker.push(repository, LATEST_TAG, registry, currentProgressStatus -> { try { outputConsumer.writeLine(progressLineFormatter.format(currentProgressStatus)); } catch (IOException ignored) { } }); docker.removeImage(registry + '/' + repository, false); <START> return new DockerMachineSource(repository).setRegistry(registry).setDigest(digest).setTag(LATEST_TAG); <END> } catch (IOException e) { throw new MachineException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new MachineException(e.getLocalizedMessage(), e); } }</code><technical_language>fluent style setters, please consider usage of methods instead</technical_language>

Target:
public MachineSource saveToSnapshot(String owner) throws MachineException { try { final String repository = generateRepository(); if(!snapshotUseRegistry) { commitContainer(owner, repository, LATEST_TAG); return new DockerMachineSource(repository).withTag(LATEST_TAG); } final String repositoryName = registry + '/' + repository; commitContainer(owner, repositoryName, LATEST_TAG); Thread.sleep(2000); final ProgressLineFormatterImpl lineFormatter = new ProgressLineFormatterImpl(); final String digest = docker.push(PushParams.create(repository) .withTag(LATEST_TAG) .withRegistry(registry), progressMonitor -> { try { outputConsumer.writeLine(lineFormatter.format(progressMonitor)); } catch (IOException ignored) { } }); docker.removeImage(RemoveImageParams.create(repositoryName).withForce(false)); return new DockerMachineSource(repository).withRegistry(registry).withDigest(digest).withTag(LATEST_TAG); } catch (IOException ioEx) { throw new MachineException(ioEx); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new MachineException(e.getLocalizedMessage(), e); } }