auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private PartitionMetadata findLeader() throws InterruptedException { for (KafkaBroker broker : replicaBrokers) { SimpleConsumer consumer = null; try { log.info("findLeader, try broker %s:%s", broker.host, broker.port); consumer = new SimpleConsumer(broker.host, broker.port, soTimeout, bufferSize, clientId + "leaderLookup"); TopicMetadataResponse resp = consumer.send(new TopicMetadataRequest(Collections.singletonList(topic))); List<TopicMetadata> metaData = resp.topicsMetadata(); for (TopicMetadata item : metaData) { if (topic.equals(item.topic())) { for (PartitionMetadata part : item.partitionsMetadata()) { if (part.partitionId() == partitionId) { return part; } } } } } catch (Exception e) { ensureNotInterrupted(e); log.warn( e, "error communicating with Broker [%s] to find leader for [%s] - [%s]", broker, topic, partitionId ); } finally { if (consumer != null) { try { consumer.close(); } <START> catch (Exception e) { <END> } } } } return null; }</code><technical_language>log this</technical_language>

Target:
private PartitionMetadata findLeader() throws InterruptedException { for (KafkaBroker broker : replicaBrokers) { SimpleConsumer consumer = null; try { log.info("Finding new leader from Kafka brokers, try broker %s:%s", broker.host, broker.port); consumer = new SimpleConsumer(broker.host, broker.port, SO_TIMEOUT, BUFFER_SIZE, leaderLookupClientId); TopicMetadataResponse resp = consumer.send(new TopicMetadataRequest(Collections.singletonList(topic))); List<TopicMetadata> metaData = resp.topicsMetadata(); for (TopicMetadata item : metaData) { if (topic.equals(item.topic())) { for (PartitionMetadata part : item.partitionsMetadata()) { if (part.partitionId() == partitionId) { return part; } } } } } catch (Exception e) { ensureNotInterrupted(e); log.warn( e, "error communicating with Kafka Broker [%s] to find leader for [%s] - [%s]", broker, topic, partitionId ); } finally { if (consumer != null) { consumer.close(); } } } return null; }
Source:
<code>UpdatesFromMixpanel constructUpdatesFromMixpanel(final Context context, final String token) { <START> if (Build.VERSION.SDK_INT < MPConfig.UI_FEATURES_MIN_API <END> || mConfig.getDisableViewCrawler()) { Log.i(LOGTAG, "Web Configuration, A/B Testing, and Dynamic Tweaks are disabled."); return new NoOpUpdatesFromMixpanel(sSharedTweaks); } else { return new ViewCrawler(mContext, mToken, this, sSharedTweaks); } }</code><technical_language>UnsupportedUpdatesFromMixpanel NoOpUpdatesFromMixpanel? result is same</technical_language>

Target:
UpdatesFromMixpanel constructUpdatesFromMixpanel(final Context context, final String token) { if (Build.VERSION.SDK_INT < MPConfig.UI_FEATURES_MIN_API) { Log.i(LOGTAG, "SDK version is lower than " + MPConfig.UI_FEATURES_MIN_API + ". Web Configuration, A/B Testing, and Dynamic Tweaks are disabled."); return new NoOpUpdatesFromMixpanel(sSharedTweaks); } else if (mConfig.getDisableViewCrawler()) { Log.i(LOGTAG, "DisableViewCrawler is set to true. Web Configuration, A/B Testing, and Dynamic Tweaks are disabled."); return new NoOpUpdatesFromMixpanel(sSharedTweaks); } else { return new ViewCrawler(mContext, mToken, this, sSharedTweaks); } }
Source:
<code>public Map<String, QuestionGroupDto> findQuestionGroup( @PathVariable("id") Long id) { final Map<String, QuestionGroupDto> response = new HashMap<String, QuestionGroupDto>(); QuestionGroup s = questionGroupDao.getByKey(id); QuestionGroupDto dto = null; if (s != null) { <START> dto = QuestionGroupDtoMapper.transform(s); <END> } response.put("question_group", dto); return response; }</code><technical_language>I a thrown I variable name s. I thought function transform a survey. idea rename appropriately</technical_language>

Target:
public Map<String, QuestionGroupDto> findQuestionGroup( @PathVariable("id") Long id) { final Map<String, QuestionGroupDto> response = new HashMap<String, QuestionGroupDto>(); QuestionGroup qg = questionGroupDao.getByKey(id); QuestionGroupDto dto = null; if (qg != null) { dto = QuestionGroupDtoMapper.transform(qg); } response.put("question_group", dto); return response; }
Source:
<code>public ProducerRecord<byte[], byte[]> serialize(RowData consumedRow, @Nullable Long timestamp) { if (keySerialization == null && !hasMetadata) { final byte[] valueSerialized = valueSerialization.serialize(consumedRow); return new ProducerRecord<>( topic, extractPartition(consumedRow, null, valueSerialized), null, valueSerialized); } final byte[] keySerialized; final RowKind kind = consumedRow.getRowKind(); if (keySerialization == null) { keySerialized = null; } else { <START> final RowData keyRow = createProjectedRow(consumedRow, kind, keyFieldGetters); <END> keySerialized = keySerialization.serialize(keyRow); } final byte[] valueSerialized; if (kind == RowKind.DELETE) { valueSerialized = null; } else { final RowData valueRow = createProjectedRow(consumedRow, kind, valueFieldGetters); valueSerialized = valueSerialization.serialize(valueRow); } return new ProducerRecord<>( topic, extractPartition(consumedRow, keySerialized, valueSerialized), readMetadata(consumedRow, KafkaDynamicSink.WritableMetadata.TIMESTAMP), keySerialized, valueSerialized, readMetadata(consumedRow, KafkaDynamicSink.WritableMetadata.HEADERS)); }</code><technical_language>keyRow in INSERT RowKind</technical_language>

