auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void deletePhenotype(final Integer phenotypeId) { <START> final Phenotype phenotype = new Phenotype(); <END> phenotype.setPhenotypeId(phenotypeId); this.daoFactory.getPhenotypeDAO().makeTransient(phenotype); }</code><technical_language>@darla-leafnode deleting a phenotype impact status for values related observation unit. For example, phenotype want delete is input for a formula, status of formula result marked OUT_OF_SYNC</technical_language>

Target:
public void deletePhenotype(final Integer phenotypeId) { final Phenotype phenotype = this.daoFactory.getPhenotypeDAO().getById(phenotypeId); final Integer observableId = phenotype.getObservableId(); final Integer observationUnitId = phenotype.getExperiment().getNdExperimentId(); this.daoFactory.getPhenotypeDAO().makeTransient(phenotype); this.updateDependentPhenotypesStatus(observableId, observationUnitId); }
Source:
<code>public int getNumberOfTypes(Player player) { if (player == null || player.getInheritance() == null || !this.equals(Cards.estate)) { return types.length; } <START> return player.getInheritance().getNumberOfTypes(player); <END> }</code><technical_language>Need add types of Estate card (i.e. Victory)</technical_language>

Target:
public int getNumberOfTypes(Player player) { if (player == null || player.getInheritance() == null || !this.equals(Cards.estate)) { return types.length; } Set<Type> typeSet = new HashSet<Type>(); typeSet.addAll(Arrays.asList(player.getInheritance().getTypes())); typeSet.addAll(Arrays.asList(types)); return typeSet.size(); }
Source:
<code>public Void presentation(String programName, String programEditor, String applicationHomepage, String scriptorName) { <START> final String htmlToShow = "<body>" + tr("Installation Wizard for {0}", programName) <END> + ".<br><br>" + tr("Installation Script by {0}", programEditor) + "<br><br>" + tr("For more information about this program, visit:") + String.format("<br><a href=\"%1$s\">%1$s</a><br><br>", applicationHomepage) + tr("Installation Script by {0}", scriptorName) + "<br><br>" + "<br><br>" + tr("{0} will be installed in: {1}", programName, applicationUserRoot) + "<br><br>" + tr("{0} is not responsible for anything that might happen as a result of using these scripts.", applicationName) + "<br><br>" + tr("Click \"Next\" to start.") + "</body>"; return messageSender.runAndWait(message -> setupUi.showHtmlPresentationStep(message, htmlToShow)); }</code><technical_language>uppercase wizard script</technical_language>

Target:
public Void presentation(String programName, String programEditor, String applicationHomepage, String scriptorName) { final String htmlToShow = "<body>" + tr("Installation wizard for {0}", programName) + ".<br><br>" + tr("Installation script by {0}", programEditor) + "<br><br>" + tr("For more information about this program, visit:") + String.format("<br><a href=\"%1$s\">%1$s</a><br><br>", applicationHomepage) + tr("Installation script by {0}", scriptorName) + "<br><br>" + "<br><br>" + tr("{0} will be installed in: {1}", programName, applicationUserRoot) + "<br><br>" + tr("{0} is not responsible for anything that might happen as a result of using these scripts.", applicationName) + "<br><br>" + tr("Click \"Next\" to start.") + "</body>"; return messageSender.runAndWait(message -> setupUi.showHtmlPresentationStep(message, htmlToShow)); }
Source:
<code>public ListIterator<T> listIterator(final int index) { try { return this.origin.listIterator(index); } catch (final IndexOutOfBoundsException ex) { <START> throw new IllegalArgumentException(this.message, ex); <END> } }</code><technical_language>@Happy-Neko here, IndexOutOfBoundsException custom message</technical_language>

Target:
public ListIterator<T> listIterator(final int index) { try { return this.origin.listIterator(index); } catch (final IndexOutOfBoundsException ex) { throw this.wrapException(ex); } }
Source:
<code>private void initAttestation() { List<VDSGroup> vdsGroups = DbFacade.getInstance().getVdsGroupDao().getTrustedClusters(); List<VDS> trustedVdsList = new ArrayList<>(); List<String> trustedVdsNames = new ArrayList<>(); if (vdsGroups == null || vdsGroups.size() == 0) { return; } for (VDSGroup vdsGroup : vdsGroups) { <START> List<VDS> vdssInGroup = DbFacade.getInstance().getVdsDao().getAllForVdsGroup(vdsGroup.getId()); <END> if (vdssInGroup != null) { trustedVdsList.addAll(vdssInGroup); } } for (VDS vds : trustedVdsList) { trustedVdsNames.add(vds.getHostName()); setNonOperational(NonOperationalReason.UNINITIALIZED, vds); } try { AttestThread attestThread = new AttestThread(trustedVdsNames); attestThread.start(); } catch (Exception e) { log.error("Failed to initialize attestation cache", e); } }</code><technical_language>hosts? hosts? i dont a reason change hosts in non-responsive,non-operational maintenance..</technical_language>

Target:
private void initAttestation() { List<VDSGroup> vdsGroups = DbFacade.getInstance().getVdsGroupDao().getTrustedClusters(); List<VDS> trustedVdsList = new ArrayList<>(); List<String> trustedVdsNames = new ArrayList<>(); if (vdsGroups == null || vdsGroups.size() == 0) { return; } for (VDSGroup vdsGroup : vdsGroups) { List<VDS> vdssInGroup = DbFacade.getInstance().getVdsDao(). getAllForVdsGroupWithStatus(vdsGroup.getId(), VDSStatus.Up); if (vdssInGroup != null) { trustedVdsList.addAll(vdssInGroup); } } for (VDS vds : trustedVdsList) { trustedVdsNames.add(vds.getHostName()); setNonOperational(NonOperationalReason.UNINITIALIZED, vds); } try { AttestThread attestThread = new AttestThread(trustedVdsNames); attestThread.start(); } catch (Exception e) { log.error("Failed to initialize attestation cache", e); } }
Source:
<code>protected ArrayList<TaskAttribute> parseFromJson(InputStreamReader in) { <START> TypeToken<ArrayList<TaskAttribute>> <END> type = new TypeToken<ArrayList<TaskAttribute>>() { }; return new GsonBuilder().registerTypeAdapter(type.getType(), new JSonTaskDataDeserializer()) .setExclusionStrategies(exclustionStrategy) .create() .fromJson(in, type.getType()); }</code><technical_language>List</technical_language>

