auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private List<CheckpointedResultSubpartition> calculateMapping(ResultSubpartitionInfo info) { final RescaledChannelsMapping rescaledChannelsMapping = channelMapping.getChannelMapping(info.getPartitionIdx()); <START> final List<CheckpointedResultSubpartition> subpartitions = Arrays.stream(rescaledChannelsMapping.getNewChannelIndexes(info.getSubPartitionIdx())) <END> .mapToObj(newIndexes -> getSubpartition(info.getPartitionIdx(), newIndexes)) .collect(Collectors.toList()); LOG.info("output#calculateMapping for using {}: {}", info, rescaledChannelsMapping, subpartitions.stream().map(CheckpointedResultSubpartition::getSubpartitionInfo).collect(Collectors.toList())); return subpartitions; }</code><technical_language>nit: move top</technical_language>

Target:
private List<CheckpointedResultSubpartition> calculateMapping(ResultSubpartitionInfo info) { final RescaledChannelsMapping rescaledChannelsMapping = channelMapping.getChannelMapping(info.getPartitionIdx()); final List<CheckpointedResultSubpartition> subpartitions = Arrays.stream(rescaledChannelsMapping.getNewChannelIndexes(info.getSubPartitionIdx())) .mapToObj(newIndexes -> getSubpartition(info.getPartitionIdx(), newIndexes)) .collect(Collectors.toList()); if (subpartitions.isEmpty()) { throw new IllegalStateException("Recovered a buffer from old " + info + " that has no mapping in " + rescaledChannelsMapping); } return subpartitions; }
Source:
<code>public Document getInnerDocument() { IRubyObject innerDocument = getRubyProperty("inner_document"); if (innerDocument.isNil()) return null; <START> return (Document) NodeConverter.createASTNode(innerDocument); <END> }</code><technical_language>I tested it, I this compile</technical_language>

Target:
public Document getInnerDocument() { IRubyObject innerDocument = getRubyProperty("inner_document"); if (innerDocument.isNil()) { return null; } return (Document) NodeConverter.createASTNode(innerDocument); }
Source:
<code>public Message next() { <START> Timer.Context readingTimerContext = readingTimer.time(); <END> try { MessageAndMetadata<byte[], byte[]> message = iterator.next(); MessageWithMetadata unwrappedContent = contentWrapper.unwrapContent(message.message()); return new Message( unwrappedContent.getMessageMetadata().getId(), message.offset(), message.partition(), message.topic(), unwrappedContent.getContent(), unwrappedContent.getMessageMetadata().getTimestamp(), clock.getTime()); } catch (ConsumerTimeoutException consumerTimeoutException) { throw new MessageReceivingTimeoutException("No messages received", consumerTimeoutException); } catch (Exception e) { throw new InternalProcessingException("Message received failed", e); } finally { readingTimerContext.close(); } }</code><technical_language>Timer.Context managed try-with-resources. implements AutoCloseable interface</technical_language>

Target:
public Message next() { try (Timer.Context readingTimerContext = readingTimer.time()) { MessageAndMetadata<byte[], byte[]> message = iterator.next(); UnwrappedMessageContent unwrappedContent = contentWrapper.unwrapContent(message.message()); return new Message( unwrappedContent.getMessageMetadata().getId(), message.offset(), message.partition(), message.topic(), unwrappedContent.getContent(), unwrappedContent.getMessageMetadata().getTimestamp(), clock.getTime()); } catch (ConsumerTimeoutException consumerTimeoutException) { throw new MessageReceivingTimeoutException("No messages received", consumerTimeoutException); } catch (Exception e) { throw new InternalProcessingException("Message received failed", e); } }
Source:
<code>public void checkPagingOneByOneThroughReferenceBases() throws AvroRemoteException { final String refId = Utils.getValidReferenceId(client); final long sequenceStart = 0L; final long sequenceEnd = 150L; final ListReferenceBasesRequest req = ListReferenceBasesRequest.newBuilder() .setStart(sequenceStart).setEnd(sequenceEnd) .build(); final ListReferenceBasesResponse resp = client.references.getReferenceBases(refId, req); final String expectedSequence = resp.getSequence(); assertThat(expectedSequence).hasSize((int)sequenceEnd); long offset = 0L; <START> for (char expectedChar : expectedSequence.toCharArray()) { <END> final ListReferenceBasesRequest pageReq = ListReferenceBasesRequest.newBuilder() .setStart(offset).setEnd(offset + 1) .build(); final ListReferenceBasesResponse pageResp = client.references.getReferenceBases(refId, pageReq); final String sequence = pageResp.getSequence(); assertThat(sequence).hasSize(1); assertThat(sequence.charAt(0)).isEqualTo(expectedChar); offset = pageResp.getOffset() + 1; } assertThat(offset).isEqualTo(sequenceEnd); }</code><technical_language>150 serial requests overkill. a smaller range? larger intervals</technical_language>

Target:
public void checkPagingOneByOneThroughReferenceBases() throws AvroRemoteException { final String refId = Utils.getValidReferenceId(client); final long sequenceStart = 2L; final long sequenceEnd = 15L; final ListReferenceBasesRequest req = ListReferenceBasesRequest.newBuilder() .setStart(sequenceStart).setEnd(sequenceEnd) .build(); final ListReferenceBasesResponse resp = client.references.getReferenceBases(refId, req); final String expectedSequence = resp.getSequence(); assertThat(expectedSequence).hasSize((int)(sequenceEnd - sequenceStart)); long offset = sequenceStart; for (char expectedChar : expectedSequence.toCharArray()) { final ListReferenceBasesRequest pageReq = ListReferenceBasesRequest.newBuilder() .setStart(offset).setEnd(offset + 1) .build(); final ListReferenceBasesResponse pageResp = client.references.getReferenceBases(refId, pageReq); final String sequence = pageResp.getSequence(); assertThat(sequence).hasSize(1); assertThat(sequence.charAt(0)).isEqualTo(expectedChar); offset = pageResp.getOffset() + 1; } assertThat(offset).isEqualTo(sequenceEnd); }
Source:
<code>public LogBuilder atTrace() { if (isTraceEnabled()) { <START> return logBuilder.get().setLevel(Level.TRACE); <END> } else { return LogBuilder.INSTANCE; } }</code><technical_language>I need similar ReusableParameterizedMessage.reserved for this work, clobber threadlocal state this: java private void func() { log.atInfo().withMessage("Value {}").withParameters(getValue()).log(); } private Object getValue() { log.atInfo().withMessage("Getting Value").log(); return value; }</technical_language>