Target:
public ProducerRecord<byte[], byte[]> serialize(RowData consumedRow, @Nullable Long timestamp) { if (keySerialization == null && !hasMetadata) { final byte[] valueSerialized = valueSerialization.serialize(consumedRow); return new ProducerRecord<>( topic, extractPartition(consumedRow, null, valueSerialized), null, valueSerialized); } final byte[] keySerialized; if (keySerialization == null) { keySerialized = null; } else { final RowData keyRow = createProjectedRow(consumedRow, RowKind.INSERT, keyFieldGetters); keySerialized = keySerialization.serialize(keyRow); } final byte[] valueSerialized; final RowKind kind = consumedRow.getRowKind(); final RowData valueRow = createProjectedRow(consumedRow, kind, valueFieldGetters); if (upsertMode) { if (kind == RowKind.DELETE || kind == RowKind.UPDATE_BEFORE) { valueSerialized = null; } else { valueRow.setRowKind(RowKind.INSERT); valueSerialized = valueSerialization.serialize(valueRow); } } else { valueSerialized = valueSerialization.serialize(valueRow); } return new ProducerRecord<>( topic, extractPartition(consumedRow, keySerialized, valueSerialized), readMetadata(consumedRow, KafkaDynamicSink.WritableMetadata.TIMESTAMP), keySerialized, valueSerialized, readMetadata(consumedRow, KafkaDynamicSink.WritableMetadata.HEADERS)); }
Source:
<code>public String getColumnText(Object element, int columnIndex) { if (element instanceof ECAction) { switch (columnIndex) { case 0: if (null != ((ECAction) element).getAlgorithm()) { return ((ECAction) element).getAlgorithm().getName(); } break; case 1: if (null != ((ECAction) element).getOutput()) { return ((ECAction) element).getOutput().getName(); } break; default: break; } } return <START> "[none]"; <END> }</code><technical_language>this string is language dependent, this externalized</technical_language>

Target:
public String getColumnText(Object element, int columnIndex) { if (element instanceof ECAction) { switch (columnIndex) { case 0: if (null != ((ECAction) element).getAlgorithm()) { return ((ECAction) element).getAlgorithm().getName(); } break; case 1: if (null != ((ECAction) element).getOutput()) { return ((ECAction) element).getOutput().getName(); } break; default: break; } } return ECCContentAndLabelProvider.EMPTY_FIELD; }
Source:
<code><START> void checkExpectedRouterErrorCode(RouterErrorCode routerErrorCode) throws Exception { <END> try { future.get(AWAIT_TIMEOUT, TimeUnit.SECONDS); Assert.fail("Blob should have failed in operation: " + getOperationName()); } catch (Exception e) { Assert.assertTrue("Expect RouterException", e.getCause() instanceof RouterException); Assert.assertEquals("RouterErrorCode doesn't match.", routerErrorCode, ((RouterException) e.getCause()).getErrorCode()); } }</code><technical_language>Exception is unnecessary, remove it</technical_language>

Target:
void checkExpectedRouterErrorCode(RouterErrorCode routerErrorCode) { try { future.get(AWAIT_TIMEOUT, TimeUnit.SECONDS); Assert.fail("Blob should have failed in operation: " + getOperationName()); } catch (Exception e) { Assert.assertTrue("Expect RouterException", e.getCause() instanceof RouterException); Assert.assertEquals("RouterErrorCode doesn't match.", routerErrorCode, ((RouterException) e.getCause()).getErrorCode()); } }
Source:
<code>private ConditionEvaluationResult evaluate(EnabledIf annotation, ScriptEngine scriptEngine, String script) { Object result; try { result = scriptEngine.eval(script); } catch (ScriptException e) { <START> logger.warn(e, () -> "Evaluation of @EnabledIf script failed, disabling execution"); <END> logger.info(() -> "Script: `" + script + "`"); logger.info(() -> "Bindings: " + scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE).entrySet()); return disabled(e.toString()); } if (result instanceof ConditionEvaluationResult) { return (ConditionEvaluationResult) result; } String resultAsString = String.valueOf(result); String reason = createReason(annotation, script, resultAsString); return Boolean.parseBoolean(resultAsString) ? enabled(reason) : disabled(reason); }</code><technical_language>test fail evaluating script fails</technical_language>

Target:
private ConditionEvaluationResult evaluate(EnabledIf annotation, ScriptEngine scriptEngine, String script) { Object result; try { result = scriptEngine.eval(script); } catch (ScriptException e) { String caption = "Evaluation of @EnabledIf script failed."; String bindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE).entrySet().toString(); String message = String.format("%s script=`%s`, bindings=%s", caption, script, bindings); throw new JUnitException(message, e); } if (result instanceof ConditionEvaluationResult) { return (ConditionEvaluationResult) result; } String resultAsString = String.valueOf(result); String reason = createReason(annotation, script, resultAsString); return Boolean.parseBoolean(resultAsString) ? enabled(reason) : disabled(reason); }
Source:
<code>private void showMissingMediaView(String mediaUri, String errorMessage, boolean allowDownload, @Nullable Runnable completion) { missingMediaBackground.setVisibility(VISIBLE); <START> missingMediaText.setText(errorMessage); <END> missingMediaText.setVisibility(VISIBLE); downloadIcon.setVisibility(allowDownload ? View.VISIBLE : INVISIBLE); downloadIcon.setOnClickListener(v -> { progressBar.setVisibility(VISIBLE); downloadIcon.setVisibility(INVISIBLE); downloadIcon.setEnabled(false); missingMediaText.setText(StringUtils.getStringRobust(getContext(), R.string.media_download_in_progress)); MissingMediaDownloadHelper.requestMediaDownload(mediaUri, result -> { if (result instanceof MissingMediaDownloadResult.Success) { AndroidUtil.showToast(getContext(), R.string.media_download_completed); if (completion != null) { completion.run(); } } else if (!(result instanceof MissingMediaDownloadResult.InProgress)) { progressBar.setVisibility(GONE); downloadIcon.setVisibility(VISIBLE); downloadIcon.setEnabled(true); missingMediaText.setText(StringUtils.getStringRobust(getContext(), R.string.media_download_failed)); } }); }); }</code><technical_language>nit: missingMediaText -> missingMediaStatus</technical_language>