Target:
protected ArrayList<TaskAttribute> parseFromJson(InputStreamReader in) { TypeToken<ArrayList<TaskAttribute>> type = new TypeToken<ArrayList<TaskAttribute>>() { }; return new GsonBuilder().registerTypeAdapter(type.getType(), new JSonTaskDataDeserializer()) .create() .fromJson(in, type.getType()); }
Source:
<code><START> public ISelectionListener addPredicate(Predicate<ISelectionModel> predicate) { <END> if (predicate != null) { fPredicate = fPredicate.and(predicate); } return this; }</code><technical_language>Returning ISelectionListener this method blocks possibility add predicates in a "chain" addPredicate(p1).addPredicate(p2) reason for this change</technical_language>

Target:
public PartSelectionListener addPredicate(Predicate<ISelectionModel> predicate) { if (predicate != null) { fPredicate = fPredicate.and(predicate); } return this; }
Source:
<code>private FormatterStep createLazyLicenseHeaderStep(Project project) { String delimiter = "(?! \\*|/\\*| \\*/)"; Supplier<FormatterStep> realStep = Suppliers.memoize(() -> { String header = computeCopyrightHeader(project); return LicenseHeaderStep.createFromHeader(header, delimiter); }); return (FormatterStep) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] {FormatterStep.class}, <START> (_proxy, method, args) -> method.invoke(realStep.get(), args)); <END> }</code><technical_language>a LazyInitializedFormatterStep a memozied suppleire instead pls</technical_language>

Target:
private FormatterStep createLazyLicenseHeaderStep(Project project) { String delimiter = "(?! \\*|/\\*| \\*/)"; return new LazyFormatterStep(MultiLicenseHeaderStep.name(), () -> { List<String> headers = computeCopyrightHeaders(project); return MultiLicenseHeaderStep.createFromHeaders(headers, delimiter); }); }
Source:
<code>public void onChange(Saveable o, XmlFile file) { <START> if (o instanceof Hudson) { <END> MinimumInstanceChecker.checkForMinimumInstances(); } }</code><technical_language>suggestion if (o instanceof Jenkins) {</technical_language>

Target:
public void onChange(Saveable o, XmlFile file) { if (o instanceof Jenkins) { MinimumInstanceChecker.checkForMinimumInstances(); } }
Source:
<code>private void setPreferencesFromSiteSettings() { assignPrefListeners(false); try { <START> if (!mSiteSettings.isSharingModuleEnabled()) { <END> mSharingDisabledNotification.setVisibility(View.VISIBLE); mSharingSettingsWrapper.setVisibility(View.GONE); } mPrefLabel.setTextEntry(mSiteSettings.getSharingLabel()); mPrefButtonStyle.setSummary(mSiteSettings.getSharingButtonStyleDisplayText(getActivity())); mPrefShowReblog.setChecked(mSiteSettings.getAllowReblogButton()); mPrefShowLike.setChecked(mSiteSettings.getAllowLikeButton()); mPrefAllowCommentLikes.setChecked(mSiteSettings.getAllowCommentLikes()); mPrefTwitterName.setTextEntry(mSiteSettings.getTwitterUsername()); String selectedName = mSiteSettings.getSharingButtonStyleDisplayText(getActivity()); String[] names = getResources().getStringArray(R.array.sharing_button_style_display_array); String[] values = getResources().getStringArray(R.array.sharing_button_style_array); PrefListItems listItems = new PrefListItems(); for (int i = 0; i < names.length; i++) { PrefListItem item = new PrefListItem(names[i], values[i], false); listItems.add(item); } listItems.setSelectedName(selectedName); mPrefButtonStyle.setListItems(listItems); mPrefButtonStyle.setSummary(selectedName); } finally { assignPrefListeners(true); } }</code><technical_language>Do set visibility of mSharingDisabledNotification mSharingSettingsWrapper a bit more dynamically? for example, if decided add pull refresh this page user enables sharing page is loaded (so notification is visible) this hide notification show settings. do right now, future proof code a bit. do think</technical_language>

Target:
private void setPreferencesFromSiteSettings() { assignPrefListeners(false); try { boolean sharingModuleEnabled = mSiteSettings.isSharingModuleEnabled(); mSharingDisabledNotification.setVisibility(sharingModuleEnabled ? View.GONE : View.VISIBLE); mSharingSettingsWrapper.setVisibility(sharingModuleEnabled ? View.VISIBLE : View.GONE); mPrefLabel.setTextEntry(mSiteSettings.getSharingLabel()); mPrefButtonStyle.setSummary(mSiteSettings.getSharingButtonStyleDisplayText(getActivity())); mPrefShowReblog.setChecked(mSiteSettings.getAllowReblogButton()); mPrefShowLike.setChecked(mSiteSettings.getAllowLikeButton()); mPrefAllowCommentLikes.setChecked(mSiteSettings.getAllowCommentLikes()); mPrefTwitterName.setTextEntry(mSiteSettings.getTwitterUsername()); String selectedName = mSiteSettings.getSharingButtonStyleDisplayText(getActivity()); String[] names = getResources().getStringArray(R.array.sharing_button_style_display_array); String[] values = getResources().getStringArray(R.array.sharing_button_style_array); PrefListItems listItems = new PrefListItems(); for (int i = 0; i < names.length; i++) { PrefListItem item = new PrefListItem(names[i], values[i], false); listItems.add(item); } listItems.setSelectedName(selectedName); mPrefButtonStyle.setListItems(listItems); mPrefButtonStyle.setSummary(selectedName); } finally { assignPrefListeners(true); } }
Source:
<code>public JsonResponse add(@Valid @RequestBody SpamRuleDto ruleDto, BindingResult result) throws org.jtalks.common.service.exceptions.NotFoundException, InterruptedException { checkForAdminPermissions(); trimAndValidate(ruleDto, result); if (result.hasFieldErrors() || result.hasGlobalErrors()) { return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors()); } <START> SpamRule spamRule = SpamRule.toEntity(ruleDto); <END> return saveOrUpdateSpamRule(result, spamRule); }</code><technical_language>this ruleDto.toEntity()</technical_language>