Target:
public LogBuilder atTrace() { return atLevel(Level.TRACE); }
Source:
<code>private void saveMessage(SQLiteDatabase db, Message message) { ContentValues cv = new ContentValues(); cv.put("id", message.id); cv.put("thread_id", message.threadId); cv.put("author_id", message.authorId); cv.put("date", DateConverter.dateToLong(message.date)); cv.put("body", message.rawBody); <START> int status = (message.isNew ? 1 : 0) | <END> (message.isPushed ? 1 : 0) << MessageTable.STATUS_BIT_IS_PUSHED; cv.put("status", status); insertOrUpdate(db, MessageTable.NAME, cv, message.id); }</code><technical_language>torn here. hand, "YAGNI". status is is moment fix prematurely in *yet*. other hand, I slip through. decide. :)</technical_language>

Target:
private void saveMessage(SQLiteDatabase db, Message message) { ContentValues cv = new ContentValues(); cv.put("id", message.id); cv.put("thread_id", message.threadId); cv.put("author_id", message.authorId); cv.put("date", DateConverter.dateToLong(message.date)); cv.put("body", message.rawBody); int status = (message.isNew ? 1 : 0) << MessageTable.STATUS_BIT_IS_NEW | (message.isPushed ? 1 : 0) << MessageTable.STATUS_BIT_IS_PUSHED; cv.put("status", status); insertOrUpdate(db, MessageTable.NAME, cv, message.id); }
Source:
<code>public void addLabels(String issueId, List<String> labels) { List<String> newLabels = Lists.newArrayList(); Issue existingIssue = service.getIssue(issueId); if(existingIssue.getLabels() != null) newLabels.addAll(existingIssue.getLabels()); boolean changed = false; for(String label : labels) { if(!newLabels.contains(label)) { newLabels.add(label); changed = true; } } <START> if(changed) <END> service.setIssueLabels(issueId, newLabels); }</code><technical_language>please add brackets</technical_language>

Target:
public void addLabels(String issueId, List<String> labels) { List<String> newLabels = Lists.newArrayList(); Issue existingIssue = service.getIssue(issueId); if(existingIssue.getLabels() != null) { newLabels.addAll(existingIssue.getLabels()); } boolean changed = false; for(String label : labels) { if(!newLabels.contains(label)) { newLabels.add(label); changed = true; } } if(changed) { service.setIssueLabels(issueId, newLabels); } }
Source:
<code>private static boolean isArgumentCompatible(Type argumentType, Type collectionParameterType) { <START> if (collectionParameterType instanceof JavaType.WildCardType) { <END> return argumentType.isSubtypeOf(collectionParameterType); } return isSubtypeOf(argumentType.erasure(), collectionParameterType.erasure()) || isSubtypeOf(collectionParameterType.erasure(), argumentType.erasure()) || autoboxing(argumentType, collectionParameterType); }</code><technical_language>This lacks a fixme a link ticket explanation</technical_language>

Target:
private static boolean isArgumentCompatible(Type argumentType, Type collectionParameterType) { if (((JavaType) collectionParameterType).isTagged(JavaType.WILDCARD)) { return argumentType.isSubtypeOf(collectionParameterType); } return isSubtypeOf(argumentType.erasure(), collectionParameterType.erasure()) || isSubtypeOf(collectionParameterType.erasure(), argumentType.erasure()) || autoboxing(argumentType, collectionParameterType); }
Source:
<code>public void stop(Duration delayInSeconds) { LOGGER.info("Will stop node in seconds", delayInSeconds.getSeconds()); runAfterDelay(delayInSeconds, () -> { LOGGER.info("Stopping node"); <START> ServerEnv.getServer().stop(); <END> }); }</code><technical_language>new API, please change ServerEnv.getServer().stop(ZAP); remove TODO</technical_language>

Target:
public void stop(Duration delayInSeconds) { LOGGER.info("Will stop node in seconds", delayInSeconds.getSeconds()); runAfterDelay(delayInSeconds, () -> { LOGGER.info("Stopping node"); ServerEnv.getServer().stop(ZAP); }); }
Source:
<code>public String eventSchedProcessWaking() { <START> return SCHED_WAKING; <END> }</code><technical_language>put "sched_waking" inline. eventually move other do too. private static final String initial copy-paste</technical_language>

Target:
public String eventSchedProcessWaking() { return "sched_waking"; }
Source:
<code>private Object getImmediateFieldValue(BundleActivator activator) { try { Field f = activator.getClass() .getField("IMMEDIATE"); return f.get(activator); } catch (Exception e) <START> return null; <END> }</code><technical_language>I return Boolean.FALSE here</technical_language>

Target:
private Object getImmediateFieldValue(BundleActivator activator) { try { Field f = activator.getClass() .getField("IMMEDIATE"); return f.get(activator); } catch (Exception e) return Boolean.FALSE; }
Source:
<code>public static boolean canShowHistoryFor(final Object object) { if (object instanceof HistoryPageInput) { return true; } if (object instanceof IResource) { return typeOk((IResource) object); } if (object instanceof RepositoryTreeNode) { return <START> SUPPORTED_REPOSITORY_NODE_TYPES.contains(object); <END> } if (object instanceof Path) { return true; } IResource resource = AdapterUtils.adaptToAnyResource(object); if (resource != null && typeOk(resource)) { return true; } return Adapters.adapt(object, Repository.class) != null; }</code><technical_language>((RepositoryTreeNode) object).getType()</technical_language>