Target:
private void showMissingMediaView(String mediaUri, String errorMessage, boolean allowDownload, @Nullable Runnable completion) { missingMediaBackground.setVisibility(VISIBLE); missingMediaStatus.setText(errorMessage); missingMediaStatus.setVisibility(VISIBLE); downloadIcon.setVisibility(allowDownload ? View.VISIBLE : INVISIBLE); downloadIcon.setOnClickListener(v -> { progressBar.setVisibility(VISIBLE); downloadIcon.setVisibility(INVISIBLE); downloadIcon.setEnabled(false); missingMediaStatus.setText(StringUtils.getStringRobust(getContext(), R.string.media_download_in_progress)); MissingMediaDownloadHelper.requestMediaDownload(mediaUri, Dispatchers.getDefault(), result -> { if (result instanceof MissingMediaDownloadResult.Success) { AndroidUtil.showToast(getContext(), R.string.media_download_completed); hideMissingMediaView(); if (completion != null) { completion.run(); } } else if (!(result instanceof MissingMediaDownloadResult.InProgress)) { progressBar.setVisibility(GONE); downloadIcon.setVisibility(VISIBLE); downloadIcon.setEnabled(true); missingMediaStatus.setText(StringUtils.getStringRobust(getContext(), R.string.media_download_failed)); } }); }); }
Source:
<code>private void populateTeamsContainer() { if (!replay.getValidity().equals(Validity.VALID)) { showRatingChangeButton.setDisable(true); showRatingChangeButton.setText(i18n.get("game.notValid")); } else if (replay.getTeamPlayerStats() .values() .stream() .flatMap(Collection::stream) <START> .anyMatch(playerStats -> playerStats.getAfterMean() == null || playerStats.getAfterDeviation() == null)) { <END> showRatingChangeButton.setDisable(true); showRatingChangeButton.setText(i18n.get("game.notRatedYet")); } Map<Integer, PlayerStats> statsByPlayerId = teams.values().stream() .flatMap(Collection::stream) .collect(Collectors.toMap(PlayerStats::getPlayerId, Function.identity())); Platform.runLater(() -> teams.forEach((team, value) -> { List<Integer> playerIds = value.stream() .map(PlayerStats::getPlayerId) .collect(Collectors.toList()); TeamCardController controller = uiService.loadFxml("theme/team_card.fxml"); teamCardControllers.add(controller); playerService.getPlayersByIds(playerIds) .thenAccept(players -> controller.setPlayersInTeam(team, players, player -> { PlayerStats playerStats = statsByPlayerId.get(player.getId()); return new Rating(playerStats.getBeforeMean(), playerStats.getBeforeDeviation()); })); teamsContainer.getChildren().add(controller.getRoot()); })); }</code><technical_language>Extract this condition a method (CTRL+ALT+M) a self-explanatory name</technical_language>

Target:
private void populateTeamsContainer() { if (!replay.getValidity().equals(Validity.VALID)) { showRatingChangeButton.setDisable(true); showRatingChangeButton.setText(i18n.get("game.notValid")); } else if (!replayService.replayChangedRating(replay)) { showRatingChangeButton.setDisable(true); showRatingChangeButton.setText(i18n.get("game.notRatedYet")); } Map<Integer, PlayerStats> statsByPlayerId = teams.values().stream() .flatMap(Collection::stream) .collect(Collectors.toMap(PlayerStats::getPlayerId, Function.identity())); Platform.runLater(() -> teams.forEach((team, value) -> { List<Integer> playerIds = value.stream() .map(PlayerStats::getPlayerId) .collect(Collectors.toList()); TeamCardController controller = uiService.loadFxml("theme/team_card.fxml"); teamCardControllers.add(controller); playerService.getPlayersByIds(playerIds) .thenAccept(players -> controller.setPlayersInTeam(team, players, player -> { PlayerStats playerStats = statsByPlayerId.get(player.getId()); return new Rating(playerStats.getBeforeMean(), playerStats.getBeforeDeviation()); })); teamsContainer.getChildren().add(controller.getRoot()); })); }
Source:
<code><START> public void setUp() throws Exception { <END> IEclipseContext globalContext = Activator.getDefault() .getGlobalContext(); workbenchContext = globalContext.createChild("workbenchContext"); ContextInjectionFactory.make(CommandServiceAddon.class, workbenchContext); ContextInjectionFactory.make(ContextServiceAddon.class, workbenchContext); ContextInjectionFactory.make(BindingServiceAddon.class, workbenchContext); defineCommands(workbenchContext); defineContexts(workbenchContext); defineBindingTables(workbenchContext); }</code><technical_language>I throws Exception removed</technical_language>

Target:
public void setUp() { IEclipseContext globalContext = Activator.getDefault() .getGlobalContext(); workbenchContext = globalContext.createChild("workbenchContext"); ContextInjectionFactory.make(CommandServiceAddon.class, workbenchContext); ContextInjectionFactory.make(ContextServiceAddon.class, workbenchContext); ContextInjectionFactory.make(BindingServiceAddon.class, workbenchContext); defineCommands(workbenchContext); defineContexts(workbenchContext); defineBindingTables(workbenchContext); }
Source:
<code>private static String serialize(Object obj) throws IOException { ObjectMapper mapper = new ObjectMapper() .enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE); mapper.getSerializationConfig().addMixInAnnotations(ExtMap.class, JsonExtMapMixIn.class); <START> mapper.getSerializationConfig().addMixInAnnotations(IVdcQueryable.class, <END> JsonIVdcQueryableMixIn.class); return mapper.writeValueAsString(obj); }</code><technical_language>Do IVdcQueryable in AAA</technical_language>

Target:
private static String serialize(Object obj) throws IOException { ObjectMapper mapper = new ObjectMapper() .enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE); mapper.getSerializationConfig().addMixInAnnotations(ExtMap.class, JsonExtMapMixIn.class); return mapper.writeValueAsString(obj); }
Source:
<code>private static byte[] loadExternalResource(String location) throws IOException, CheckstyleException { final ByteArrayOutputStream content = new ByteArrayOutputStream(); final URI uri = CommonUtil.getUriByFilename(location); try (InputStream is = uri.toURL().openStream()) { do { final int size = is.read(BUFFER); if (size == -1) { break; } content.write(BUFFER, 0, size); <START> } while (true); <END> } return content.toByteArray(); }</code><technical_language>code static method</technical_language>

