auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testDelete() { String content = getExpectedDefString(); when( path.toURI() ).thenReturn( FILE_URI ); org.uberfire.java.nio.file.Path nioPath = Paths.convert( path ); when( ioService.readAllString( nioPath ) ).thenReturn( content ); when( ioService.exists( nioPath ) ).thenReturn( true ); when ( projectService.resolveProject( path ) ).thenReturn( project ); <START> try { <END> when( runtimeManager.getDataSourceDeploymentInfo( getExpectedDef().getUuid() ) ).thenReturn( dataSourceDeploymentInfo ); when( runtimeManager.getDriverDeploymentInfo( getExpectedDef().getUuid() ) ).thenReturn( driverDeploymentInfo ); } catch ( Exception e ) { } editorService.delete( path, COMMENT ); verifyDeleteConditions( ); }</code><technical_language>Do need a try {...} catch( e ) {...} block for when(..)</technical_language>

Target:
public void testDelete() throws Exception { String content = getExpectedDefString(); when( path.toURI() ).thenReturn( FILE_URI ); org.uberfire.java.nio.file.Path nioPath = Paths.convert( path ); when( ioService.readAllString( nioPath ) ).thenReturn( content ); when( ioService.exists( nioPath ) ).thenReturn( true ); when( projectService.resolveProject( path ) ).thenReturn( project ); when( runtimeManager.getDataSourceDeploymentInfo( getExpectedDef().getUuid() ) ).thenReturn( dataSourceDeploymentInfo ); when( runtimeManager.getDriverDeploymentInfo( getExpectedDef().getUuid() ) ).thenReturn( driverDeploymentInfo ); editorService.delete( path, COMMENT ); verifyDeleteConditions(); }
Source:
<code>protected void internalRefresh(Object element) { getContentProvider().runWhenReady(IN_UI_SYNC, new Runnable() { public void run() { getViewer().refresh(); } }); getContentProvider().runWhenReady(IN_UI_SYNC, new Runnable() { public void run() { dependencyData.updateDependencies(getSelection(), EMFCompareRCPPlugin.getDefault() .getMergerRegistry()); internalRedraw(); } }); <START> getContentProvider().runWhenReady(IN_UI_SYNC, new <END> Runnable() { public void run() { refreshTitle(); } }); }</code><technical_language>Stefan, I a solution check disposed state of control in refreshTitle() method instead of change ASYNC SYNC. If control is disposed, refresh need done. do ? private void refreshTitle() { if (!getControl().isDisposed()) { Composite parent = getControl().getParent(); .... } }</technical_language>

Target:
protected void internalRefresh(Object element) { getContentProvider().runWhenReady(IN_UI_SYNC, new Runnable() { public void run() { getViewer().refresh(); } }); getContentProvider().runWhenReady(IN_UI_SYNC, new Runnable() { public void run() { dependencyData.updateDependencies(getSelection(), EMFCompareRCPPlugin.getDefault() .getMergerRegistry()); internalRedraw(); } }); getContentProvider().runWhenReady(IN_UI_ASYNC, new Runnable() { public void run() { if (!getControl().isDisposed()) { refreshTitle(); } } }); }
Source:
<code>public String toString() { <START> return "Erratum [id=" + id + ", title=" + title + ", type=" + type END> + ", severity=" + severity + "]"; }</code><technical_language>please org.ovirt.engine.core.common.utils.ToStringBuilder.toString()</technical_language>

Target:
public String toString() { ToStringBuilder builder = ToStringBuilder.forInstance(this); builder.append("id", id); builder.append("title", title); builder.append("type", type); builder.append("severity", severity); return builder.toString(); }
Source:
<code>public InterpretedPageProjectionOutput(DriverYieldSignal yieldSignal, Page page, SelectedPositions selectedPositions) { this.yieldSignal = requireNonNull(yieldSignal, "yieldSignal is null"); this.blocks = requireNonNull(page, "page is null").getBlocks(); this.selectedPositions = requireNonNull(selectedPositions, "selectedPositions is null"); this.nextIndexOrPosition = selectedPositions.getOffset(); if (selectedPositions.isList()) { this.positions = selectedPositions.getPositions(); } else { this.positions = null; <START> } <END> }</code><technical_language>precompute selectedPositions.getPositions. is unnecessary. code harder follow</technical_language>

Target:
public InterpretedPageProjectionOutput(DriverYieldSignal yieldSignal, Page page, SelectedPositions selectedPositions) { this.yieldSignal = requireNonNull(yieldSignal, "yieldSignal is null"); this.blocks = requireNonNull(page, "page is null").getBlocks(); this.selectedPositions = requireNonNull(selectedPositions, "selectedPositions is null"); this.nextIndexOrPosition = selectedPositions.getOffset(); }
Source:
<code>public void persist_shouldSearchHistoryByChargeId_IgnoringRefundStatusWithStateCreated() { ChargeEntity chargeEntity = new ChargeEntity(); chargeEntity.setId(chargeTestRecord.getChargeId()); <START> RefundEntity refundEntity1 = new RefundEntity(chargeEntity, 100L, null); <END> refundEntity1.setStatus(RefundStatus.CREATED); RefundEntity refundEntity = new RefundEntity(chargeEntity, 100L, null); refundEntity.setStatus(RefundStatus.REFUND_SUBMITTED); refundEntity.setReference("test-refund-entity"); refundDao.persist(refundEntity); List<RefundHistory> refundHistoryList = refundDao.searchHistoryByChargeId(chargeEntity.getId()); assertThat(refundHistoryList.size(), is(1)); RefundHistory refundHistory = refundHistoryList.get(0); assertThat(refundHistory.getId(), is(refundEntity.getId())); assertThat(refundHistory.getExternalId(), is(refundEntity.getExternalId())); assertThat(refundHistory.getAmount(), is(refundEntity.getAmount())); assertThat(refundHistory.getStatus(), is(refundEntity.getStatus())); assertNotNull(refundHistory.getChargeEntity()); assertThat(refundHistory.getChargeEntity().getId(), is(refundEntity.getChargeEntity().getId())); assertThat(refundHistory.getCreatedDate(), is(refundEntity.getCreatedDate())); assertThat(refundHistory.getVersion(), is(refundEntity.getVersion())); assertThat(refundHistory.getReference(), is(refundEntity.getReference())); }</code><technical_language>Again, this actual assert refund stores this</technical_language>