Target:
public static boolean canShowHistoryFor(final Object object) { if (object instanceof HistoryPageInput) { return true; } if (object instanceof IResource) { return typeOk((IResource) object); } if (object instanceof RepositoryTreeNode) { return SUPPORTED_REPOSITORY_NODE_TYPES .contains(((RepositoryTreeNode) object).getType()); } if (object instanceof Path) { return true; } IResource resource = AdapterUtils.adaptToAnyResource(object); if (resource != null && typeOk(resource)) { return true; } return Adapters.adapt(object, Repository.class) != null; }
Source:
<code><START> public ResponseEntity<List<Map<String, Object>>> getObservationUnitTableAsJSONArray(@PathVariable final String cropname, END> @PathVariable final Integer studyId, @PathVariable final Integer datasetId, @RequestBody final ObservationUnitsSearchDTO searchDTO) { Preconditions.checkNotNull(searchDTO, "params cannot be null"); Preconditions.checkNotNull(searchDTO.getFilter(), "filter inside params cannot be null"); Preconditions .checkArgument(!Collections.isEmpty(searchDTO.getFilter().getFilterColumns()), "filterColumns cannot be null or empty"); return new ResponseEntity<>(this.studyDatasetService.getObservationUnitRowsAsListMap(studyId, datasetId, searchDTO), HttpStatus.OK); }</code><technical_language>important include in API notes variables (let's factors variates anymore) in filterColumns retrieved in map</technical_language>

Target:
public ResponseEntity<List<Map<String, Object>>> getObservationUnitTableAsJSONArray(@PathVariable final String cropname, @PathVariable final Integer studyId, @PathVariable final Integer datasetId, @RequestBody final ObservationUnitsSearchDTO searchDTO) { Preconditions.checkNotNull(searchDTO, "params cannot be null"); Preconditions.checkNotNull(searchDTO.getFilter(), "filter inside params cannot be null"); Preconditions .checkArgument(!Collections.isEmpty(searchDTO.getFilterColumns()), "filterColumns cannot be null or empty"); return new ResponseEntity<>(this.studyDatasetService.getObservationUnitRowsAsMapList(studyId, datasetId, searchDTO), HttpStatus.OK); }
Source:
<code>private void handleSignInResponse(int resultCode, Intent data) { <START> if (data != null) { <END> IdpResponse response = IdpResponse.fromResultIntent(data); if (resultCode == ResultCodes.OK) { startActivity(SignedInActivity.createIntent(this, response)); finish(); return; } if (response.getErrorCode() == ErrorCodes.NO_NETWORK) { showSnackbar(R.string.no_internet_connection); return; } if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) { showSnackbar(R.string.unknown_error); return; } } if (resultCode == ResultCodes.CANCELED) { showSnackbar(R.string.sign_in_cancelled); return; } showSnackbar(R.string.unknown_sign_in_response); }</code><technical_language>a here: - checking for RESULT_OK a top-level check. contract, nullity of data. - resultCode is CANCELED quick snackbars right? IdpResponse contains UNKNOWN_ERROR canceled</technical_language>

Target:
private void handleSignInResponse(int resultCode, Intent data) { IdpResponse response = IdpResponse.fromResultIntent(data); if (resultCode == ResultCodes.OK) { startActivity(SignedInActivity.createIntent(this, response)); finish(); return; } else { if (response == null) { showSnackbar(R.string.sign_in_cancelled); return; } if (response.getErrorCode() == ErrorCodes.NO_NETWORK) { showSnackbar(R.string.no_internet_connection); return; } if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) { showSnackbar(R.string.unknown_error); return; } } showSnackbar(R.string.unknown_sign_in_response); }
Source:
<code>public boolean updateKFS() { <START> updateAgencies(); <END> updateProposals(); updateAwards(); return false; }</code><technical_language>set a boolean like: boolean successfullyProcessed = updateAgencies(); successfullyProcessed &= updateProposals(); successfullyProcessed &= updateAwards(); return successfullyProcessed;</technical_language>

Target:
public boolean updateKFS() { boolean successfullyUpdated = updateAgencies(); successfullyUpdated &= updateProposals(); successfullyUpdated &= updateAwards(); return successfullyUpdated; }
Source:
<code>public static ColumnChunkMetaData get( ColumnPath path, PrimitiveTypeName type, CompressionCodecName codec, EncodingStats encodingStats, Set<Encoding> encodings, Statistics statistics, long firstDataPage, long dictionaryPageOffset, long valueCount, long totalSize, long totalUncompressedSize) { <START> return get(path, new PrimitiveType(Type.Repetition.OPTIONAL, type, ""), codec, encodingStats, encodings, statistics, <END> firstDataPage, dictionaryPageOffset, valueCount, totalSize, totalUncompressedSize); }</code><technical_language>Types API instead of constructors. constructors public in 2.0 API</technical_language>

Target:
public static ColumnChunkMetaData get( ColumnPath path, PrimitiveTypeName type, CompressionCodecName codec, EncodingStats encodingStats, Set<Encoding> encodings, Statistics statistics, long firstDataPage, long dictionaryPageOffset, long valueCount, long totalSize, long totalUncompressedSize) { return get(path, Types.optional(type).named("fake_type"), codec, encodingStats, encodings, statistics, firstDataPage, dictionaryPageOffset, valueCount, totalSize, totalUncompressedSize); }
Source:
<code>protected void updateExternalVnicProfilesPerTargetCluster() { final Map<Cluster, Set<VnicProfileMappingEntity>> result = new HashMap<>(); <START> getEntities().getItems().stream().forEach( registerVmData -> <END> updateExternalVnicProfilesPerTargetCluster( registerVmData.getEntity().getInterfaces(), registerVmData.getCluster().getSelectedItem(), result)); setExternalVnicProfilesPerTargetCluster(result); }</code><technical_language>need stream() a Collection get forEach</technical_language>