Target:
private static byte[] loadExternalResource(String location) throws IOException, CheckstyleException { final URI uri = CommonUtil.getUriByFilename(location); try (InputStream is = uri.toURL().openStream()) { return toByteArray(is); } }
Source:
<code>public VariableStatsEstimate visitCall(CallExpression call, Void context) { if (resolution.isNegateFunction(call.getFunctionHandle())) { return computeNegationStatistics(call, context); } FunctionMetadata functionMetadata = metadata.getFunctionManager().getFunctionMetadata(call.getFunctionHandle()); if (functionMetadata.getOperatorType().map(OperatorType::isArithmeticOperator).orElse(false)) { return computeArithmeticBinaryStatistics(call, context); } RowExpression value = new RowExpressionOptimizer(metadata).optimize(call, OPTIMIZED, session.toConnectorSession()); <START> if (value == null) { <END> return nullStatsEstimate(); } if (value instanceof ConstantExpression) { return value.accept(this, context); } if (resolution.isCastFunction(call.getFunctionHandle())) { return computeCastStatistics(call, context); } return VariableStatsEstimate.unknown(); }</code><technical_language>this is issue; null changed Object RowExpression. Remove this handled visitConstant</technical_language>

Target:
public VariableStatsEstimate visitCall(CallExpression call, Void context) { if (resolution.isNegateFunction(call.getFunctionHandle())) { return computeNegationStatistics(call, context); } FunctionMetadata functionMetadata = metadata.getFunctionManager().getFunctionMetadata(call.getFunctionHandle()); if (functionMetadata.getOperatorType().map(OperatorType::isArithmeticOperator).orElse(false)) { return computeArithmeticBinaryStatistics(call, context); } RowExpression value = new RowExpressionOptimizer(metadata).optimize(call, OPTIMIZED, session.toConnectorSession()); if (isNull(value)) { return nullStatsEstimate(); } if (value instanceof ConstantExpression) { return value.accept(this, context); } if (resolution.isCastFunction(call.getFunctionHandle())) { return computeCastStatistics(call, context); } return VariableStatsEstimate.unknown(); }
Source:
<code>public static SingleServerAppliance create(String id, String name, List<AvailableDataCenters> availableDataCenters, String osInstallationBase, Types.OSFamliyType osFamily, String os, String osVersion, int osArchitecture, Types.OSImageType osImageType, int minHddSize, Types.ApplianceType type, String state, String version, List<String> categories, String eulaUrl) { <START> return new AutoValue_SingleServerAppliance(id, name, availableDataCenters == null ? ImmutableList.<AvailableDataCenters>of() : availableDataCenters, osInstallationBase, osFamily, os, osVersion, osArchitecture, osImageType, minHddSize, type, state, version, categories == null ? ImmutableList.<String>of() : categories, eulaUrl); <END> }</code><technical_language>ImmutableList.copyOf lists null</technical_language>

Target:
public static SingleServerAppliance create(String id, String name, List<AvailableDataCenters> availableDataCenters, String osInstallationBase, Types.OSFamliyType osFamily, String os, String osVersion, int osArchitecture, Types.OSImageType osImageType, int minHddSize, Types.ApplianceType type, String state, String version, List<String> categories, String eulaUrl) { return builder() .id(id) .name(name) .availableDataCenters(availableDataCenters == null ? ImmutableList.<AvailableDataCenters>of() : ImmutableList.copyOf(availableDataCenters)) .osInstallationBase(osInstallationBase) .osFamily(osFamily) .os(os) .osVersion(osVersion) .osArchitecture(osArchitecture) .osImageType(osImageType) .minHddSize(minHddSize) .type(type) .state(state) .version(version) .categories(categories == null ? ImmutableList.<String>of() : ImmutableList.copyOf(categories)) .eulaUrl(eulaUrl) .build(); }
Source:
<code>public void testResourceLoadingAtOpenSession() throws Exception { SessionManager.INSTANCE.addSessionsListener(new SessionManagerListener.Stub() { @Override public void notify(Session updated, int notification) { super.notify(updated, notification); if (notification == SessionListener.OPENING) { ResourceSet resourceSet = session.getTransactionalEditingDomain().getResourceSet(); EList<Resource> resources = resourceSet.getResources(); assertEquals("ResourceSet should contain only 2 resources at SessionListener.OPENING notification. <START> Resources in <END> resourceSet :", 2, resources.size()); } } @Override public void notifyAddSession(Session newSession) { ResourceSet resourceSet = session.getTransactionalEditingDomain().getResourceSet(); EList<Resource> resources = resourceSet.getResources(); assertEquals("ResourceSet should contain only resources at notifyAddSession. Resources in resourceSet :", 2, resources.size()); } }); copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, PATH, AIRD_MODEL_FILENAME, SEMANTIC_MODEL_FILENAME); URI sessionResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + AIRD_MODEL_FILENAME, true); session = SessionFactory.INSTANCE.createSession(sessionResourceURI, new NullProgressMonitor()); session.open(new NullProgressMonitor()); }</code><technical_language>Nb resources</technical_language>

Target:
public void testResourceLoadingAtOpenSession() throws Exception { SessionManager.INSTANCE.addSessionsListener(new SessionManagerListener.Stub() { @Override public void notify(Session updated, int notification) { super.notify(updated, notification); if (notification == SessionListener.OPENING) { ResourceSet resourceSet = session.getTransactionalEditingDomain().getResourceSet(); EList<Resource> resources = resourceSet.getResources(); assertEquals("Wrong number of ResourceSet resources at SessionListener.OPENING notification", 2, resources.size()); } } @Override public void notifyAddSession(Session newSession) { ResourceSet resourceSet = session.getTransactionalEditingDomain().getResourceSet(); EList<Resource> resources = resourceSet.getResources(); assertEquals("Wrong number of ResourceSet resources at notifyAddSession", 1, resources.size()); } }); copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, PATH, AIRD_MODEL_FILENAME, SEMANTIC_MODEL_FILENAME); URI sessionResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + AIRD_MODEL_FILENAME, true); session = SessionFactory.INSTANCE.createSession(sessionResourceURI, new NullProgressMonitor()); session.open(new NullProgressMonitor()); }
Source:
<code>public Type[] getActualTypeArguments() { <START> return actualTypeArguments.clone(); <END> }</code><technical_language>This is necessary control. suppress warning instead</technical_language>