Target:
public JsonResponse add(@Valid @RequestBody SpamRuleDto ruleDto, BindingResult result) throws org.jtalks.common.service.exceptions.NotFoundException, InterruptedException { checkForAdminPermissions(); trimAndValidate(ruleDto, result); if (result.hasFieldErrors() || result.hasGlobalErrors()) { return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors()); } SpamRule spamRule = ruleDto.toEntity(); return saveOrUpdateSpamRule(result, spamRule); }
Source:
<code>private void processMethod(DetailAST ast) { final DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); if (violateImpliedPublicMethod && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null && modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) == null) { log(ast, MSG_KEY, PUBLIC_ACCESS_MODIFIER); } if (violateImpliedAbstractMethod && modifiers.findFirstToken(TokenTypes.LITERAL_STATIC) == null && modifiers.findFirstToken(TokenTypes.LITERAL_DEFAULT) == null <START> && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null <END> && modifiers.findFirstToken(TokenTypes.ABSTRACT) == null) { log(ast, MSG_KEY, ABSTRACT_KEYWORD); } }</code><technical_language>please move PRIVATE top of this group, mix visibility "kind"</technical_language>

Target:
private void processMethod(DetailAST ast) { final DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); if (violateImpliedPublicMethod && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null && modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) == null) { log(ast, MSG_KEY, PUBLIC_ACCESS_MODIFIER); } if (violateImpliedAbstractMethod && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null && modifiers.findFirstToken(TokenTypes.LITERAL_STATIC) == null && modifiers.findFirstToken(TokenTypes.LITERAL_DEFAULT) == null && modifiers.findFirstToken(TokenTypes.ABSTRACT) == null) { log(ast, MSG_KEY, ABSTRACT_KEYWORD); } }
Source:
<code>public Description matchMethod(MethodTree tree, VisitorState state) { if (IS_OVERRIDE.matches(tree, state)) { return Description.NO_MATCH; } Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(tree); if (symbol == null || symbol.isConstructor()) { return Description.NO_MATCH; } if (tree.getParameters().size() > MAX_NUM_ARGS) { return buildDescription(tree) .setMessage("Interfaces can take at most " + MAX_NUM_ARGS + " arguments.") <START> .build(); <END> } return Description.NO_MATCH; }</code><technical_language>suggested fix lop a unimportant params? ;-) want add message suggesting args object a builder, potentially recommending immutables</technical_language>

Target:
public Description matchMethod(MethodTree tree, VisitorState state) { if (IS_OVERRIDE.matches(tree, state)) { return Description.NO_MATCH; } Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(tree); if (symbol == null || symbol.isConstructor()) { return Description.NO_MATCH; } if (tree.getParameters().size() > MAX_NUM_ARGS) { return buildDescription(tree) .setMessage("Interfaces can take at most " + MAX_NUM_ARGS + " arguments. Consider the following ways of soling the problem:\n" + "- Define an object with Immutables that contains all of the arguments\n" + "- Expose smaller interfaces by refactorings concepts into separate interfaces") .build(); } return Description.NO_MATCH; }
Source:
<code>public void deleteProjectOverviewNote(ProjectOverview projectOverview, Long noteId) throws IOException { <START> authorizationManager.throwIfNonAdmin(); <END> if (noteId == null || noteId.equals(Note.UNSAVED_ID)) { throw new IllegalArgumentException("Cannot delete an unsaved Note"); } ProjectOverview managed = projectStore.getProjectOverviewById(projectOverview.getId()); Note deleteNote = null; for (Note note : managed.getNotes()) { if (note.getNoteId().equals(noteId)) { deleteNote = note; break; } } if (deleteNote == null) { throw new IOException("Note " + noteId + " not found for ProjectOverview " + projectOverview.getId()); } managed.getNotes().remove(deleteNote); projectStore.saveOverview(managed); }</code><technical_language>Note owner able delete</technical_language>

Target:
public void deleteProjectOverviewNote(ProjectOverview projectOverview, Long noteId) throws IOException { if (noteId == null || noteId.equals(Note.UNSAVED_ID)) { throw new IllegalArgumentException("Cannot delete an unsaved Note"); } ProjectOverview managed = projectStore.getProjectOverviewById(projectOverview.getId()); Note deleteNote = null; for (Note note : managed.getNotes()) { if (note.getNoteId().equals(noteId)) { deleteNote = note; break; } } if (deleteNote == null) { throw new IOException("Note " + noteId + " not found for ProjectOverview " + projectOverview.getId()); } authorizationManager.throwIfNonAdminOrMatchingOwner(deleteNote.getOwner()); managed.getNotes().remove(deleteNote); projectStore.saveOverview(managed); }
Source:
<code>private Map<String, Double> calculateWeightedPercentagePerOption(Map<String, Integer> answerFrequency) { Map<String, Double> weightedPercentagePerOption = new LinkedHashMap<>(); <START> if (!hasAssignedWeights) { <END> return weightedPercentagePerOption; } for (int i = 0; i < mcqChoices.size(); i++) { String option = mcqChoices.get(i); double weight = mcqWeights.get(i); weightedPercentagePerOption.put(option, weight); } if (otherEnabled) { weightedPercentagePerOption.put("Other", mcqOtherWeight); } for (String key : weightedPercentagePerOption.keySet()) { int frequency = answerFrequency.get(key); double weight = weightedPercentagePerOption.get(key); double weightedPercentage = 100 * ((frequency * weight) / calculateTotalWeightedResponseCount(answerFrequency)); weightedPercentagePerOption.put(key, weightedPercentage); } return weightedPercentagePerOption; }</code><technical_language>add assumption here. More strict checking. If assigned weights, method called all. Assumption.assertTrue(hasAssignedWeights, "bla bla bla")</technical_language>