Target:
protected void updateExternalVnicProfilesPerTargetCluster() { final Map<Cluster, Set<VnicProfileMappingEntity>> result = new HashMap<>(); getEntities().getItems().forEach( registerVmData -> updateExternalVnicProfilesPerTargetCluster( registerVmData.getEntity().getInterfaces(), registerVmData.getCluster().getSelectedItem(), result)); setExternalVnicProfilesPerTargetCluster(result); }
Source:
<code><START> static Map<String, String> escape(EnvVars envVars) { <END> Map<String, String> m = new TreeMap<String, String>(); for (Map.Entry<String, String> entry : envVars.entrySet()) { m.put(entry.getKey(), entry.getValue().replace("$", "$$")); } return m; }</code><technical_language>Unnecessary (and incompatible); revert</technical_language>

Target:
protected static Map<String, String> escape(EnvVars envVars) { Map<String, String> m = new TreeMap<String, String>(); for (Map.Entry<String, String> entry : envVars.entrySet()) { m.put(entry.getKey(), entry.getValue().replace("$", "$$")); } return m; }
Source:
<code>public boolean isVerificationSuccessful(String captchaResponse, String secretKey) { <START> if (secretKey == null) { <END> return true; } else if (captchaResponse == null || captchaResponse.isEmpty()) { return false; } try { String response = getApiResponse(captchaResponse, secretKey); JsonObject responseInJson = JsonUtils.parse(response).getAsJsonObject(); if (responseInJson.has("error-codes")) { JsonArray errorCodes = responseInJson.get("error-codes").getAsJsonArray(); log.warning("Error codes during reCAPTCHA verification: " + errorCodes.toString()); } return Boolean.parseBoolean(responseInJson.get("success").toString()); } catch (Exception e) { log.severe(TeammatesException.toStringWithStackTrace(e)); return false; } }</code><technical_language>if secretKey is empty string</technical_language>

Target:
public boolean isVerificationSuccessful(String captchaResponse, String secretKey) { if (secretKey == null || secretKey.isEmpty()) { return true; } if (captchaResponse == null || captchaResponse.isEmpty()) { return false; } try { String response = getApiResponse(captchaResponse, secretKey); JsonObject responseInJson = JsonUtils.parse(response).getAsJsonObject(); if (responseInJson.has("error-codes")) { JsonArray errorCodes = responseInJson.get("error-codes").getAsJsonArray(); log.warning("Error codes during reCAPTCHA verification: " + errorCodes.toString()); } return Boolean.parseBoolean(responseInJson.get("success").toString()); } catch (Exception e) { log.severe(TeammatesException.toStringWithStackTrace(e)); return false; } }
Source:
<code><START> public FirestorePagingOptions<T> build() { <END> return new FirestorePagingOptions<>(mData, mParser, mOwner); }</code><technical_language>Nit: @NonNull</technical_language>

Target:
public FirestorePagingOptions<T> build() { if (mData == null || mParser == null) { throw new IllegalStateException("Must call setQuery() before calling build()."); } if (mDiffCallback == null) { mDiffCallback = new DefaultSnapshotDiffCallback<T>(mParser); } return new FirestorePagingOptions<>(mData, mParser, mDiffCallback, mOwner); }
Source:
<code>private List<LightRuleMatch> parseAggregatedJson(File inputFile) throws IOException { ObjectMapper mapper = new ObjectMapper(); List<LightRuleMatch> ruleMatches = new ArrayList<>(); int lineCount = 1; <START> for (String line : Files.readAllLines(inputFile.toPath())) { <END> try { JsonNode node = mapper.readTree(line); JsonNode matches = node.get("matches"); for (JsonNode match : matches) { ruleMatches.add(nodeToLightMatch(node.get("title").asText(), match)); } lineCount++; } catch (Exception e) { throw new RuntimeException("Failed to parse line " + lineCount + " of " + inputFile, e); } } return ruleMatches; }</code><technical_language>This scanner avoid reading RAM</technical_language>

Target:
private List<LightRuleMatch> parseAggregatedJson(File inputFile) throws IOException { ObjectMapper mapper = new ObjectMapper(); List<LightRuleMatch> ruleMatches = new ArrayList<>(); try (BufferedReader br = Files.newBufferedReader(inputFile.toPath())) { String line; while ((line = br.readLine()) != null) { JsonNode node = mapper.readTree(line); JsonNode matches = node.get("matches"); for (JsonNode match : matches) { ruleMatches.add(nodeToLightMatch(node.get("title").asText(), match)); } } } return ruleMatches; }
Source:
<code>public void appendData(DecodedBlockNode[] decodedBlocks, int fixedWidthRowSize, List<Integer> variableWidthChannels, OutputBuffer outputBuffer) { <START> checkArgument(decodedBlocks.length == channelCount, "Unexpected number of blocks"); <END> if (positionCount == 0) { return; } if (channelCount == 0) { bufferedRowCount += positionCount; return; } initializeBlockEncodingBuffers(decodedBlocks); for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i].setupDecodedBlocksAndPositions(decodedBlocks[i], positions, positionCount); } populateSerializedRowSizes(fixedWidthRowSize, variableWidthChannels); int offset = 0; do { int batchSize = calculateNextBatchSize(fixedWidthRowSize, variableWidthChannels, offset); for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i].setNextBatch(offset, batchSize); blockEncodingBuffers[i].appendDataInBatch(); } bufferedRowCount += batchSize; offset += batchSize; if (bufferFull) { flush(outputBuffer); bufferFull = false; } } while (offset < positionCount); }</code><technical_language>please add actual values error message, in case fails</technical_language>