Target:
public void persist_shouldSearchHistoryByChargeId_IgnoringRefundStatusWithStateCreated() { ChargeEntity chargeEntity = new ChargeEntity(); chargeEntity.setId(chargeTestRecord.getChargeId()); RefundEntity refundEntity1 = new RefundEntity(chargeEntity, 100L, userExternalId); refundEntity1.setStatus(RefundStatus.CREATED); RefundEntity refundEntity = new RefundEntity(chargeEntity, 100L, userExternalId); refundEntity.setStatus(RefundStatus.REFUND_SUBMITTED); refundEntity.setReference("test-refund-entity"); refundDao.persist(refundEntity); List<RefundHistory> refundHistoryList = refundDao.searchHistoryByChargeId(chargeEntity.getId()); assertThat(refundHistoryList.size(), is(1)); RefundHistory refundHistory = refundHistoryList.get(0); assertThat(refundHistory.getId(), is(refundEntity.getId())); assertThat(refundHistory.getExternalId(), is(refundEntity.getExternalId())); assertThat(refundHistory.getAmount(), is(refundEntity.getAmount())); assertThat(refundHistory.getStatus(), is(refundEntity.getStatus())); assertNotNull(refundHistory.getChargeEntity()); assertThat(refundHistory.getChargeEntity().getId(), is(refundEntity.getChargeEntity().getId())); assertThat(refundHistory.getCreatedDate(), is(refundEntity.getCreatedDate())); assertThat(refundHistory.getVersion(), is(refundEntity.getVersion())); assertThat(refundHistory.getReference(), is(refundEntity.getReference())); assertThat(userExternalId, is(refundEntity.getUserExternalId())); assertThat(refundHistory.getUserExternalId(), is(refundEntity.getUserExternalId())); }
Source:
<code>public void loadConvertsCodeFieldsWhenControllerIsOnlyCodeFields() throws Exception { this.documentAccessBridge = this.codeFieldImplMocker.getInstance(DocumentAccessBridge.class); doReturn(this.doc).when(this.documentAccessBridge).getDocument(this.patientDocument); List<String> list1 = new LinkedList<>(); list1.add("HP:00000015"); doReturn(list1).when(this.baseProperty1).getValue(); doReturn(list1).when(this.baseProperty2).getValue(); PatientData<List<VocabularyProperty>> result = this.codeFieldImplMocker.getComponentUnderTest().load(this.patient); List<VocabularyProperty> propertyOneList = result.get(PROPERTY_1); List<VocabularyProperty> propertyTwoList = result.get(PROPERTY_2); <START> Assert.assertNotNull(propertyOneList); <END> Assert.assertNotNull(propertyTwoList); }</code><technical_language>check for more null</technical_language>

Target:
public void loadConvertsCodeFieldsWhenControllerIsOnlyCodeFields() throws Exception { this.documentAccessBridge = this.codeFieldImplMocker.getInstance(DocumentAccessBridge.class); doReturn(this.doc).when(this.documentAccessBridge).getDocument(this.patientDocument); List<String> list1 = new LinkedList<>(); list1.add("HP:00000015"); doReturn(list1).when(this.baseProperty1).getValue(); List<String> list2 = new LinkedList<>(); list2.add("HP:00000120"); doReturn(list2).when(this.baseProperty2).getValue(); PatientData<List<VocabularyProperty>> result = this.codeFieldImplMocker.getComponentUnderTest().load(this.patient); List<VocabularyProperty> propertyOneList = result.get(PROPERTY_1); List<VocabularyProperty> propertyTwoList = result.get(PROPERTY_2); Assert.assertNotNull(propertyOneList); Assert.assertNotNull(propertyTwoList); Assert.assertThat(propertyOneList, hasSize(1)); Assert.assertThat(propertyTwoList, hasSize(1)); Assert.assertThat(propertyOneList, contains(hasProperty("id", is("HP:00000015")))); Assert.assertThat(propertyTwoList, contains(hasProperty("id", is("HP:00000120")))); }
Source:
<code>public void addInput(Page page) { verify(probe == null); probe = page; probePosition = 0; joinAddresses = null; <START> joinAddressIndex = 0; <END> }</code><technical_language>1 more correct. AFAIC skip this</technical_language>

Target:
public void addInput(Page page) { verify(probe == null); probe = page; probePosition = 0; joinAddresses = null; }
Source:
<code>Object encodeLiteral(Object literal, Class<?> targetType) { if (literal instanceof Envelope) { return geometryBuilder.toObject((Envelope) literal); } else if (literal instanceof Geometry) { return geometryBuilder.toObject((Geometry) literal); } else if (literal instanceof Date) { if (targetType != null && Date.class.isAssignableFrom(targetType)) { return literal; } return ISO8601_SDF.format((Date)literal); } else if (literal instanceof String) { if (targetType != null && Date.class.isAssignableFrom(targetType)) { try { return ISO8601_SDF.parse((String) literal); } catch (ParseException e) { LOGGER.log(Level.WARNING, "Could not parse String literal as ISO-8601 date", e); } } return literal; } else if (literal instanceof Number) { <START> return literal; <END> } else { return literal.toString(); } }</code><technical_language>I do kinds of Numbers mongodb hold, this trip BigDecimal Byte? of considered numbers</technical_language>