Target:
private Map<String, Double> calculateWeightedPercentagePerOption(Map<String, Integer> answerFrequency) { Map<String, Double> weightedPercentagePerOption = new LinkedHashMap<>(); Assumption.assertTrue("Weights should be enabled when calling the function", hasAssignedWeights); double totalWeightedResponseCount = calculateTotalWeightedResponseCount(answerFrequency); for (int i = 0; i < mcqChoices.size(); i++) { String option = mcqChoices.get(i); double weight = mcqWeights.get(i); weightedPercentagePerOption.put(option, weight); } if (otherEnabled) { weightedPercentagePerOption.put("Other", mcqOtherWeight); } for (String key : weightedPercentagePerOption.keySet()) { int frequency = answerFrequency.get(key); double weight = weightedPercentagePerOption.get(key); double weightedPercentage = totalWeightedResponseCount == 0 ? 0 : 100 * ((frequency * weight) / totalWeightedResponseCount); weightedPercentagePerOption.put(key, weightedPercentage); } return weightedPercentagePerOption; }
Source:
<code>public static Optional<GameData> parse(final URI mapUri) { final Optional<InputStream> inputStream = UrlStreams.openStream(mapUri); if (inputStream.isEmpty()) { return Optional.empty(); } try (InputStream input = inputStream.get()) { return Optional.of(parse(mapUri.toString(), input, new XmlGameElementMapper())); } catch (final EngineVersionException e) { log.log(Level.WARNING, "Game engine not compatible with: " + mapUri, e); return Optional.empty(); } catch (final GameParseException e) { log.log(Level.WARNING, "Could not parse:" + mapUri, e); return Optional.empty(); } catch (final IOException e) { log.log(Level.SEVERE, "Error opening file: " + mapUri + ", " + e.getMessage(), e); <START> return Optional.empty(); <END> } }</code><technical_language>Avoid return statements this method</technical_language>

Target:
public static Optional<GameData> parse(final URI mapUri) { return UrlStreams.openStream( mapUri, inputStream -> { try { return parse(mapUri.toString(), inputStream, new XmlGameElementMapper()); } catch (final EngineVersionException e) { log.log(Level.WARNING, "Game engine not compatible with: " + mapUri, e); return null; } catch (final GameParseException e) { log.log(Level.WARNING, "Could not parse:" + mapUri, e); return null; } }); }
Source:
<code>public QueryResult query(final Query query, final TimeUnit timeUnit) { Call<QueryResult> call = null; if (query instanceof BoundParameterQuery) { <START> BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query; <END> call = this.influxDBService.query(this.username, this.password, query.getDatabase(), TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded(), boundParameterQuery.getParameterJsonWithUrlEncoded()); } else { call = this.influxDBService.query(this.username, this.password, query.getDatabase(), TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded()); } return execute(call); }</code><technical_language>formatting</technical_language>

Target:
public QueryResult query(final Query query, final TimeUnit timeUnit) { Call<QueryResult> call = null; if (query instanceof BoundParameterQuery) { BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query; call = this.influxDBService.query(this.username, this.password, query.getDatabase(), TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded(), boundParameterQuery.getParameterJsonWithUrlEncoded()); } else { call = this.influxDBService.query(this.username, this.password, query.getDatabase(), TimeUtil.toTimePrecision(timeUnit), query.getCommandWithUrlEncoded()); } return executeQuery(call); }
Source:
<code>private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) { EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL); storage_pool storagePool = getStoragePoolDAO().get(storagePoolId); StorageDomain masterDomain = getStorageDomainDAO().getStorageDomainForPoolByType(storagePoolId, StorageDomainType.Master); boolean shouldProceedVdsStats = true; try { runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds.getId(), storagePoolId, vds.getVdsSpmId(), masterDomain.getId(), storagePool.getmaster_domain_version())).getSucceeded(); } catch (VdcBLLException e) { <START> boolean isMasterDomainInactiveOrUnknown = (masterDomain.getStatus() == StorageDomainStatus.InActive <END> || masterDomain.getStatus() == StorageDomainStatus.Unknown); if (e.getErrorCode() != VdcBllErrors.VDS_NETWORK_ERROR && isMasterDomainInactiveOrUnknown) { shouldProceedVdsStats = false; result.setSuccess(true); } else { log.errorFormat("Could not connect host {0} to pool {1}", vds.getName(), storagePool .getname()); result.setSuccess(false); } } catch (RuntimeException exp) { log.errorFormat("Could not connect host {0} to pool {1}", vds.getName(), storagePool .getname()); result.setSuccess(false); } if (result.isSuccess() && shouldProceedVdsStats) { result.setSuccess(proceedVdsStats()); if (!result.isSuccess()) { AuditLogDirector.log(new AuditLogableBase(getVdsId()), AuditLogType.VDS_STORAGE_VDS_STATS_FAILED); } } return result; }</code><technical_language>consider giving this boolean a name describes /meaining/, is - e.g., doesStatusProhibitConnect</technical_language>