Target:
public Type[] getActualTypeArguments() { return actualTypeArguments; }
Source:
<code>public PerUnitGcBiasMetricsCollector(final String sample, final String library, final String readGroup) { this.sample = sample; this.library = library; this.readGroup = readGroup; final String prefix; if (this.readGroup != null) { prefix = this.readGroup; gcData.put(prefix, new GcObject()); } else if (this.library != null) { prefix = this.library; gcData.put(prefix, new GcObject()); } else if (this.sample != null) { prefix = this.sample; gcData.put(prefix, new GcObject()); } else { <START> prefix = "All_Reads"; <END> gcData.put(prefix, new GcObject()); } }</code><technical_language>want this a symbol later</technical_language>

Target:
public PerUnitGcBiasMetricsCollector(final String sample, final String library, final String readGroup) { this.sample = sample; this.library = library; this.readGroup = readGroup; final String prefix; if (this.readGroup != null) { prefix = this.readGroup; gcData.put(prefix, new GcObject()); } else if (this.library != null) { prefix = this.library; gcData.put(prefix, new GcObject()); } else if (this.sample != null) { prefix = this.sample; gcData.put(prefix, new GcObject()); } else { prefix = allReads; gcData.put(prefix, new GcObject()); } }
Source:
<code>public Response testMail() throws MessagingException { <START> NotificationMail.sendMailSync(getUserId(), new Event("unknown", 0), null); <END> return Response.noContent().build(); }</code><technical_language>"test" instead of "unknown"</technical_language>

Target:
public Response testMail() throws MessagingException { NotificationMail.sendMailSync(getUserId(), new Event("test", 0), null); return Response.noContent().build(); }
Source:
<code>public void usesImplictAndExplicitFieldAliasAndIncludeExclude() { ProjectionOperation operation = Aggregation.project("foo").and("foobar").as("bar").andInclude("inc1", "inc2") .andExclude("_id"); DBObject dbObject = operation.toDBObject(Aggregation.DEFAULT_CONTEXT); DBObject projectClause = DBObjectUtils.getAsDBObject(dbObject, PROJECT); <START> assertThat(projectClause.get("foo"), is((Object) "$foo")); END> assertThat(projectClause.get("bar"), is((Object) "$foobar")); assertThat((Integer) projectClause.get("inc1"), is(1)); assertThat((Integer) projectClause.get("inc2"), is(1)); assertThat((Integer) projectClause.get("_id"), is(0)); }</code><technical_language>right side of this 1 well</technical_language>

Target:
public void usesImplictAndExplicitFieldAliasAndIncludeExclude() { ProjectionOperation operation = Aggregation.project("foo").and("foobar").as("bar").andInclude("inc1", "inc2") .andExclude("_id"); DBObject dbObject = operation.toDBObject(Aggregation.DEFAULT_CONTEXT); DBObject projectClause = DBObjectUtils.getAsDBObject(dbObject, PROJECT); assertThat((Integer) projectClause.get("foo"), is(1)); assertThat(projectClause.get("bar"), is((Object) "$foobar")); assertThat((Integer) projectClause.get("inc1"), is(1)); assertThat((Integer) projectClause.get("inc2"), is(1)); assertThat((Integer) projectClause.get("_id"), is(0)); }
Source:
<code>private WebResponse makeRequest(List<NameValuePair> postData) throws Exception { WebRequest request = new WebRequest(client.createCrumbedUrl(ENDPOINT), POST); if (postData != null) request.setRequestParameters(postData); <START> request.setCharset(Charset.forName("UTF-8")); <END> return client.loadWebResponse(request); }</code><technical_language>java.nio.charset.StandardCharsets.UTF_8 instead</technical_language>

Target:
private WebResponse makeRequest(List<NameValuePair> postData) throws Exception { WebRequest request = new WebRequest(client.createCrumbedUrl(ENDPOINT), POST); if (postData != null) request.setRequestParameters(postData); request.setCharset(StandardCharsets.UTF_8); return client.loadWebResponse(request); }
Source:
<code>IFocusSelectable[] getFocusSelectableSegments() { if (selectableSegments != null || paragraphs == null) return selectableSegments; Vector<ParagraphSegment> result = new Vector<>(); for (Paragraph <START> p : <END> paragraphs) { ParagraphSegment[] segments = p.getSegments(); for (ParagraphSegment segment : segments) { if (segment instanceof IFocusSelectable) result.add(segment); } } selectableSegments = result .toArray(new IFocusSelectable[result.size()]); return selectableSegments; }</code><technical_language>consistency: rename loop vars paragraph</technical_language>

Target:
IFocusSelectable[] getFocusSelectableSegments() { if (selectableSegments != null || paragraphs == null) return selectableSegments; Vector<ParagraphSegment> result = new Vector<>(); for (Paragraph paragraph : paragraphs) { ParagraphSegment[] segments = paragraph.getSegments(); for (ParagraphSegment segment : segments) { if (segment instanceof IFocusSelectable) result.add(segment); } } selectableSegments = result .toArray(new IFocusSelectable[result.size()]); return selectableSegments; }
Source:
<code>public void display_tags_with_edit() { executeBuild("shared/xoo-sample", "sample-with-tags", "Sample with tags"); wsClient.wsConnector().call( new PostRequest("api/project_tags/set") .setParam("project", "sample-with-tags") .setParam("tags", "foo,bar,baz") ); executeBuild("shared/xoo-sample", "sample", "Sample"); ProjectDashboardPage page = nav.logIn().asAdmin().openProjectDashboard("sample"); SelenideElement tags = page.getTags(); <START> tags.$(".tags-list > span").should(hasText("No tags")); <END> tags.$("button").shouldBe(visible).click(); tags.$("div.multi-select").shouldBe(visible); tags.$$("ul.menu a").get(2).click(); tags.$(".tags-list > span").should(hasText("foo")); tags.$("input").sendKeys("test"); tags.$$("ul.menu a").get(1).should(hasText("+ test")).click(); tags.$(".tags-list > span").should(hasText("foo, test")); tags.$$("ul.menu a").get(1).should(hasText("test")); tags.$("input").sendKeys(Keys.ENTER); tags.$(".tags-list > span").should(hasText("foo")); }</code><technical_language>here, hide low-level implementation</technical_language>