Target:
Object encodeLiteral(Object literal, Class<?> targetType) { if (literal instanceof Envelope) { return geometryBuilder.toObject((Envelope) literal); } else if (literal instanceof Geometry) { return geometryBuilder.toObject((Geometry) literal); } else if (literal instanceof Date) { if (targetType != null && Date.class.isAssignableFrom(targetType)) { return literal; } return ISO8601_SDF.format((Date)literal); } else if (literal instanceof String) { if (targetType != null && Date.class.isAssignableFrom(targetType)) { try { return ISO8601_SDF.parse((String) literal); } catch (ParseException e) { LOGGER.log(Level.WARNING, "Could not parse String literal as ISO-8601 date", e); } } return literal; } else if (literal instanceof Integer || literal instanceof Long || literal instanceof Double) { return literal; } else { return literal.toString(); } }
Source:
<code><START> public void fromXmlWithInvalidElementThrowsExceptionInDevBuild() throws IOException { <END> final String xmlResponse = "<Object Name=\"file1\" InCache=\"false\" Length=\"256\" Offset=\"0\" TheAnswerToEverything=\"42\" />"; XmlOutput.fromXml(xmlResponse, BulkObject.class); }</code><technical_language>this test fail a production build expected exception thrown</technical_language>

Target:
public void fromXmlWithInvalidElementThrowsExceptionInDevBuild() throws IOException { assumeFalse(XmlOutput.isProductionBuild()); final String xmlResponse = "<Object Name=\"file1\" InCache=\"false\" Length=\"256\" Offset=\"0\" TheAnswerToEverything=\"42\" />"; XmlOutput.fromXml(xmlResponse, BulkObject.class); }
Source:
<code>public void accept(String json, Context context) throws RuntimeException { JsonObject body = GSON_PARSER.fromJson(json, JsonObject.class); JsonObject tempJson = body.getAsJsonObject("value"); String currentValue = null; if (tempJson != null) { tempJson = tempJson.getAsJsonObject("fields"); } if (tempJson != null) { tempJson = tempJson.getAsJsonObject("original"); } if (tempJson != null && tempJson.has("stringValue")) { currentValue = tempJson.get("stringValue").getAsString(); } if (currentValue == null) { throw new IllegalArgumentException("Malformed JSON"); } String newValue = currentValue.toUpperCase(); Map<String, String> newFields = new HashMap<>(); newFields.put("original", newValue); String affectedDoc = context.resource().split("/documents/")[1].replace("\"", ""); LOGGER.info(String.format("Replacing value: %s --> %s", currentValue, newValue)); try { FIRESTORE.document(affectedDoc).set(newFields, SetOptions.merge()).get(); } catch (ExecutionException | InterruptedException e) { <START> throw new RuntimeException(e); <END> } }</code><technical_language>nit: I thought settled logging this wrapping in RuntimeException (@lesv FYI)</technical_language>

Target:
public void accept(String json, Context context) { JsonObject body = gson.fromJson(json, JsonObject.class); JsonObject tempJson = body.getAsJsonObject("value"); String currentValue = null; if (tempJson != null) { tempJson = tempJson.getAsJsonObject("fields"); } if (tempJson != null) { tempJson = tempJson.getAsJsonObject("original"); } if (tempJson != null && tempJson.has("stringValue")) { currentValue = tempJson.get("stringValue").getAsString(); } if (currentValue == null) { throw new IllegalArgumentException("Malformed JSON: " + json); } String newValue = currentValue.toUpperCase(Locale.getDefault()); Map<String, String> newFields = new HashMap<>(); newFields.put("original", newValue); String affectedDoc = context.resource().split("/documents/")[1].replace("\"", ""); LOGGER.info(String.format("Replacing value: %s --> %s", currentValue, newValue)); try { FIRESTORE.document(affectedDoc).set(newFields, SetOptions.merge()).get(); } catch (ExecutionException | InterruptedException e) { LOGGER.log(Level.SEVERE, "Error updating Firestore document: " + e.getMessage(), e); } }
Source:
<code>public void copyObjectFail() throws InterruptedException, IOException { MockWebServer server = mockOpenStackServer(); server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404) .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "bar"))); try { SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift"); api.objectApiInRegionForContainer("DFW", "foo") .copy("bar.txt", "bar", "foo.txt"); assertEquals(server.getRequestCount(), 2); assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1"); RecordedRequest copyRequest = server.takeRequest(); assertEquals(copyRequest.getRequestLine(), "PUT /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/foo/bar.txt HTTP/1.1 "); <START> fail(); <END> } finally { server.shutdown(); } }</code><technical_language>Add a message this fail()? Actually, line do expect throw CopyObjectException here</technical_language>

Target:
public void copyObjectFail() throws InterruptedException, IOException { MockWebServer server = mockOpenStackServer(); server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404) .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bogus/foo.txt"))); try { SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift"); api.objectApiInRegionForContainer("DFW", "foo").copy("bar.txt", "bogus", "foo.txt"); } finally { server.shutdown(); } }
Source:
<code>public KafkaEightSimpleConsumerFirehoseFactory( @JsonProperty("brokerList") List<String> brokerList, @JsonProperty("partitionIdList") List<Integer> partitionIdList, @JsonProperty("clientId") String clientId, @JsonProperty("feed") String feed, @JsonProperty("queueBufferLength") Integer queueBufferLength, @JsonProperty("resetOffsetToEarliest") Boolean resetOffsetToEarliest ) { this.brokerList = brokerList; this.partitionIdList = partitionIdList; this.clientId = clientId; this.feed = feed; <START> this.queueBufferLength = queueBufferLength == null ? DEFAULT_QUEUE_BUFFER_LENGTH : queueBufferLength; <END> log.info("queueBufferLength loaded as[%s]", this.queueBufferLength); this.earliest = resetOffsetToEarliest == null ? true : resetOffsetToEarliest.booleanValue(); log.info("Default behavior of cosumer set to earliest? [%s]", this.earliest); }</code><technical_language>I assume 0 is intended a valid here</technical_language>