Target:
private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) { EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL); storage_pool storagePool = getStoragePoolDAO().get(storagePoolId); StorageDomain masterDomain = getStorageDomainDAO().getStorageDomainByTypeAndPool(storagePoolId, StorageDomainType.Master); boolean shouldProceedVdsStats = true; try { runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds.getId(), storagePoolId, vds.getVdsSpmId(), masterDomain.getId(), storagePool.getmaster_domain_version())).getSucceeded(); } catch (VdcBLLException e) { if (e.getErrorCode() != VdcBllErrors.VDS_NETWORK_ERROR && e.getErrorCode() != VdcBllErrors.PROTOCOL_ERROR && (masterDomain.getStatus() == StorageDomainStatus.InActive || masterDomain.getStatus() == StorageDomainStatus.Unknown)) { shouldProceedVdsStats = false; } else { log.errorFormat("Could not connect host {0} to pool {1}", vds.getName(), storagePool .getname()); result.setSuccess(false); } } catch (RuntimeException exp) { log.errorFormat("Could not connect host {0} to pool {1}", vds.getName(), storagePool .getname()); result.setSuccess(false); } if (result.isSuccess() && shouldProceedVdsStats) { result.setSuccess(proceedVdsStats()); if (!result.isSuccess()) { AuditLogDirector.log(new AuditLogableBase(getVdsId()), AuditLogType.VDS_STORAGE_VDS_STATS_FAILED); } } return result; }
Source:
<code>private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { ShadowElement se = (ShadowElement) shadow; if (!(shadow instanceof ShadowElement) || !se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) <START> return; <END> List<Component> children = shadow.getChildren(); if (children.size() > 0) { doBindChildrenInFilter(children.toArray(new Component[children.size()])); } else { Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); } } }</code><technical_language>continue</technical_language>

Target:
private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { if (shadow instanceof ShadowElement) { ShadowElement se = (ShadowElement) shadow; if (!se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) continue; List<Component> children = shadow.getChildren(); if (children.size() > 0) { doBindChildrenInFilter(children.toArray(new Component[children.size()])); } else { Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); } } } }
Source:
<code>private void processTruncationRequestEvent(final WatchedEvent event) { if (event.getType() == EventType.NodeChildrenChanged) { <START> boolean isBare = (!m_BareProcessed.getAndSet(true) && VoltDB.instance().isBare()); <END> loggingLog.info("Scheduling truncation request processing " + (isBare ? 0 : m_truncationGatheringPeriod) + " seconds from now"); m_es.schedule(new Runnable() { @Override public void run() { try { processSnapshotTruncationRequestCreated(event); } catch (Exception e) { VoltDB.crashLocalVoltDB("Error processing snapshot truncation request creation", true, e); } } }, isBare ? 0 : m_truncationGatheringPeriod, TimeUnit.SECONDS); return; } else { VoltDB.crashLocalVoltDB( "Trunction request watcher fired with event type other then created: " + event.getType(), true, null); } }</code><technical_language>do gathering determination local variable logging scheduling tasks java int gatheringSeconds = isBare ? 0 : m_truncationGatheringPeriod;</technical_language>

Target:
private void processTruncationRequestEvent(final WatchedEvent event) { if (event.getType() == EventType.NodeChildrenChanged) { boolean isBare = (!m_BareProcessed.getAndSet(true) && VoltDB.instance().isBare()); int truncationGatheringPeriod = (isBare ? 0 : m_truncationGatheringPeriod); loggingLog.info("Scheduling truncation request processing " + truncationGatheringPeriod + " seconds from now"); m_es.schedule(new Runnable() { @Override public void run() { try { processSnapshotTruncationRequestCreated(event); } catch (Exception e) { VoltDB.crashLocalVoltDB("Error processing snapshot truncation request creation", true, e); } } }, truncationGatheringPeriod, TimeUnit.SECONDS); return; } else { VoltDB.crashLocalVoltDB( "Trunction request watcher fired with event type other then created: " + event.getType(), true, null); } }
Source:
<code>public boolean[] readBoolArray() throws TException { <START> TList tList = protocol.readListBegin(); <END> boolean[] array = new boolean[tList.size]; for (int i = 0; i < tList.size; i++) { array[i] = readBool(); } protocol.readListEnd(); return array; }</code><technical_language>name this list</technical_language>

Target:
public boolean[] readBoolArray() throws TException { TList list = protocol.readListBegin(); boolean[] array = new boolean[list.size]; for (int i = 0; i < list.size; i++) { array[i] = readBool(); } protocol.readListEnd(); return array; }
Source:
<code>public static String formatDateResponse(String value) { try { Date date = new Date(Long.valueOf(value)); return DATE_RESPONSE_FORMAT.get().format(date); <START> } catch (NumberFormatException e) { <END> log.error("Invalid date response: " + value); } return ""; }</code><technical_language>In some cases incidents in datastore contained date strings instead of timestamps e.g 21-03-2016 16:21:05 previous formatting fall parsing for this format if a NumberFormatException occurred. for time being</technical_language>

Target:
public static String formatDateResponse(String value) { Date date = parseDatastoreDate(value); if (date != null) { return DATE_RESPONSE_FORMAT.get().format(date); } return ""; }
Source:
<code>public void enqueued( BoltConnection to, Job job ) { <START> checkLimitsOnEnqueue( to, counters.compute( to.id(), ( k, v ) -> v == null ? new AtomicInteger( 0 ) : v ).incrementAndGet() ); <END> }</code><technical_language>Map#computeIfAbsent() instead code a bit shorter</technical_language>