Target:
private void appendData(DecodedBlockNode[] decodedBlocks, int fixedWidthRowSize, List<Integer> variableWidthChannels, OutputBuffer outputBuffer) { if (decodedBlocks.length != channelCount) { throw new IllegalArgumentException(format("Unexpected number of decoded blocks %d. It should be %d.", decodedBlocks.length, channelCount)); } if (positionCount == 0) { return; } if (channelCount == 0) { bufferedRowCount += positionCount; return; } initializeBlockEncodingBuffers(decodedBlocks); for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i].setupDecodedBlocksAndPositions(decodedBlocks[i], positions, positionCount); } populateSerializedRowSizes(fixedWidthRowSize, variableWidthChannels); int offset = 0; do { int batchSize = calculateNextBatchSize(fixedWidthRowSize, variableWidthChannels, offset); for (int i = 0; i < channelCount; i++) { blockEncodingBuffers[i].setNextBatch(offset, batchSize); blockEncodingBuffers[i].appendDataInBatch(); } bufferedRowCount += batchSize; offset += batchSize; if (bufferFull) { flush(outputBuffer); bufferFull = false; } } while (offset < positionCount); }
Source:
<code>void should_convertToVariableDeletedEvent() { <START> ActivitiVariableEventImpl internalEvent = new ActivitiVariableEventImpl(ActivitiEventType.VARIABLE_CREATED); <END> internalEvent.setVariableName("variableName"); internalEvent.setProcessInstanceId("processInstanceId"); internalEvent.setTaskId("taskId"); VariableType variableType = new BooleanType(); internalEvent.setVariableType(variableType); Object value = mock(Object.class); internalEvent.setVariableValue(value); Optional<VariableDeletedEvent> result = converter.from(internalEvent); assertThat(result).isPresent(); VariableDeletedEvent actualEvent = result.get(); assertThat(actualEvent.getEventType()).isEqualTo(VariableEvents.VARIABLE_DELETED); VariableInstance actualEntity = actualEvent.getEntity(); assertThat(actualEntity.getName()).isEqualTo("variableName"); assertThat(actualEntity.getProcessInstanceId()).isEqualTo("processInstanceId"); assertThat(actualEntity.getTaskId()).isEqualTo("taskId"); assertThat(actualEntity.getType()).isEqualTo("boolean"); Object actualValue = actualEntity.getValue(); assertThat(actualValue).isSameAs(value); }</code><technical_language>I guess this ActivitiEventType.VARIABLE_DELETED</technical_language>

Target:
void should_convertToVariableDeletedEvent() { ActivitiVariableEventImpl internalEvent = new ActivitiVariableEventImpl(ActivitiEventType.VARIABLE_DELETED); internalEvent.setVariableName("variableName"); internalEvent.setProcessInstanceId("processInstanceId"); internalEvent.setTaskId("taskId"); VariableType variableType = new BooleanType(); internalEvent.setVariableType(variableType); Object value = mock(Object.class); internalEvent.setVariableValue(value); Optional<VariableDeletedEvent> result = converter.from(internalEvent); assertThat(result).isPresent(); VariableDeletedEvent actualEvent = result.get(); assertThat(actualEvent.getEventType()).isEqualTo(VariableEvents.VARIABLE_DELETED); VariableInstance actualEntity = actualEvent.getEntity(); assertThat(actualEntity.getName()).isEqualTo("variableName"); assertThat(actualEntity.getProcessInstanceId()).isEqualTo("processInstanceId"); assertThat(actualEntity.getTaskId()).isEqualTo("taskId"); assertThat(actualEntity.getType()).isEqualTo("boolean"); Object actualValue = actualEntity.getValue(); assertThat(actualValue).isSameAs(value); }
Source:
<code>protected void endSuccessfully() { if (getParameters().isShouldTeardown()) { Guid hostForExecution = vdsCommandsHelper.getHostForExecution(getParameters().getStoragePoolId()); if (!executeWithHost(hostForExecution, host -> imagesHandler.teardownImage( getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), host).getSucceeded())) { log.warn("Failed to tear down image '{}/{}'", getParameters().getImageGroupId(), getParameters().getImageId()); } } <START> getReturnValue().setEndActionTryAgain(false); <END> setSucceeded(true); }</code><technical_language>this called in endWithFailure()</technical_language>

Target:
protected void endSuccessfully() { if (getParameters().isShouldTeardown()) { Guid hostForExecution = vdsCommandsHelper.getHostForExecution(getParameters().getStoragePoolId()); if (!executeWithHost(hostForExecution, host -> imagesHandler.teardownImage( getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), host).getSucceeded())) { log.warn("Failed to tear down image '{}/{}'", getParameters().getImageGroupId(), getParameters().getImageId()); getReturnValue().setEndActionTryAgain(false); } } setSucceeded(true); }
Source:
<code>public ValidationResult validateStorageExistForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) { for (Snapshot snap : snapshots) { if (StringUtils.isNotEmpty(snap.getMemoryVolume())) { List<Guid> guids = GuidUtils.getGuidListFromString(snap.getMemoryVolume()); StorageDomain sd = getStorageDomainDao().getForStoragePool(guids.get(0), params.getStoragePoolId()); ValidationResult result = new StorageDomainValidator(sd).isDomainExistAndActive(); if (!result.isValid()) { log.error("Storage Domain '{}', could not be found for <START> disks: '{}','{}' <END> in snapshot '{}'", guids.get(0), guids.get(2), guids.get(4), snap.getDescription()); if (!allowPartial) { return result; } failedDisksToImport.putIfAbsent(guids.get(2), snap.getDescription() + "(memory disk)"); } } } return ValidationResult.VALID; }</code><technical_language>'memory disks' maybe</technical_language>