Target:
public KafkaEightSimpleConsumerFirehoseFactory( @JsonProperty("brokerList") List<String> brokerList, @JsonProperty("partitionIdList") List<Integer> partitionIdList, @JsonProperty("clientId") String clientId, @JsonProperty("feed") String feed, @JsonProperty("queueBufferLength") Integer queueBufferLength, @JsonProperty("resetOffsetToEarliest") Boolean resetOffsetToEarliest ) { this.brokerList = brokerList; Preconditions.checkArgument( brokerList != null && brokerList.size() > 0, "brokerList is null/empty" ); this.partitionIdList = partitionIdList; Preconditions.checkArgument( partitionIdList != null && partitionIdList.size() > 0, "partitionIdList is null/empty" ); this.clientId = clientId; Preconditions.checkArgument( clientId != null && !clientId.isEmpty(), "clientId is null/empty" ); this.feed = feed; Preconditions.checkArgument( feed != null && !feed.isEmpty(), "feed is null/empty" ); this.queueBufferLength = queueBufferLength == null ? DEFAULT_QUEUE_BUFFER_LENGTH : queueBufferLength; Preconditions.checkArgument(queueBufferLength > 0, "queueBufferLength must be positive number"); log.info("queueBufferLength loaded as[%s]", this.queueBufferLength); this.earliest = resetOffsetToEarliest == null ? true : resetOffsetToEarliest.booleanValue(); log.info( "if old offsets are not known, data from partition will be read from [%s] available offset.", this.earliest ? "earliest" : "latest" ); }
Source:
<code>public void sanitizeForSaving() { <START> name = SanitizationHelper.sanitizeForHtml(name); <END> }</code><technical_language>do this. unsanitized name presents problem displaying HTML, storing in DB</technical_language>

Target:
public void sanitizeForSaving() { }
Source:
<code>public CohortMembership getActiveMembership(Patient patient) { <START> return getMemberships().stream().filter(CohortMembership::isActive).filter(m -> m.getPatientId().equals(patient.getPatientId())).findFirst().get(); <END> }</code><technical_language>Is reason calling filter twice</technical_language>

Target:
public CohortMembership getActiveMembership(Patient patient) { return getMemberships().stream().filter(m -> m.isActive() && m.getPatientId().equals(patient.getPatientId())).findFirst().get(); }
Source:
<code>private StreamCollector newRunResponseCollector() { return new StreamCollector() { @Override public void keys( String[] names ) { <START> keys = new ArrayList<>( Arrays.asList( names ) ); <END> } @Override public void record( Value[] fields ) @Override public void statementType( StatementType type ) @Override public void statementStatistics( UpdateStatistics statistics ) @Override public void plan( Plan plan ) @Override public void profile( ProfiledPlan plan ) @Override public void notifications( List<Notification> notifications ) @Override public void done() { if ( keys == null ) { keys = new ArrayList<>(); } } }; }</code><technical_language>need for ArrayList</technical_language>

Target:
private StreamCollector newRunResponseCollector() { return new StreamCollector() { @Override public void keys( String[] names ) { keys = Arrays.asList( names ); } @Override public void record( Value[] fields ) @Override public void statementType( StatementType type ) @Override public void statementStatistics( UpdateStatistics statistics ) @Override public void plan( Plan plan ) @Override public void profile( ProfiledPlan plan ) @Override public void notifications( List<Notification> notifications ) @Override public void done() { if ( keys == null ) { keys = new ArrayList<>(); } } }; }
Source:
<code>private void pruneStore(PersistableNetworkPayloadStore historicalStore, String version) { <START> int preLive = getMapOfLiveData().keySet().size(); <END> getMapOfLiveData().keySet().removeAll(historicalStore.getMap().keySet()); int postLive = getMapOfLiveData().size(); if (preLive > postLive) { log.info("We pruned data from our live data store which are already contained in the historical data store with version {}. " + "The live map had entries before pruning and has entries afterwards.", version, preLive, postLive); } else { log.info("No pruning from historical data store with version was applied", version); } storage.queueUpForSave(store); }</code><technical_language>suggestion int preLive = getMapOfLiveData().size();</technical_language>

Target:
private void pruneStore(PersistableNetworkPayloadStore historicalStore, String version) { int preLive = getMapOfLiveData().size(); getMapOfLiveData().keySet().removeAll(historicalStore.getMap().keySet()); int postLive = getMapOfLiveData().size(); if (preLive > postLive) { log.info("We pruned data from our live data store which are already contained in the historical data store with version {}. " + "The live map had entries before pruning and has entries afterwards.", version, preLive, postLive); } else { log.info("No pruning from historical data store with version was applied", version); } storage.queueUpForSave(store); }
Source:
<code>@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(discoSpi); cfg.setConsistentId(igniteInstanceName); if (disableAutoActivation) cfg.setAutoActivationEnabled(false); cfg.setDataStorageConfiguration( new DataStorageConfiguration().setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(100 * 1024 * 1024) .setInitialSize(100 * 1024 * 1024) ) <START> .setDataRegionConfigurations( <END> new DataRegionConfiguration() .setName("memory") .setPersistenceEnabled(false) .setMaxSize(100 * 1024 * 1024) .setInitialSize(100 * 1024 * 1024) ) .setWalMode(WALMode.LOG_ONLY) ); if (userAttrs != null) cfg.setUserAttributes(userAttrs); if (client) cfg.setClientMode(true); return cfg; }</code><technical_language>this need in this commit, is related BLT</technical_language>

Target:
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setConsistentId(igniteInstanceName); if (disableAutoActivation) cfg.setAutoActivationEnabled(false); cfg.setDataStorageConfiguration( new DataStorageConfiguration().setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(100L * 1024 * 1024) .setInitialSize(100L * 1024 * 1024) ) .setDataRegionConfigurations( new DataRegionConfiguration() .setName("memory") .setPersistenceEnabled(false) .setMaxSize(100L * 1024 * 1024) .setInitialSize(100L * 1024 * 1024) ) .setWalMode(WALMode.LOG_ONLY) ); if (userAttrs != null) cfg.setUserAttributes(userAttrs); if (client) cfg.setClientMode(true); return cfg; }
Source:
<code>static List<String> identifySamplesWithSuspiciousContigs(final List<ReadCountCollection> singleSampleTangentNormalizedReadCounts, final Map<String, Double> contigToMedian) { logger.info("Checking for samples with suspicious contigs..."); <START> return singleSampleTangentNormalizedReadCounts.stream().filter(r -> hasSuspiciousContigs(r, contigToMedian)).map(r -> r.columnNames().get(0)).collect(Collectors.toList()); <END> }</code><technical_language>Slight preference for lambda variable rcc for ReadCountCollection</technical_language>