Target:
public void display_tags_with_edit() { executeBuild("shared/xoo-sample", "sample-with-tags", "Sample with tags"); wsClient.wsConnector().call( new PostRequest("api/project_tags/set") .setParam("project", "sample-with-tags") .setParam("tags", "foo,bar,baz") ); executeBuild("shared/xoo-sample", "sample", "Sample"); ProjectDashboardPage page = nav.logIn().asAdmin().openProjectDashboard("sample"); page .shouldHaveTags("No tags") .shouldBeEditable() .openTagEditor() .getTagAtIdx(2).click(); page .shouldHaveTags("foo") .sendKeysToTagsInput("test") .getTagAtIdx(0).should(hasText("+ test")).click(); page .shouldHaveTags("foo", "test") .getTagAtIdx(1).should(hasText("test")); page .sendKeysToTagsInput(Keys.ENTER) .shouldHaveTags("test"); }
Source:
<code>public void testCreateFailNotFound() { <START> PluginDescriptor pluginDescriptor = mock(DefaultPluginDescriptor.class); <END> when(pluginDescriptor.getPluginClass()).thenReturn("org.pf4j.plugin.NotFoundTestPlugin"); PluginWrapper pluginWrapper = mock(PluginWrapper.class); when(pluginWrapper.getDescriptor()).thenReturn(pluginDescriptor); when(pluginWrapper.getPluginClassLoader()).thenReturn(getClass().getClassLoader()); DefaultPluginFactory instance = new DefaultPluginFactory(); Plugin result = instance.create(pluginWrapper); assertNull(result); }</code><technical_language>need change. I feel refactoring action</technical_language>

Target:
public void testCreateFailNotFound() { PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class); when(pluginDescriptor.getPluginClass()).thenReturn("org.pf4j.plugin.NotFoundTestPlugin"); PluginWrapper pluginWrapper = mock(PluginWrapper.class); when(pluginWrapper.getDescriptor()).thenReturn(pluginDescriptor); when(pluginWrapper.getPluginClassLoader()).thenReturn(getClass().getClassLoader()); DefaultPluginFactory instance = new DefaultPluginFactory(); Plugin result = instance.create(pluginWrapper); assertNull(result); }
Source:
<code>private void initUserAnswers() { OrderedHashtable<String, QueryPrompt> queryPrompts = queryDatum.getUserQueryPrompts(); for (Enumeration en = queryPrompts.keys(); en.hasMoreElements(); ) { String promptId = (String)en.nextElement(); QueryPrompt prompt = queryPrompts.get(promptId); String defaultValue = ""; if(prompt.getDefaultValueExpr() != null) { <START> defaultValue = FunctionUtils.toString(prompt.getDefaultValueExpr().eval(evaluationContext)); <END> } userAnswers.put(prompt.getKey(), defaultValue); } }</code><technical_language>this result in XPathExceptions, top level calls this path catching exception showing error user</technical_language>

Target:
private void initUserAnswers() throws XPathException { OrderedHashtable<String, QueryPrompt> queryPrompts = queryDatum.getUserQueryPrompts(); for (Enumeration en = queryPrompts.keys(); en.hasMoreElements(); ) { String promptId = (String)en.nextElement(); QueryPrompt prompt = queryPrompts.get(promptId); String defaultValue = ""; if(prompt.getDefaultValueExpr() != null) { defaultValue = FunctionUtils.toString(prompt.getDefaultValueExpr().eval(evaluationContext)); } userAnswers.put(prompt.getKey(), defaultValue); } }
Source:
<code>public void onActivityCreated(final Activity activity, Bundle bundle) { Observable .just(activity) .filter(sameInstance) <START> .subscribe(sendCreateEvent); <END> }</code><technical_language>Observable in callbacks is wasteful in allocation performance. I advantage java if (activity == activityToMonitor) { subscriber.onNext(LifecycleEvent.CREATE); } is allocation-free</technical_language>

Target:
public void onActivityCreated(final Activity activity, Bundle bundle) { sendEvent(activity, LifecycleEvent.CREATE); }
Source:
<code>public OutputSettings charset(Charset charset) { if( document != null ) { <START> Element meta = document.select("meta[charset]").first(); <END> if( meta != null ) { meta.attr("charset", charset.displayName()); } } this.charset = charset; charsetEncoder = charset.newEncoder(); return this; }</code><technical_language>other forms of this? meta name=charset value=, meta htt-equiv contenttype? code in DataUtils for that, able reuse</technical_language>

Target:
public OutputSettings charset(Charset charset) { this.charset = charset; charsetEncoder = charset.newEncoder(); return this; }
Source:
<code>public static String makeRandomPassword(final int length, String... passwordValidCharsPool) { Preconditions.checkState(length >= passwordValidCharsPool.length); int l = 0; <START> char[] id = new char[length]; <END> for(int i = 0; i < passwordValidCharsPool.length; i++){ id[l++] = pickRandomCharFrom(passwordValidCharsPool[i]); } String remainingValidChars = passwordValidCharsPool[passwordValidCharsPool.length - 1]; while(l < length) { id[l++] = pickRandomCharFrom(remainingValidChars); } return new String(id); }</code><technical_language>Minor: call password instead of id</technical_language>