Target:
public ValidationResult validateStorageExistForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) { for (Snapshot snap : snapshots) { if (StringUtils.isNotEmpty(snap.getMemoryVolume())) { List<Guid> guids = Guid.createGuidListFromString(snap.getMemoryVolume()); StorageDomain sd = getStorageDomainDao().getForStoragePool(guids.get(0), params.getStoragePoolId()); ValidationResult result = new StorageDomainValidator(sd).isDomainExistAndActive(); if (!result.isValid()) { log.error("Storage Domain '{}', could not be found for memory disks: '{}','{}' in snapshot '{}' (id: '{}')", guids.get(0), guids.get(2), guids.get(4), snap.getDescription(), snap.getId()); if (!allowPartial) { return result; } failedDisksToImport.putIfAbsent(guids.get(2), snap.getDescription() + "(memory disk)"); } } } return ValidationResult.VALID; }
Source:
<code>private Dimension getLabelsDimension() { Dimension labelDimension = new Dimension(-1, -1); <START> labelDimension.width = Math.max(labelDimension.width, nameLabel != null ? nameLabel.getPreferredSize().width : -1); <END> labelDimension.width = Math.max(labelDimension.width, taggedLabel != null ? taggedLabel.getPreferredSize().width : -1); labelDimension.width = Math.max(labelDimension.width, stereotypesLabel != null ? stereotypesLabel.getPreferredSize().width : -1); labelDimension.width = Math.max(labelDimension.width, stereotypePropertiesInBraceContent != null ? stereotypePropertiesInBraceContent.getPreferredSize().width : -1); labelDimension.width = Math.max(labelDimension.width, qualifiedLabel != null ? qualifiedLabel.getPreferredSize().width : -1); ResizableCompartmentFigure firstCompartment = FigureUtils.findChildFigureInstance(this, ResizableCompartmentFigure.class); if (firstCompartment != null) { labelDimension.height = firstCompartment.getBounds().y - getBounds().y; } return labelDimension; }</code><technical_language>preferable test 'nameLabel != null' in a condition set if is null -1 is minimum value. This increase performance</technical_language>

Target:
private Dimension getLabelsDimension() { Dimension labelDimension = new Dimension(-1, -1); if (null != nameLabel && labelDimension.width < nameLabel.getPreferredSize().width) { labelDimension.width = nameLabel.getPreferredSize().width; } if (null != taggedLabel && labelDimension.width < taggedLabel.getPreferredSize().width) { labelDimension.width = taggedLabel.getPreferredSize().width; } if (null != stereotypesLabel && labelDimension.width < stereotypesLabel.getPreferredSize().width) { labelDimension.width = stereotypesLabel.getPreferredSize().width; } if (null != stereotypePropertiesInBraceContent && labelDimension.width < stereotypePropertiesInBraceContent.getPreferredSize().width) { labelDimension.width = stereotypePropertiesInBraceContent.getPreferredSize().width; } if (null != qualifiedLabel && labelDimension.width < qualifiedLabel.getPreferredSize().width) { labelDimension.width = qualifiedLabel.getPreferredSize().width; } ResizableCompartmentFigure firstCompartment = FigureUtils.findChildFigureInstance(this, ResizableCompartmentFigure.class); if (null != firstCompartment) { labelDimension.height = firstCompartment.getBounds().y - getBounds().y; } return labelDimension; }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; <START> } else if (!getClass().equals(obj.getClass())) { <END> return false; } PreSharedKeyIdentity other = (PreSharedKeyIdentity) obj; if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } return true; }</code><technical_language>Generally, I eclipse generate this kind of code for me. version of "old" version of eclipse this pattern : java if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Is reason change code this ? (I'm curious I objection change it)</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (getClass() != obj.getClass()) { return false; } PreSharedKeyIdentity other = (PreSharedKeyIdentity) obj; if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } return true; }
Source:
<code>private ChangeDetail submitRest(PatchSet.Id id, IProgressMonitor monitor) throws GerritException { final String uri = "/a/changes/" + id.getParentKey().get() + "/revisions/" + id.get() + "/submit"; try { JsonEntity entity = new JsonEntity() { @Override public String getContent() { SubmitInput reviewInput = new SubmitInput(true); return reviewInput.toJson(); } }; <START> String response = client.execute(client.new JsonRequest(uri, entity) { <END> @Override public void handleError(HttpMethodBase method) throws GerritException { if (method.getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN && "submit not permitted\n".equals(getResponseBodyAsString(method))) { throw new GerritException("Cannot submit change"); } } private String getResponseBodyAsString(HttpMethodBase method) { try { return method.getResponseBodyAsString(); } catch (IOException e) { return null; } } }, monitor); SubmitInfo.fromJson(response); return getChangeDetail(id.get(), monitor); } catch (IOException e) { throw new GerritException(e); } }</code><technical_language>other review, nice simplify abstract serialization concerns</technical_language>

Target:
private ChangeDetail submitRest(PatchSet.Id id, IProgressMonitor monitor) throws GerritException { final String uri = "/a/changes/" + id.getParentKey().get() + "/revisions/" + id.get() + "/submit"; execute(uri, new SubmitInput(true), SubmitInfo.class, new ErrorHandler() { @Override public void handleError(HttpMethodBase method) throws GerritException { if (method.getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN && "submit not permitted\n".equals(getResponseBodyAsString(method))) { throw new GerritException("Cannot submit change"); } } private String getResponseBodyAsString(HttpMethodBase method) { try { return method.getResponseBodyAsString(); } catch (IOException e) { return null; } } }, monitor); return getChangeDetail(id.get(), monitor); }
Source:
<code>public boolean handleMessage(Message message) { if (realm.sharedGroupManager != null) { QueryUpdateTask.Result result; switch (message.what) { <START> case LOCAL_COMMIT: <END> case REALM_CHANGED: realmChanged(); break; case COMPLETED_ASYNC_REALM_RESULTS: result = (QueryUpdateTask.Result) message.obj; completedAsyncRealmResults(result); break; case COMPLETED_ASYNC_REALM_OBJECT: result = (QueryUpdateTask.Result) message.obj; completedAsyncRealmObject(result); break; case COMPLETED_UPDATE_ASYNC_QUERIES: result = (QueryUpdateTask.Result) message.obj; completedAsyncQueriesUpdate(result); break; case REALM_ASYNC_BACKGROUND_EXCEPTION: throw (Error) message.obj; default: throw new IllegalArgumentException("Unknown message: " + message.what); } } return true; }</code><technical_language>private void realmChanged() { deleteWeakReferences(); if (threadContainsAsyncQueries()) { updateAsyncQueries(); } else { RealmLog.d("REALM_CHANGED realm:" + HandlerController.this + " async queries, advance_read"); realm.sharedGroupManager.advanceRead(); notifyAllListeners(); } } if (threadContainsAsyncQueries()) { is covered ... @#$!@#$@!$# This hurts brain !!</technical_language>

Target:
public boolean handleMessage(Message message) { if (realm.sharedGroupManager != null) { QueryUpdateTask.Result result; switch (message.what) { case LOCAL_COMMIT: case REALM_CHANGED: realmChanged(message.what == LOCAL_COMMIT); break; case COMPLETED_ASYNC_REALM_RESULTS: result = (QueryUpdateTask.Result) message.obj; completedAsyncRealmResults(result); break; case COMPLETED_ASYNC_REALM_OBJECT: result = (QueryUpdateTask.Result) message.obj; completedAsyncRealmObject(result); break; case COMPLETED_UPDATE_ASYNC_QUERIES: result = (QueryUpdateTask.Result) message.obj; completedAsyncQueriesUpdate(result); break; case REALM_ASYNC_BACKGROUND_EXCEPTION: throw (Error) message.obj; default: throw new IllegalArgumentException("Unknown message: " + message.what); } } return true; }
Source:
<code>public void testGraphCommandUndoWithRows() { relation.getRow().add(new List()); relation.getRow().get(0).getExpression().add(new LiteralExpression()); ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).setText("value"); makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); assertEquals(1, relation.getRow().get(0).getExpression().size()); <START> assertEquals("value", <END> ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).getText()); }</code><technical_language>extract "value" local variable</technical_language>