Target:
static List<String> identifySamplesWithSuspiciousContigs(final List<ReadCountCollection> singleSampleTangentNormalizedReadCounts, final Map<String, Double> contigToMedian) { logger.info("Checking for samples with suspicious contigs..."); return singleSampleTangentNormalizedReadCounts.stream().filter(rcc -> hasSuspiciousContigs(rcc, contigToMedian)).map(rcc -> rcc.columnNames().get(0)).collect(Collectors.toList()); }
Source:
<code>private List<Project.NameKey> getAllParents(final Project.NameKey projectName) { final List<Project.NameKey> parents = new ArrayList<Project.NameKey>(); Project.NameKey p = projectName; while (p != null) { final ProjectState e = projectCache.get(p); <START> if (e == null) { <END> break; } p = getParentName(e.getProject()); if (p != null) { parents.add(p); } } return parents; }</code><technical_language>This loop detect abort potential loops</technical_language>

Target:
private List<Project.NameKey> getAllParents(final Project.NameKey projectName) { final List<Project.NameKey> parents = new ArrayList<Project.NameKey>(); Project.NameKey p = projectName; while (p != null && !parents.contains(p)) { final ProjectState e = projectCache.get(p); if (e == null) { break; } p = getParentName(e.getProject()); if (p != null) { parents.add(p); } } return parents; }
Source:
<code>public void onSuccess(FullJsonResponseHandler.JsonResponse<T> response) { stats.updateSuccess(); stats.responseSize(response.getResponseSize()); try { if (response.getStatusCode() == HttpStatus.OK.code() && response.hasValue()) { callback.success(response.getValue()); } else if (response.getStatusCode() == HttpStatus.SERVICE_UNAVAILABLE.code()) { callback.failed(new ServiceUnavailableException(uri)); } else { Exception cause = response.getException(); if (cause == null) { if (response.getStatusCode() == HttpStatus.OK.code()) { cause = new PrestoException(REMOTE_TASK_ERROR, format("Expected response from %s is empty", uri)); } else { cause = new PrestoException(REMOTE_TASK_ERROR, format("Expected response code from %s to be %s, but was %s: %s%n%s", uri, HttpStatus.OK.code(), response.getStatusCode(), response.getStatusMessage(), response.getResponseBody())); } } else { <START> cause = new PrestoException(REMOTE_TASK_ERROR, format("Unexpected exception raised from %s", uri), cause); <END> } callback.fatal(cause); } } catch (Throwable t) { callback.fatal(t); } }</code><technical_language>this java "Unexpected response %s"</technical_language>

Target:
public void onSuccess(FullJsonResponseHandler.JsonResponse<T> response) { stats.updateSuccess(); stats.responseSize(response.getResponseSize()); try { if (response.getStatusCode() == HttpStatus.OK.code() && response.hasValue()) { callback.success(response.getValue()); } else if (response.getStatusCode() == HttpStatus.SERVICE_UNAVAILABLE.code()) { callback.failed(new ServiceUnavailableException(uri)); } else { Exception cause = response.getException(); if (cause == null) { if (response.getStatusCode() == HttpStatus.OK.code()) { cause = new PrestoException(REMOTE_TASK_ERROR, format("Expected response from %s is empty", uri)); } else { cause = new PrestoException(REMOTE_TASK_ERROR, format("Expected response code from %s to be %s, but was %s: %s%n%s", uri, HttpStatus.OK.code(), response.getStatusCode(), response.getStatusMessage(), response.getResponseBody())); } } else { cause = new PrestoException(REMOTE_TASK_ERROR, format("Unexpected response from %s", uri), cause); } callback.fatal(cause); } } catch (Throwable t) { callback.fatal(t); } }
Source:
<code>protected DigdagClient buildClient(boolean checkServerVersion) throws IOException, SystemExitException { Properties props = loadSystemProperties(); PluginSet plugins = loadSystemPlugins(props); <START> plugins = plugins.withPlugins(new TdDigdagClientConfigurationPlugin()); <END> List<DigdagClientConfigurator> clientConfigurators = plugins.withInjector(injector).getServiceProviders(DigdagClientConfigurator.class); if (endpoint == null) { endpoint = props.getProperty("client.http.endpoint", DEFAULT_ENDPOINT); } DigdagClient client = buildClient(endpoint, env, props, disableCertValidation, httpHeaders, clientConfigurators); if (checkServerVersion && !disableVersionCheck) { Map<String, Object> remoteVersions = client.getVersion(); String remoteVersion = String.valueOf(remoteVersions.getOrDefault("version", "")); if (!version.version().equals(remoteVersion)) { throw systemExit(String.format("" + "Client and server version mismatch: Client: %s, Server: %s.%n" + "Please run following command locally to download a compatible version with the server:%n" + "%n" + " " + programName + " selfupdate %s%n", version, remoteVersion, remoteVersion)); } } return client; }</code><technical_language>#237 solves this. please a</technical_language>