Target:
public static String makeRandomPassword(final int length, String... passwordValidCharsPool) { Preconditions.checkState(length >= passwordValidCharsPool.length); int l = 0; Character[] password = new Character[length]; for(int i = 0; i < passwordValidCharsPool.length; i++){ password[l++] = pickRandomCharFrom(passwordValidCharsPool[i]); } String remainingValidChars = mergeCharacterSets(passwordValidCharsPool); while(l < length) { password[l++] = pickRandomCharFrom(remainingValidChars); } List<Character> list = Arrays.asList(password); Collections.shuffle(list); return Joiner.on("").join(list); }
Source:
<code>private Object createSecurityManager(SparkConf conf) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Object securityManager = null; try { Constructor<?> smConstructor = getClass().getClassLoader() .loadClass("org.apache.spark.SecurityManager") <START> .getConstructor(new Class[]{ SparkConf.class }); <END> } catch (NoSuchMethodException e) { Constructor<?> smConstructor = getClass().getClassLoader() .loadClass("org.apache.spark.SecurityManager") .getConstructor(new Class[]{ SparkConf.class, scala.Option.class }); securityManager = smConstructor.newInstance(conf, null); } return securityManager; }</code><technical_language>two-arg constructor is newest version of Spark, one-arg constructor is older version of Spark, for two-arg constructor first? for constructors if older version of Spark. this is negligible this method called Spark interpreter anyway</technical_language>

Target:
private Object createSecurityManager(SparkConf conf) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Object securityManager = null; try { Constructor<?> smConstructor = getClass().getClassLoader() .loadClass("org.apache.spark.SecurityManager") .getConstructor(new Class[]{ SparkConf.class, scala.Option.class }); securityManager = smConstructor.newInstance(conf, null); } catch (NoSuchMethodException e) { Constructor<?> smConstructor = getClass().getClassLoader() .loadClass("org.apache.spark.SecurityManager") .getConstructor(new Class[]{ SparkConf.class }); securityManager = smConstructor.newInstance(conf); } return securityManager; }
Source:
<code>public void theGetOrganizationResponseContains(final Map<String, String> expectedResult) { final FindOrganisationResponse response = (FindOrganisationResponse) ScenarioContext.current() .get(PlatformCommonKeys.RESPONSE); final Organisation organisation = response.getOrganisation(); final Organisation expected = this.createOrganisation(expectedResult); <START> if (this.organisationMatches(expected, organisation)) { <END> return; } Assert.fail("Expected organization \"" + expected.getOrganisationIdentification() + "\" was not found as the organization in the response"); }</code><technical_language>Replace if Assert.fail Assert.assertTrue("....", this.organisationMatches(...))</technical_language>

Target:
public void theGetOrganizationResponseContains(final Map<String, String> expectedResult) { final FindOrganisationResponse response = (FindOrganisationResponse) ScenarioContext.current() .get(PlatformCommonKeys.RESPONSE); final Organisation organisation = response.getOrganisation(); final Organisation expected = this.createOrganisation(expectedResult); Assert.assertTrue( "Expected organization \"" + expected.getOrganisationIdentification() + "\" was not found as the organization in the response", this.organisationMatches(expected, organisation)); }
Source:
<code>private String getDeviceIpAddress(final DlmsDevice dlmsDevice, final String messageMetaDataIpAddress) throws SessionProviderException { String deviceIpAddress = null; final String iccId = dlmsDevice.getIccId(); try { deviceIpAddress = this.getDeviceIpAddressFromSessionProvider(iccId, dlmsDevice); } catch (final SessionProviderUnsupportedException e) { LOGGER.warn( "iccId is not supported by the sessionProvider for {}. Using device messageMetaData IpAddress {}", iccId, dlmsDevice.getCommunicationProvider(), messageMetaDataIpAddress); return messageMetaDataIpAddress; } if (deviceIpAddress == null) { <START> throw new SessionProviderException("The meter did not wake up in 5 minutes"); <END> } return deviceIpAddress; }</code><technical_language>"5 minutes" in exception message from? I suspect this depends configuration, a remark "within time configured for checking" is more correct</technical_language>

Target:
private String getDeviceIpAddress(final DlmsDevice dlmsDevice, final String messageMetaDataIpAddress) throws SessionProviderException { String deviceIpAddress = null; final String iccId = dlmsDevice.getIccId(); try { deviceIpAddress = this.getDeviceIpAddressFromSessionProvider(iccId, dlmsDevice); } catch (final SessionProviderUnsupportedException e) { LOGGER.warn( "iccId " + iccId + " is not supported by the sessionProvider for " + dlmsDevice.getCommunicationProvider() + ". Using device messageMetaData IpAddress " + messageMetaDataIpAddress, e); return messageMetaDataIpAddress; } if (deviceIpAddress == null) { throw new SessionProviderException("The meter did not wake up. Retried " + this.jasperGetSessionRetries + " times in a total amount of " + this.jasperGetSessionRetries * this.jasperGetSessionSleepBetweenRetries + " seconds"); } return deviceIpAddress; }
Source:
<code>protected Warning createWarning(final Matcher matcher) { <START> String tool, type, category, message, fileName; <END> int lineNumber = 0; int column = 0; List<String> arr = new ArrayList<String>(); int n = matcher.groupCount(); for (int i = 0; i<= n; i++) arr.add(i,matcher.group(i)); Priority priority = Priority.LOW; if (matcher.group(1) != null) { tool = matcher.group(2); type = matcher.group(3); category = matcher.group(4); fileName = matcher.group(6); lineNumber = getLineNumber(matcher.group(7)); message = matcher.group(5); priority = Priority.NORMAL; } else if (matcher.group(16) != null) { return handleDirectory(matcher, 20); } else if (matcher.group(8) != null) { tool = matcher.group(9); type = matcher.group(10); category = matcher.group(11); fileName = matcher.group(12); lineNumber = getLineNumber(matcher.group(13)); priority = Priority.NORMAL; message = matcher.group(15); } else if (matcher.group(21) != null) { tool = matcher.group(22); type = matcher.group(23); category = matcher.group(24); message = matcher.group(25); fileName = "/NotFileRelated"; } else { return FALSE_POSITIVE; } if (category.equalsIgnoreCase("E")) { priority = Priority.HIGH; category = "Error (" + tool + "): " + category; } else { category = "Warning (" + tool + "): " + category; } if (fileName.startsWith(SLASH)) { return createWarning(fileName, lineNumber, category, message, priority); } else { return createWarning(directory + fileName, lineNumber, category, message, priority); } }</code><technical_language>Single line variable. move variables position first</technical_language>