Target:
public void enqueued( BoltConnection to, Job job ) { checkLimitsOnEnqueue( to, counters.computeIfAbsent( to.id(), k -> new AtomicInteger( 0 ) ).incrementAndGet() ); }
Source:
<code>public Response interceptGeoServerRequest(HttpServletRequest request) throws InterceptorException, URISyntaxException, UnsupportedEncodingException, HttpException { MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(request); OgcMessage message = getOgcRequest(mutableRequest); URI geoServerBaseUri = getGeoServerBaseURI(message); mutableRequest.setRequestURI(geoServerBaseUri); mutableRequest = ogcMessageDistributor .distributeToRequestInterceptor(mutableRequest, message); <START> Response response = sendRequest(mutableRequest); <END> Response interceptedResponse = ogcMessageDistributor .distributeToResponeInterceptor(response, message); interceptedResponse.setHeaders( getHeadersToForward(interceptedResponse.getHeaders())); return interceptedResponse; }</code><technical_language>Good TODO :smile: I suggested</technical_language>

Target:
public Response interceptGeoServerRequest(HttpServletRequest request) throws InterceptorException, URISyntaxException, HttpException, IOException { MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(request); OgcMessage message = getOgcRequest(mutableRequest); URI geoServerBaseUri = getGeoServerBaseURI(message); mutableRequest.setRequestURI(geoServerBaseUri); mutableRequest = ogcMessageDistributor .distributeToRequestInterceptor(mutableRequest, message); Response response = sendRequest(mutableRequest); Response interceptedResponse = ogcMessageDistributor .distributeToResponseInterceptor(response, message); interceptedResponse.setHeaders( getHeadersToForward(interceptedResponse.getHeaders())); return interceptedResponse; }
Source:
<code><START> public ModVersion() { <END> version = new SimpleObjectProperty<>(); id = new SimpleStringProperty(); uid = new SimpleStringProperty(); type = new SimpleObjectProperty<>(); description = new SimpleStringProperty(); filename = new SimpleStringProperty(); icon = new SimpleStringProperty(); ranked = new SimpleBooleanProperty(); hidden = new SimpleBooleanProperty(); createTime = new SimpleObjectProperty<>(); updateTime = new SimpleObjectProperty<>(); thumbnailUrl = new SimpleObjectProperty<>(); downloadUrl = new SimpleObjectProperty<>(); mod = new SimpleObjectProperty<>(); }</code><technical_language>discussed, rename Mod instead</technical_language>

Target:
public ModVersion() { displayName = new SimpleStringProperty(); imagePath = new SimpleObjectProperty<>(); id = new SimpleStringProperty(); uid = new SimpleStringProperty(); description = new SimpleStringProperty(); uploader = new SimpleStringProperty(); selectable = new SimpleBooleanProperty(); version = new SimpleObjectProperty<>(); selected = new SimpleBooleanProperty(); likes = new SimpleIntegerProperty(); played = new SimpleIntegerProperty(); createTime = new SimpleObjectProperty<>(); updateTime = new SimpleObjectProperty<>(); reviewsSummary = new SimpleObjectProperty<>(); downloads = new SimpleIntegerProperty(); thumbnailUrl = new SimpleObjectProperty<>(); comments = new SimpleListProperty<>(FXCollections.observableArrayList()); downloadUrl = new SimpleObjectProperty<>(); mountPoints = new SimpleListProperty<>(FXCollections.observableArrayList()); hookDirectories = new SimpleListProperty<>(FXCollections.observableArrayList()); reviews = new SimpleListProperty<>(FXCollections.observableArrayList(param -> new Observable[]{param.scoreProperty(), param.textProperty()})); modType = new SimpleObjectProperty<>(); filename = new SimpleStringProperty(); icon = new SimpleStringProperty(); ranked = new SimpleBooleanProperty(); hidden = new SimpleBooleanProperty(); mod = new SimpleObjectProperty<>(); }
Source:
<code>public void testReloadBrooklynPropertiesFromFile() throws Exception { <START> File globalPropertiesFile = File.createTempFile("local-brooklyn-properties-test", ".properties"); <END> globalPropertiesFile.deleteOnExit(); String property = "mykey=myval"; Files.write(property, globalPropertiesFile, Charsets.UTF_8); launcher = BrooklynLauncher.newInstance() .webconsole(false) .globalBrooklynPropertiesFile(globalPropertiesFile.getAbsolutePath()) .start(); LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext(); assertEquals(managementContext.getConfig().getFirst("mykey"), "myval"); property = "mykey=newval"; Files.write(property, globalPropertiesFile, Charsets.UTF_8); managementContext.reloadBrooklynProperties(); assertEquals(managementContext.getConfig().getFirst("mykey"), "newval"); }</code><technical_language>Good a try-finally delete this temporary file. deleteOnExit get called folk running manual tests if kill process etc</technical_language>

Target:
public void testReloadBrooklynPropertiesFromFile() throws Exception { File globalPropertiesFile = File.createTempFile("local-brooklyn-properties-test", ".properties"); try { String property = "mykey=myval"; Files.write(property, globalPropertiesFile, Charsets.UTF_8); launcher = BrooklynLauncher.newInstance() .webconsole(false) .globalBrooklynPropertiesFile(globalPropertiesFile.getAbsolutePath()) .start(); LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext(); assertEquals(managementContext.getConfig().getFirst("mykey"), "myval"); property = "mykey=newval"; Files.write(property, globalPropertiesFile, Charsets.UTF_8); managementContext.reloadBrooklynProperties(); assertEquals(managementContext.getConfig().getFirst("mykey"), "newval"); } finally { globalPropertiesFile.delete(); } }
Source:
<code>TrustManagerFactoryWrapper(TrustManager tm) throws Exception { <START> this.tm = tm; <END> }</code><technical_language>ObjectUtil.checkNotNull(tm, "tm"); below</technical_language>

Target:
TrustManagerFactoryWrapper(TrustManager tm) { this.tm = ObjectUtil.checkNotNull(tm, "tm"); }
Source:
<code>public void sessionDestroyed(HttpSessionEvent se) { if (authorizationManagers.isEmpty()) { return; } final User currentUser = (User) se.getSession().getAttribute(ServletSecurityAuthenticationService.USER_SESSION_ATTR_NAME); <START> if (currentUser != null && !currentUser.equals(User.ANONYMOUS)) { <END> for (AuthorizationManager authorizationManager : authorizationManagers) { authorizationManager.invalidate(currentUser); } } }</code><technical_language>simplified !Objects.equals(currentUser, User.ANONYMOUS)</technical_language>