Target:
public void testGraphCommandUndoWithRows() { relation.getRow().add(new List()); final LiteralExpression literalExpression = new LiteralExpression(); literalExpression.setText(VALUE); relation.getRow().get(0).getExpression().add(literalExpression); makeCommand(); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); assertEquals(1, relation.getRow().get(0).getExpression().size()); assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0)).getText()); }
Source:
<code>public CompositeByteBuf discardReadComponents() { ensureAccessible(); final int readerIndex = readerIndex(); if (readerIndex == 0) { return this; } int writerIndex = writerIndex(); if (readerIndex == writerIndex && writerIndex == capacity()) { for (int i = 0, size = componentCount; i < size; i++) { components[i].free(); } lastAccessed = null; clearComps(); setIndex(0, 0); adjustMarkers(readerIndex); return this; } int firstComponentId = 0; Component c = null; for (int size = componentCount; <START> firstComponentId < size; firstComponentId ++) { <END> c = components[firstComponentId]; if (c.endOffset > readerIndex) { break; } c.free(); } if (firstComponentId == 0) { return this; } Component la = lastAccessed; if (la != null && la.endOffset < readerIndex) { lastAccessed = null; } removeCompRange(0, firstComponentId); int offset = c.offset; updateComponentOffsets(0); setIndex(readerIndex - offset, writerIndex - offset); adjustMarkers(offset); return this; }</code><technical_language>nit: fit a single line</technical_language>

Target:
public CompositeByteBuf discardReadComponents() { ensureAccessible(); final int readerIndex = readerIndex(); if (readerIndex == 0) { return this; } int writerIndex = writerIndex(); if (readerIndex == writerIndex && writerIndex == capacity()) { for (int i = 0, size = componentCount; i < size; i++) { components[i].free(); } lastAccessed = null; clearComps(); setIndex(0, 0); adjustMarkers(readerIndex); return this; } int firstComponentId = 0; Component c = null; for (int size = componentCount; firstComponentId < size; firstComponentId++) { c = components[firstComponentId]; if (c.endOffset > readerIndex) { break; } c.free(); } if (firstComponentId == 0) { return this; } Component la = lastAccessed; if (la != null && la.endOffset <= readerIndex) { lastAccessed = null; } removeCompRange(0, firstComponentId); int offset = c.offset; updateComponentOffsets(0); setIndex(readerIndex - offset, writerIndex - offset); adjustMarkers(offset); return this; }
Source:
<code>public Properties trackCreateAccountClicked() { try{ <START> VideoEvent vEvent = new VideoEvent(); <END> vEvent.properties.putValue(Keys.NAME, Values.CREATE_ACCOUNT_CLICK); vEvent.setAppNameContext(); tracker.track(Keys.CREATE_ACCOUNT_CLICKED, vEvent.properties); return vEvent.properties; }catch(Exception e){ logger.error(e); } return null; }</code><technical_language>I if this needs changed right now, sort of funny this is a VideoEvent do videos</technical_language>

Target:
public Properties trackCreateAccountClicked() { try{ SegmentAnalyticsEvent aEvent = new SegmentAnalyticsEvent(); aEvent.properties.putValue(Keys.NAME, Values.CREATE_ACCOUNT_CLICK); aEvent.setAppNameContext(); tracker.track(Keys.CREATE_ACCOUNT_CLICKED, aEvent.properties); return aEvent.properties; }catch(Exception e){ logger.error(e); } return null; }
Source:
<code>private void combineFiles() throws Exception { final File parentDirectory = dstfile.getParentFile(); if (parentDirectory == null || parentDirectory.exists()) { truncateDestinationFileIfNecessary(); } else { if (!parentDirectory.mkdirs()) { <START> throw new AmazonClientException("Unable to create directory in the path" + parentDirectory.getAbsolutePath()); <END> } } for (Future<File> f : futureFiles) { File partFile = f.get(); ServiceUtils.appendFile(partFile, dstfile); download.updatePersistableTransfer(++lastFullyMergedPartNumber); try { if (!partFile.delete()) { LOG.warn("The file " + partFile.getAbsolutePath() + " could not be deleted."); } } catch (SecurityException exception) { LOG.warn("SecurityException denied delete access to file " + partFile.getAbsolutePath()); } } }</code><technical_language>Space ": " needed in exception message</technical_language>