Target:
protected Warning createWarning(final Matcher matcher) { String tool; String type; String category; String message; String fileName; int lineNumber = 0; int column = 0; List<String> arr = new ArrayList<String>(); int n = matcher.groupCount(); for (int i = 0; i <= n; i++) { arr.add(i, matcher.group(i)); } Priority priority = Priority.LOW; if (matcher.group(1) != null) { tool = matcher.group(2); type = matcher.group(3); category = matcher.group(4); fileName = matcher.group(6); lineNumber = getLineNumber(matcher.group(7)); message = matcher.group(5); priority = Priority.NORMAL; } else if (matcher.group(16) != null) { return handleDirectory(matcher, 20); } else if (matcher.group(8) != null) { tool = matcher.group(9); type = matcher.group(10); category = matcher.group(11); fileName = matcher.group(12); lineNumber = getLineNumber(matcher.group(13)); priority = Priority.NORMAL; message = matcher.group(15); } else if (matcher.group(21) != null) { tool = matcher.group(22); type = matcher.group(23); category = matcher.group(24); message = matcher.group(25); fileName = "/NotFileRelated"; } else { return FALSE_POSITIVE; } if (category.equalsIgnoreCase("E")) { priority = Priority.HIGH; category = "Error (" + tool + "): " + category; } else { category = "Warning (" + tool + "): " + category; } if (fileName == null) { return FALSE_POSITIVE; } if (fileName.startsWith(SLASH)) { return createWarning(fileName, lineNumber, category, message, priority); } else { return createWarning(directory + fileName, lineNumber, category, message, priority); } }
Source:
<code>public static @NonNull Collection<ITmfTrace> getTraceSet(ITmfTrace trace) { if (trace == null) { return NonNullUtils.checkNotNull(ImmutableSet.<ITmfTrace> of()); } List<ITmfTrace> traces = trace.getChildren(ITmfTrace.class); if (traces.size() > 0) { return NonNullUtils.checkNotNull(ImmutableSet.<ITmfTrace> copyOf(traces)); } <START> return NonNullUtils.checkNotNull(ImmutableSet.<ITmfTrace> of(trace)); <END> }</code><technical_language>for lines, need <ITmfTrace>, type inference figures out</technical_language>

Target:
public static @NonNull Collection<ITmfTrace> getTraceSet(ITmfTrace trace) { if (trace == null) { return NonNullUtils.checkNotNull(ImmutableSet.<ITmfTrace> of()); } List<ITmfTrace> traces = trace.getChildren(ITmfTrace.class); if (traces.size() > 0) { return NonNullUtils.checkNotNull(ImmutableSet.copyOf(traces)); } return NonNullUtils.checkNotNull(ImmutableSet.of(trace)); }
Source:
<code>protected static String getPopulatedEmptyStringErrorMessage(String messageTemplate, String fieldName, int maxLength) throws ReflectiveOperationException { <START> return (String) invokeMethod(FieldValidator.class, "getPopulatedEmptyStringErrorMessage", <END> new Class<?>[] { String.class, String.class, int.class }, null, new Object[] { messageTemplate, fieldName, maxLength }); }</code><technical_language>call method directly, instead of reflection. return FieldValidator.getPopulatedEmptyStringErrorMessage(...);</technical_language>

Target:
protected static String getPopulatedEmptyStringErrorMessage(String messageTemplate, String fieldName, int maxLength) { return FieldValidator.getPopulatedEmptyStringErrorMessage(messageTemplate, fieldName, maxLength); }
Source:
<code>public void onNewOptionSelected() { final AppCompatActivity activity = UiUtils.getActivityFromView(view); if (activity == null) { return; } TextInputDialog.Builder builder = new TextInputDialog.Builder(activity); builder.setHint(activity.getString(R.string.dialog_new_broadcast_message_name)) .setTextWatcher(new NonEmptyStringTextWatcher()) .setPositiveButton(activity.getString(R.string.ok), new TextInputDialog.OnClickListener() { @Override public void onPositiveButtonClick(DialogInterface dialog, String textInput) { addItem(textInput); <START> notifyDataSetChanged(activity); <END> } }); builder.setTitle(R.string.dialog_new_broadcast_message_title) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { spinner.setSelection(getBroadcastMessage()); } }) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { spinner.setSelection(getBroadcastMessage()); } }) .show(); }</code><technical_language>if activity if SpriteActivity, for ScriptFragment present in cast activity SpriteActivity call method added notifyDataSetChanged() added. sense reuse it</technical_language>

Target:
public void onNewOptionSelected() { final SpriteActivity activity = (SpriteActivity) UiUtils.getActivityFromView(view); if (activity == null) { return; } TextInputDialog.Builder builder = new TextInputDialog.Builder(activity); builder.setHint(activity.getString(R.string.dialog_new_broadcast_message_name)) .setTextWatcher(new NonEmptyStringTextWatcher()) .setPositiveButton(activity.getString(R.string.ok), getOkButtonListener(activity)) .setTitle(R.string.dialog_new_broadcast_message_title) .setNegativeButton(R.string.cancel, getNegativeButtonListener()) .setOnCancelListener(getCanceledListener()) .show(); }
Source:
<code>private void loadRemoteStartPage(boolean loadThroughFrontDoor) { assert !bootconfig.isLocal(); String startPage = bootconfig.getStartPage(); String url = startPage; if (loadThroughFrontDoor) { url = getFrontDoorUrl(url, false); } <START> SalesforceHybridLogger.i(TAG, "loadRemoteStartPage called - loading: " + startPage); <END> loadUrl(url); webAppLoaded = true; }</code><technical_language>Minor: change this log line url correctly reflect URL loaded</technical_language>

Target:
private void loadRemoteStartPage(boolean loadThroughFrontDoor) { assert !bootconfig.isLocal(); String startPage = bootconfig.getStartPage(); String url = startPage; if (loadThroughFrontDoor) { url = getFrontDoorUrl(url, false); } SalesforceHybridLogger.i(TAG, "loadRemoteStartPage called - loading: " + url); loadUrl(url); webAppLoaded = true; }