Target:
public void sessionDestroyed(HttpSessionEvent se) { if (authorizationManagers.isEmpty()) { return; } final User currentUser = (User) se.getSession().getAttribute(ServletSecurityAuthenticationService.USER_SESSION_ATTR_NAME); if (!ANONYMOUS.equals(currentUser)) { for (AuthorizationManager authorizationManager : authorizationManagers) { authorizationManager.invalidate(currentUser); } } }
Source:
<code>private void bootstrapLogReplicationService() { try { LogReplicationConfig logReplicationConfig = getLogReplicationConfiguration(getCorfuRuntime()); logReplicationMetadataManager = new LogReplicationMetadataManager(getCorfuRuntime(), topologyDescriptor.getTopologyConfigId(), localClusterDescriptor.getClusterId()); logReplicationServerHandler = new LogReplicationServer(serverContext, logReplicationConfig, logReplicationMetadataManager, localCorfuEndpoint, topologyDescriptor.getTopologyConfigId()); logReplicationServerHandler.setActive(localClusterDescriptor.getRole().equals(ClusterRole.ACTIVE)); interClusterReplicationService = new CorfuInterClusterReplicationServerNode(serverContext, logReplicationServerHandler, logReplicationConfig); replicationContext = new LogReplicationContext(logReplicationConfig, topologyDescriptor, localCorfuEndpoint, interClusterReplicationService.getRouter().getServerAdapter().getChannelContext()); serverCallback.complete(interClusterReplicationService); logReplicationEventListener = new LogReplicationEventListener(this); logReplicationEventListener.start(); serverStarted = true; <START> } catch (Throwable t) { <END> throw t; } }</code><technical_language>Do need catch? re-throwing</technical_language>

Target:
private void bootstrapLogReplicationService() { LogReplicationConfig logReplicationConfig = getLogReplicationConfiguration(getCorfuRuntime()); logReplicationMetadataManager = new LogReplicationMetadataManager(getCorfuRuntime(), topologyDescriptor.getTopologyConfigId(), localClusterDescriptor.getClusterId()); logReplicationServerHandler = new LogReplicationServer(serverContext, logReplicationConfig, logReplicationMetadataManager, localCorfuEndpoint, topologyDescriptor.getTopologyConfigId()); logReplicationServerHandler.setActive(localClusterDescriptor.getRole().equals(ClusterRole.ACTIVE)); interClusterReplicationService = new CorfuInterClusterReplicationServerNode(serverContext, logReplicationServerHandler, logReplicationConfig); replicationContext = new LogReplicationContext(logReplicationConfig, topologyDescriptor, localCorfuEndpoint, interClusterReplicationService.getRouter().getServerAdapter().getChannelContext()); serverCallback.complete(interClusterReplicationService); logReplicationEventListener = new LogReplicationEventListener(this); logReplicationEventListener.start(); serverStarted = true; }
Source:
<code>public void shouldDisallowReAddingIndex() throws Exception { SchemaReadOperations innerRead = mock( SchemaReadOperations.class ); SchemaWriteOperations innerWrite = mock( SchemaWriteOperations.class ); DataIntegrityValidatingStatementOperations ctx = new DataIntegrityValidatingStatementOperations( null, innerRead, innerWrite ); when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( index ); ctx.indexCreate( state, descriptor ); fail( "Should have thrown exception." ); <START> verify( innerWrite, never() ).indexCreate( eq( state ), anyObject() ); <END> }</code><technical_language>this verify is reachable now, I missing something</technical_language>

Target:
public void shouldDisallowReAddingIndex() throws Exception { SchemaReadOperations innerRead = mock( SchemaReadOperations.class ); SchemaWriteOperations innerWrite = mock( SchemaWriteOperations.class ); DataIntegrityValidatingStatementOperations ctx = new DataIntegrityValidatingStatementOperations( null, innerRead, innerWrite ); when( innerRead.indexGetForLabelAndPropertyKey( state, SchemaBoundary.map( descriptor ) ) ).thenReturn( index ); try { ctx.indexCreate( state, descriptor ); fail( "Should have thrown exception." ); } catch ( AlreadyIndexedException e ) { } verify( innerWrite, never() ).indexCreate( eq( state ), anyObject() ); }
Source:
<code>private static String findTypeParameterDescriptor(Field field, ObjectAnnotations objectAnnotations) { String typeParameterDescriptor = null; final Type genericType = field.getGenericType(); if (genericType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) genericType; <START> final Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); <END> if (actualTypeArguments.length > 0) { for (Type typeArgument : actualTypeArguments) { if (typeArgument instanceof ParameterizedType) { ParameterizedType parameterizedTypeArgument = (ParameterizedType) typeArgument; typeParameterDescriptor = parameterizedTypeArgument.getRawType().getTypeName(); break; } else if ((typeArgument instanceof TypeVariable || typeArgument instanceof WildcardType) && !objectAnnotations.has(Relationship.class)) { typeParameterDescriptor = Object.class.getName(); break; } else if (typeArgument instanceof Class) { typeParameterDescriptor = ((Class) typeArgument).getName(); } } } if (typeParameterDescriptor == null) { typeParameterDescriptor = parameterizedType.getRawType().getTypeName(); } } if (typeParameterDescriptor == null && (genericType instanceof TypeVariable)) { typeParameterDescriptor = field.getType().getTypeName(); } return typeParameterDescriptor; }</code><technical_language>I this is part of PR set final local vars final of them</technical_language>