Target:
protected DigdagClient buildClient(boolean checkServerVersion) throws IOException, SystemExitException { Properties props = loadSystemProperties(); PluginSet plugins = loadSystemPlugins(props); List<DigdagClientConfigurator> clientConfigurators = plugins.withInjector(injector).getServiceProviders(DigdagClientConfigurator.class); if (endpoint == null) { endpoint = props.getProperty("client.http.endpoint", DEFAULT_ENDPOINT); } DigdagClient client = buildClient(endpoint, env, props, disableCertValidation, httpHeaders, clientConfigurators); if (checkServerVersion && !disableVersionCheck) { Map<String, Object> remoteVersions = client.getVersion(); String remoteVersion = String.valueOf(remoteVersions.getOrDefault("version", "")); if (!version.version().equals(remoteVersion)) { throw systemExit(String.format("" + "Client and server version mismatch: Client: %s, Server: %s.%n" + "Please run following command locally to download a compatible version with the server:%n" + "%n" + " " + programName + " selfupdate %s%n", version, remoteVersion, remoteVersion)); } } return client; }
Source:
<code>public void testGetTableDescriptorsWithNullAndEmptyList() throws IOException { try (Admin admin = getConnection().getAdmin()) { Exception actualError = null; try { HTableDescriptor[] descriptors = admin.getTableDescriptors(null); assertTrue(descriptors.length > 0); } catch (Exception e) { actualError = e; } assertNotNull(actualError); assertTrue(actualError instanceof NullPointerException); actualError = null; try { HTableDescriptor[] descriptors = admin.getTableDescriptors(ImmutableList.<String>of()); assertTrue(descriptors.length > 0); } catch (Exception e) { actualError = e; } <START> assertNull(actualError); <END> } }</code><technical_language>please remove unnecessary try</technical_language>

Target:
public void testGetTableDescriptorsWithNullAndEmptyList() throws IOException { try (Admin admin = getConnection().getAdmin()) { Exception actualError = null; try { admin.getTableDescriptors(null); } catch (Exception e) { actualError = e; } assertNotNull(actualError); assertTrue(actualError instanceof NullPointerException); assertTrue(admin.getTableDescriptors(ImmutableList.<String>of()).length > 0); } }
Source:
<code>public boolean connect(SocketAddress socketAddress) throws IOException { checkUnconnected(); InetSocketAddress inetSocketAddress = validateAddress(socketAddress); InetAddress normalAddr = inetSocketAddress.getAddress(); int port = inetSocketAddress.getPort(); if (normalAddr.isAnyLocalAddress()) { normalAddr = InetAddress.getLocalHost(); } boolean isBlocking = isBlocking(); boolean finished = false; int newStatus; try { if (isBlocking) { begin(); } finished = IoBridge.connect(fd, normalAddr, port); if (isBlocking) { newStatus = finished ? SOCKET_STATUS_CONNECTED : SOCKET_STATUS_UNCONNECTED; } else { <START> newStatus = SOCKET_STATUS_PENDING; <END> } } catch (IOException e) { if (isEINPROGRESS(e)) { newStatus = SOCKET_STATUS_PENDING; } else { if (isOpen()) { close(); finished = true; newStatus = SOCKET_STATUS_UNCONNECTED; } throw e; } } finally { if (isBlocking) { end(finished); } } if (!isBound) { onBind(true ); } onConnect(inetSocketAddress, newStatus, true ); return finished; }</code><technical_language>question badly phrased, answered paragraph. I wanted if return "true" (indicating a completed connection) for non-blocking connects complete. (i.e posix connect() returns 0). returning false acceptable too, API fully allows it</technical_language>

Target:
public boolean connect(SocketAddress socketAddress) throws IOException { checkUnconnected(); InetSocketAddress inetSocketAddress = validateAddress(socketAddress); InetAddress normalAddr = inetSocketAddress.getAddress(); int port = inetSocketAddress.getPort(); if (normalAddr.isAnyLocalAddress()) { normalAddr = InetAddress.getLocalHost(); } boolean isBlocking = isBlocking(); boolean finished = false; int newStatus; try { if (isBlocking) { begin(); } IoBridge.connect(fd, normalAddr, port); newStatus = isBlocking ? SOCKET_STATUS_CONNECTED : SOCKET_STATUS_PENDING; finished = true; } catch (IOException e) { if (isEINPROGRESS(e)) { newStatus = SOCKET_STATUS_PENDING; } else { if (isOpen()) { close(); finished = true; } throw e; } } finally { if (isBlocking) { end(finished); } } if (!isBound) { onBind(true ); } onConnectStatusChanged(inetSocketAddress, newStatus, true ); return status == SOCKET_STATUS_CONNECTED; }
Source:
<code><START> private void createAdvancedLiveGroup() { <END> if (fliveGroup == null && fIsAdvancedEnabled) { GridLayout layout = new GridLayout(2, false); fliveGroup = new Group(fAdvancedGroup, SWT.NONE); fliveGroup.setLayout(layout); fliveGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); Label liveDelayLabel = new Label(fliveGroup, SWT.NONE); liveDelayLabel.setText(Messages.TraceControl_CreateSessionLiveDelayLabel); fLiveDelayText = new Text(fliveGroup, SWT.NONE); fLiveDelayText.setText(Integer.toString(SessionInfo.DEFAULT_LIVE_DELAY)); fLiveDelayText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { updateEnablement(); } }); getShell().pack(); } }</code><technical_language>protocol file is allowed live streaming. session creation fails. this combination is allowed</technical_language>