Target:
private void combineFiles() throws Exception { if (!ServiceUtils.createParentDirectoryIfNecessary(dstfile)) { truncateDestinationFileIfNecessary(); } for (Future<File> f : futureFiles) { File partFile = f.get(); ServiceUtils.appendFile(partFile, dstfile); download.updatePersistableTransfer(++lastFullyMergedPartNumber); try { if (!partFile.delete()) { LOG.warn("The file " + partFile.getAbsolutePath() + " could not be deleted."); } } catch (SecurityException exception) { LOG.warn("SecurityException denied delete access to file " + partFile.getAbsolutePath()); } } }
Source:
<code>private void validateKeys(final byte[] encryptionKey, final byte[] authenticationKey) throws FunctionalException { <START> if (this.checkEmptyKey(encryptionKey)) { <END> LOGGER.error("The encryption key is empty"); throw new FunctionalException(FunctionalExceptionType.INVALID_KEY, ComponentType.PROTOCOL_DLMS); } if (this.checkEmptyKey(authenticationKey)) { LOGGER.error("The authentication key is empty"); throw new FunctionalException(FunctionalExceptionType.INVALID_KEY, ComponentType.PROTOCOL_DLMS); } if (this.checkLenghtKey(encryptionKey)) { LOGGER.error("The encryption key has an invalid length"); throw new FunctionalException(FunctionalExceptionType.INVALID_KEY_FORMAT, ComponentType.PROTOCOL_DLMS); } if (this.checkLenghtKey(authenticationKey)) { LOGGER.error("The authentication key has an invalid length"); throw new FunctionalException(FunctionalExceptionType.INVALID_KEY_FORMAT, ComponentType.PROTOCOL_DLMS); } }</code><technical_language>consider this: private void validateKeys(final byte[] encryptionKey, final byte[] authenticationKey) throws FunctionalException { if (this.checkEmptyKey(encryptionKey)) { throwFunctionException("The encryption key is empty", FunctionalExceptionType.INVALID_KEY); } if (this.checkEmptyKey(authenticationKey)) { throwFunctionException("The authentication key is empty", FunctionalExceptionType.INVALID_KEY); } if (this.checkLenghtKey(encryptionKey)) { throwFunctionException("The encryption key invalid length", FunctionalExceptionType.INVALID_KEY_FORMAT); } if (this.checkLenghtKey(authenticationKey)) { throwFunctionException("The authentication key invalid length", FunctionalExceptionType.INVALID_KEY_FORMAT); } } private void throwFunctionException(final String msg, final FunctionalExceptionType type) throws FunctionalException { LOGGER.error(msg); throw new FunctionalException(type, ComponentType.PROTOCOL_DLMS); }</technical_language>

Target:
private void validateKeys(final byte[] encryptionKey, final byte[] authenticationKey) throws FunctionalException { if (this.checkEmptyKey(encryptionKey)) { this.throwFunctionalException("The encryption key is empty", FunctionalExceptionType.INVALID_DLMS_KEY_ENCRYPTION); } if (this.checkEmptyKey(authenticationKey)) { this.throwFunctionalException("The authentication key is empty", FunctionalExceptionType.INVALID_DLMS_KEY_ENCRYPTION); } if (this.checkLenghtKey(encryptionKey)) { this.throwFunctionalException("The encryption key has an invalid length", FunctionalExceptionType.INVALID_DLMS_KEY_FORMAT); } if (this.checkLenghtKey(authenticationKey)) { this.throwFunctionalException("The authentication key has an invalid length", FunctionalExceptionType.INVALID_DLMS_KEY_FORMAT); } }
Source:
<code><START> public boolean isHostedEngineDirectLunDisk() { <END> return disk.getDiskStorageType() == DiskStorageType.LUN && StorageConstants.HOSTED_ENGINE_LUN_DISK_ALIAS.equals(disk.getDiskAlias()); }</code><technical_language>this public private? is in validator</technical_language>

Target:
private boolean isHostedEngineDirectLunDisk() { return disk.getDiskStorageType() == DiskStorageType.LUN && StorageConstants.HOSTED_ENGINE_LUN_DISK_ALIAS.equals(disk.getDiskAlias()); }
Source:
<code>public ImmutableSortedMap<String, ImmutableList<SpeciesSummary>> getSpeciesSummaryGroupedByKingdom(int limit) { return popularSpeciesInfos.get().stream() .collect(groupingBy(SpeciesSummary::getKingdom)) .entrySet().stream() .collect(toImmutableSortedMap( <START> new ArbitraryStringComparator("animals", "plants", "fungi", "protists"), <END> entry -> entry.getKey(), entry -> entry.getValue().stream().limit(limit).collect(toImmutableList()))); }</code><technical_language>I sorting of this kind is responsiblity of service. I UIs responsiblity, least, controller</technical_language>

Target:
public ImmutableMap<String, ImmutableList<SpeciesSummary>> getSpeciesSummaryGroupedByKingdom(int limit) { return popularSpeciesInfos.get().stream() .collect(groupingBy(SpeciesSummary::getKingdom)) .entrySet().stream() .collect(toImmutableMap( Map.Entry::getKey, entry -> entry.getValue().stream().limit(limit).collect(toImmutableList()))); }
Source:
<code>public void createControl(Composite parent) { composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Text pageText = new Text(composite, SWT.CENTER); pageText.setBounds(composite.getBounds()); <START> pageText.setText("Operation that stores project WizardPage"); <END> pageText.setVisible(true); }</code><technical_language>I understand this means. Operation store anything</technical_language>

Target:
public void createControl(Composite parent) { composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Text pageText = new Text(composite, SWT.CENTER); pageText.setBounds(composite.getBounds()); pageText.setText("WizardPage with operation that gets a reference to the created project"); pageText.setVisible(true); }
Source:
<code>public Stream<InputSplit> createSplits(InputFormat inputFormat, @Nullable SplitHintSpec splitHintSpec) throws IOException { if (firehoseFactory.isSplittable()) { return ((FiniteFirehoseFactory) firehoseFactory).getSplits(splitHintSpec); } else { <START> throw new UnsupportedOperationException(); <END> } }</code><technical_language>Is supporting unsplittable Firehoses future work</technical_language>

Target:
public Stream<InputSplit> createSplits(InputFormat inputFormat, @Nullable SplitHintSpec splitHintSpec) throws IOException { if (firehoseFactory.isSplittable()) { return firehoseFactory.getSplits(splitHintSpec); } else { throw new UnsupportedOperationException(); } }