Target:
private static String findTypeParameterDescriptor(Field field, ObjectAnnotations objectAnnotations) { String typeParameterDescriptor = null; Type genericType = field.getGenericType(); if (genericType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) genericType; Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); if (actualTypeArguments.length > 0) { for (Type typeArgument : actualTypeArguments) { if (typeArgument instanceof ParameterizedType) { ParameterizedType parameterizedTypeArgument = (ParameterizedType) typeArgument; typeParameterDescriptor = parameterizedTypeArgument.getRawType().getTypeName(); break; } else if ((typeArgument instanceof TypeVariable || typeArgument instanceof WildcardType) && !objectAnnotations.has(Relationship.class)) { typeParameterDescriptor = Object.class.getName(); break; } else if (typeArgument instanceof Class) { typeParameterDescriptor = ((Class) typeArgument).getName(); } } } if (typeParameterDescriptor == null) { typeParameterDescriptor = parameterizedType.getRawType().getTypeName(); } } if (typeParameterDescriptor == null && (genericType instanceof TypeVariable)) { typeParameterDescriptor = field.getType().getTypeName(); } return typeParameterDescriptor; }
Source:
<code>public AtmosphereFramework destroy() { if (isDestroyed.getAndSet(true)) return this; onPreDestroy(); closeAtmosphereResource(); destroyInterceptors(); BroadcasterFactory factory = broadcasterFactory; if (factory != null) { factory.destroy(); } if (asyncSupport != null && AsynchronousProcessor.class.isAssignableFrom(asyncSupport.getClass())) { ((AsynchronousProcessor) asyncSupport).shutdown(); } for (Entry<String, AtmosphereHandlerWrapper> entry : atmosphereHandlers.entrySet()) { AtmosphereHandlerWrapper handlerWrapper = entry.getValue(); handlerWrapper.atmosphereHandler.destroy(); } if (metaBroadcaster != null) metaBroadcaster.destroy(); if (arFactory != null) arFactory.destroy(); if (sessionFactory != null) sessionFactory.destroy(); WebSocketProcessorFactory.getDefault().destroy(); ExecutorsFactory.reset(config); <START> config.destroy(); <END> resetStates(); onPostDestroy(); try { if (this.shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(this.shutdownHook); shutdownHook = null; } } catch (IllegalStateException ex) { logger.trace("", ex); } return this; }</code><technical_language>fix tab...easier cleaner code. Thanks</technical_language>

Target:
public AtmosphereFramework destroy() { if (isDestroyed.getAndSet(true)) return this; onPreDestroy(); closeAtmosphereResource(); destroyInterceptors(); config.destroy(); BroadcasterFactory factory = broadcasterFactory; if (factory != null) { factory.destroy(); } if (asyncSupport != null && AsynchronousProcessor.class.isAssignableFrom(asyncSupport.getClass())) { ((AsynchronousProcessor) asyncSupport).shutdown(); } for (Entry<String, AtmosphereHandlerWrapper> entry : atmosphereHandlers.entrySet()) { AtmosphereHandlerWrapper handlerWrapper = entry.getValue(); handlerWrapper.atmosphereHandler.destroy(); } if (metaBroadcaster != null) metaBroadcaster.destroy(); if (arFactory != null) arFactory.destroy(); if (sessionFactory != null) sessionFactory.destroy(); WebSocketProcessorFactory.getDefault().destroy(); ExecutorsFactory.reset(config); resetStates(); onPostDestroy(); try { if (this.shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(this.shutdownHook); shutdownHook = null; } } catch (IllegalStateException ex) { logger.trace("", ex); } return this; }
Source:
<code>private void startGeoTagging() { Context context = getContext(); Intent intent = new Intent(context, GeoTagImagesService.class); intent.setAction(GeoTagImagesService.ACTION_START_GEOTAGGING); <START> getContext().startService(intent); <END> }</code><technical_language>@chaviw ensure getContext() is null, reuse context variable defined beginning of method</technical_language>

Target:
private void startGeoTagging() { Context context = getContext(); if (context != null) { Intent intent = new Intent(context, GeoTagImagesService.class); intent.setAction(GeoTagImagesService.ACTION_START_GEOTAGGING); context.startService(intent); } }
Source:
<code>protected void generateBVDesignLicenseJsonFile(final String bvDesignLocation) throws BVLicenseParseException { Process p = null; final String errorMessage = this.messageSource.getMessage("bv.design.error.failed.license.generation", null, LocaleContextHolder.getLocale()); <START> <END> try { final ProcessBuilder processBuilder = new ProcessBuilder(bvDesignLocation, "-status", "-json"); processBuilder.directory(new File(bvDesignLocation)); p = processBuilder.start(); p.waitFor(); } catch (final IOException | InterruptedException e) { BVDesignLicenseUtil.LOG.error(errorMessage + ":" + e.getMessage(), e); throw new BVLicenseParseException(errorMessage); } catch (final Exception e) { BVDesignLicenseUtil.LOG.error(errorMessage + ":" + e.getMessage(), e); throw new BVLicenseParseException(errorMessage); } }</code><technical_language>explored/tried creating unit test for BVDesignLicenseUtil#retrieveLicenseInfo? I if Mockito.spy calling actual executable</technical_language>

Target:
protected void generateBVDesignLicenseJsonFile(final String bvDesignLocation) throws BVLicenseParseException { try { final String bvDesignDirectory = new File(bvDesignLocation).getParent(); bvDesignLicenseProcessRunner.setDirectory(bvDesignDirectory); bvDesignLicenseProcessRunner.run(bvDesignLocation, "-status", "-json"); } catch (final Exception e) { final String errorMessage = this.messageSource.getMessage("bv.design.error.failed.license.generation", null, LocaleContextHolder.getLocale()); BVDesignLicenseUtil.LOG.error(errorMessage + ":" + e.getMessage(), e); throw new BVLicenseParseException(errorMessage); } }