Target:
private void createAdvancedLiveGroup() { if (fLiveGroup == null && fIsAdvancedEnabled) { GridLayout layout = new GridLayout(7, true); fLiveGroup = new Group(fAdvancedGroup, SWT.NONE); fLiveGroup.setLayout(layout); GridData layoutData = new GridData(GridData.FILL_BOTH); fLiveGroup.setLayoutData(layoutData); Label liveDelayLabel = new Label(fLiveGroup, SWT.RIGHT); layoutData = new GridData(GridData.FILL_HORIZONTAL); liveDelayLabel.setText(Messages.TraceControl_CreateSessionLiveDelayLabel); liveDelayLabel.setLayoutData(layoutData); fLiveDelayText = new Text(fLiveGroup, SWT.NONE); fLiveDelayText.setText(DEFAULT_TEXT); fLiveDelayText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); fLiveDelayText.setToolTipText(Messages.TraceControl_CreateSessionLiveDelayTooltip); fLiveDelayText.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { e.doit = e.text.matches("[0-9]*") || e.text.matches(DEFAULT_TEXT); updateEnablement(); } }); fLiveDelayText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { updateEnablement(); } }); fLiveDelayText.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { Text focusLostWidget = (Text) e.widget; if (focusLostWidget.getText().isEmpty()) { focusLostWidget.setText(DEFAULT_TEXT); focusLostWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); } } @Override public void focusGained(FocusEvent e) { Text focusGainedWidget = (Text) e.widget; if (focusGainedWidget.getText().equals(DEFAULT_TEXT)) { focusGainedWidget.setText(""); focusGainedWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); } } }); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.grabExcessHorizontalSpace = true; layoutData.horizontalSpan = 6; fLiveDelayText.setLayoutData(layoutData); getShell().pack(); } }
Source:
<code>private String getDomainFromDB(String userId) throws UserStoreException { Connection dbConnection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; String domainName = null; try { <START> dbConnection = getDBConnection(); <END> preparedStatement = dbConnection.prepareStatement(GET_DOMAIN); preparedStatement.setString(1, userId); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { domainName = resultSet.getString(DOMAIN_COLUMN_NAME); } } catch (SQLException ex) { throw new UserStoreException("Error occurred while reading the domain name for user id from database.", ex); } finally { DatabaseUtil.closeAllConnections(dbConnection, resultSet, preparedStatement); } return domainName; }</code><technical_language>try-with-resource</technical_language>

Target:
private String getDomainFromDB(String userId) throws UserStoreException { String domainName = null; try (Connection dbConnection = getDBConnection(); PreparedStatement preparedStatement = dbConnection.prepareStatement(GET_DOMAIN)) { preparedStatement.setString(1, userId); preparedStatement.setInt(2, tenantId); try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { domainName = resultSet.getString(DOMAIN_COLUMN_NAME); } } } catch (SQLException ex) { throw new UserStoreException("Error occurred while reading the domain name for user id from database.", ex); } return domainName; }
Source:
<code>public PasswordManagementWebflowConfigurer(final FlowBuilderServices flowBuilderServices, final FlowDefinitionRegistry loginFlowDefinitionRegistry, final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, final Action initPasswordChangeAction) { super(flowBuilderServices, loginFlowDefinitionRegistry, applicationContext, casProperties); this.initPasswordChangeAction = initPasswordChangeAction; <START> setOrder(WebflowConfigurersOrder.PM); <END> }</code><technical_language>This is a good start, I hardcoding order, expose order property in CAS settings configure wish. Hardcoding order is more handling auto-configuration order in a hardcoded way</technical_language>

Target:
public PasswordManagementWebflowConfigurer(final FlowBuilderServices flowBuilderServices, final FlowDefinitionRegistry loginFlowDefinitionRegistry, final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, final Action initPasswordChangeAction) { super(flowBuilderServices, loginFlowDefinitionRegistry, applicationContext, casProperties); this.initPasswordChangeAction = initPasswordChangeAction; setOrder(casProperties.getAuthn().getPm().getWebflow().getOrder()); }
Source:
<code>public SourceControl convertToEntityAttribute(String dbData) { if (dbData == null || dbData.isEmpty()) { LOG.info("Cannot convert null or empty source control"); return null; <START> } <END> Optional<SourceControl> first = Lists.newArrayList(SourceControl.values()).stream().filter(val -> val.toString().equals(dbData)) .findFirst(); if (first.isPresent()) { return first.get(); } else { LOG.error("could not convert token type: " + dbData); return null; } }</code><technical_language>For line 47/51, this, message is wrong; a token type a SourceControl</technical_language>

Target:
public SourceControl convertToEntityAttribute(String dbData) { if (dbData == null || dbData.isEmpty()) { LOG.info("Cannot convert null or empty source control"); return null; } Optional<SourceControl> first = Lists.newArrayList(SourceControl.values()).stream().filter(val -> val.toString().equals(dbData)) .findFirst(); if (first.isPresent()) { return first.get(); } else { LOG.error("could not convert source control: " + dbData); return null; } }
Source:
<code>private Run partialCopy(Run run) { Run clone = new Run(); clone.setId(run.getId()); clone.setAlias(run.getAlias()); for (RunQC qc : run.getRunQCs()) { try { clone.addQc(partialCopy(qc)); } catch (MalformedRunQcException e) { log.error("Can't track Malformed RunQC", e); } } for (User u : run.getWatchers()) { <START> clone.addWatcher(u); <END> } return clone; }</code><technical_language>Need set clone.health replace this</technical_language>

Target:
private Run partialCopy(Run run) { Run clone = new Run(); clone.setId(run.getId()); clone.setAlias(run.getAlias()); clone.setHealth(run.getHealth()); for (RunQC qc : run.getRunQCs()) { try { clone.addQc(partialCopy(qc)); } catch (MalformedRunQcException e) { log.error("Can't track Malformed RunQC", e); } } for (User u : run.getWatchers()) { clone.addWatcher(u); } return clone; }
Source:
<code>public Canvas addShapeIntoView(final Shape shape) { if (shape.getUUID() == null) { shape.setUUID(UUID.uuid()); } <START> shape.getShapeView().setUUID(shape.getUUID()); <END> getView().add(shape.getShapeView()); return this; }</code><technical_language>a part of shape#setUUID method</technical_language>

Target:
public Canvas addShapeIntoView(final Shape shape) { if (shape.getUUID() == null) { shape.setUUID(UUID.uuid()); } getView().add(shape.getShapeView()); return this; }
Source:
<code>protected void onLoad() { super.onLoad(); <START> com.google.gwtjsonrpc.common.AsyncCallback<PatchSetPublishDetail> load = <END> new ScreenLoadCallback<PatchSetPublishDetail>(this) { @Override protected void preDisplay(final PatchSetPublishDetail result) { send.setEnabled(true); display(result); } @Override protected void postDisplay() { message.setFocus(true); } }; CallbackGroup cbs = new CallbackGroup(); Util.DETAIL_SVC.patchSetPublishDetail(patchSetId, cbs.add(load)); }</code><technical_language>put this in a local variable? inline</technical_language>

Target:
protected void onLoad() { super.onLoad(); CallbackGroup cbs = new CallbackGroup(); Util.DETAIL_SVC.patchSetPublishDetail(patchSetId, cbs.add( (com.google.gwtjsonrpc.common.AsyncCallback<PatchSetPublishDetail>) new ScreenLoadCallback<PatchSetPublishDetail>(this) { @Override protected void preDisplay(final PatchSetPublishDetail result) { send.setEnabled(true); display(result); } @Override protected void postDisplay() { message.setFocus(true); } })); }
Source:
<code>public static String visibilityName(int visibility) { switch (visibility) { case ICPPClassType.v_private: return "private"; case ICPPClassType.v_protected: return "protected"; case ICPPClassType.v_public: return "public"; default: <START> return "illegal access specifier"; <END> } }</code><technical_language>Throwing IllegalArgumentException is more here</technical_language>

Target:
public static String visibilityName(int visibility) { switch (visibility) { case ICPPClassType.v_private: return "private"; case ICPPClassType.v_protected: return "protected"; case ICPPClassType.v_public: return "public"; default: throw new IllegalArgumentException("illegal visibility: " + visibility); } }
Source:
<code>public void run() { packagesIndex = new HashMap<String, PackageHierarchyElement>(); <START> System.out.println("Creating package index."); <END> startIndexing(); System.out.println("Finished package index."); }</code><technical_language>Debug needed</technical_language>

Target:
public void run() { packagesIndex = new HashMap<String, PackageHierarchyElement>(); logger.info("Creating package index."); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { startIndexing(); } }); logger.info("Finished package index."); }
Source:
<code>public void tearDown() throws Exception { if (feedRegistration!=null) BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY, feedRegistration); for (WebAppMonitor monitor : webAppMonitors) { monitor.terminate(); <START> } <END> if (executor != null) executor.shutdownNow(); super.tearDown(); RecordingSshjTool.reset(); }</code><technical_language>include webAppMonitors.clear() for loop. terminate is idempotent (I hope!) necessary</technical_language>

Target:
public void tearDown() throws Exception { try { if (feedRegistration!=null) BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY, feedRegistration); for (WebAppMonitor monitor : webAppMonitors) { monitor.terminate(); } webAppMonitors.clear(); if (executor != null) executor.shutdownNow(); super.tearDown(); } finally { RecordingSshjTool.reset(); } }
Source:
<code>public void nodeUnpublishVolume(NodeUnpublishVolumeRequest request, StreamObserver<NodeUnpublishVolumeResponse> responseObserver) { String umountCommand = String.format("fusermount -u %s", request.getTargetPath()); <START> LOG.info("Executing " + umountCommand); <END> try { executeCommand(umountCommand); responseObserver.onNext(NodeUnpublishVolumeResponse.newBuilder() .build()); responseObserver.onCompleted(); } catch (Exception e) { responseObserver.onError(e); } }</code><technical_language>NIT: LOG.info("Executing {}", umountCommand);</technical_language>

Target:
public void nodeUnpublishVolume(NodeUnpublishVolumeRequest request, StreamObserver<NodeUnpublishVolumeResponse> responseObserver) { String umountCommand = String.format("fusermount -u %s", request.getTargetPath()); LOG.info("Executing {}", umountCommand); try { executeCommand(umountCommand); responseObserver.onNext(NodeUnpublishVolumeResponse.newBuilder() .build()); responseObserver.onCompleted(); } catch (Exception e) { responseObserver.onError(e); } }
Source:
<code>protected Boolean doInBackground(Void... params) { if (mStatusFilter == null){ tmpComments = CommentTable.getCommentsForBlogWithFilter(mLocalBlogId, CommentStatus.UNKNOWN); } else { tmpComments = CommentTable.getCommentsForBlogWithFilter(mLocalBlogId, mStatusFilter); } if (mComments.isSameList(tmpComments)) { return false; } <START> final int maxImageWidth = (int) mContext.getResources().getDimension(R.dimen.reader_comment_embedded_image_max_size); END> WPHtml.ImageGetter imgGetter = new WPHtml.ImageGetter() { @Override public Drawable getDrawable(String source) { try { Bitmap bmp = ImageUtils.getScaledBitmapAtLongestSide(BitmapFactory.decodeStream(new URL(source).openStream()), maxImageWidth); BitmapDrawable drawable = new BitmapDrawable(mContext.getResources(), bmp); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight()); return drawable; } catch(IOException exception) { return null; } } }; for (Comment comment: tmpComments) { comment.getDatePublished(); comment.getUnescapedPostTitle(); comment.getAvatarForDisplay(mAvatarSz); comment.getFormattedTitle(); String content = StringUtils.notNullStr(comment.getCommentText()); Spanned spanned = WPHtml.fromHtml(content, imgGetter, null, mContext, null, maxImageWidth); comment.setUnescapedCommentWithDrawables(spanned); } return true; }</code><technical_language>works for image based emojis, IMO a good solution for other images (especially photos) ![screenshot-2016-04-28_11 01 19 993](<LINK_0></technical_language>

Target:
protected Boolean doInBackground(Void... params) { if (mStatusFilter == null){ tmpComments = CommentTable.getCommentsForBlogWithFilter(mLocalBlogId, CommentStatus.UNKNOWN); } else { tmpComments = CommentTable.getCommentsForBlogWithFilter(mLocalBlogId, mStatusFilter); } if (mComments.isSameList(tmpComments)) { return false; } for (Comment comment: tmpComments) { comment.getDatePublished(); comment.getUnescapedPostTitle(); comment.getAvatarForDisplay(mAvatarSz); comment.getFormattedTitle(); String content = StringUtils.notNullStr(comment.getCommentText()); Spanned spanned = WPHtml.fromHtml(content, null, null, mContext, null, 0); comment.setUnescapedCommentWithDrawables(spanned); } return true; }