auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void shouldFailWithAdditionalInfosWhenReadingDocumentBlobContent() throws IOException { SimpleManagedBlob mock = Mockito.mock(SimpleManagedBlob.class); when(mock.getEncoding()).thenReturn("UTF-8"); when(mock.getKey()).thenReturn("anyKey:anyKey"); when(mock.getProviderId()).thenReturn("anyProvider:anyProvider"); when(mock.getMimeType()).thenReturn("text/html"); when(mock.getStream()).thenThrow(IOException.class); DocumentBlobHolder documentBlobHolder = createDocumentBlob(mock); try { cs.convert("html2text", documentBlobHolder, Collections.emptyMap()); } catch (ConversionException e) { <START> assertTrue(e.getInfos().size() == 3); <END> assertTrue(e.getInfos().get(0).contains("anyProvider:anyProvider")); assertTrue(e.getInfos().get(1).contains("anyKey:anyKey")); assertTrue(e.getInfos().get(2).contains(documentBlobHolder.getDocument().getId())); } }</code><technical_language>assertEquals</technical_language>

Target:
public void shouldFailWithAdditionalInfosWhenReadingDocumentBlobContent() throws IOException { SimpleManagedBlob mock = Mockito.mock(SimpleManagedBlob.class); when(mock.getEncoding()).thenReturn("UTF-8"); when(mock.getKey()).thenReturn("anyKey:anyKey"); when(mock.getProviderId()).thenReturn("anyProvider:anyProvider"); when(mock.getMimeType()).thenReturn("text/html"); when(mock.getStream()).thenThrow(IOException.class); DocumentBlobHolder documentBlobHolder = createDocumentBlob(mock); try { cs.convert("html2text", documentBlobHolder, Collections.emptyMap()); fail("Should have raised a ConversionException"); } catch (ConversionException e) { assertEquals(2, e.getInfos().size()); assertTrue(e.getInfos().get(0).contains("anyProvider:anyProvider")); assertTrue(e.getInfos().get(0).contains("anyKey:anyKey")); assertTrue(e.getInfos().get(1).contains(documentBlobHolder.getDocument().getId())); } }
Source:
<code>public void sortByOrderHint() { <START> List<String> hints = Arrays.asList("0.03539970150419025", "0.9124532896017283", "0.4677879627352788", "0.9306522049331096", "0.8442774484430258", "0.3002734797783949", <END> "0.9053018615787292", "0.5897829295233494", "0.9736635784904704", "0.393321565584442", "0.605741386570728", "0.6644442788442779", "0.8541807248539874", "0.9945130750802729", "0.12979277595041627"); List<String> sortedHints = new ArrayList<>(hints); Collections.sort(sortedHints, Comparator.comparingDouble(Double::valueOf)); withCategories(client(), hints.stream().map(CategoryQueryIntegrationTest::categoryWithHint).collect(Collectors.toList()), categories -> { PagedQueryResult<Category> res = client().executeBlocking(CategoryQuery.of().plusSort(m -> m.orderHint().sort().asc()).withLimit(500)); List<String> queryResultHints = res.getResults().stream().filter(cat -> categories.contains(cat)).map(cat -> cat.getOrderHint()).collect(Collectors.toList()); assertThat(queryResultHints).containsExactly(sortedHints.toArray(new String[sortedHints.size()])); }); }</code><technical_language>Please check code for missing finalmodifiers</technical_language>

Target:
public void sortByOrderHint() { final List<String> hints = Arrays.asList("0.03539970150419025", "0.9124532896017283", "0.4677879627352788", "0.9306522049331096", "0.8442774484430258", "0.3002734797783949", "0.9053018615787292", "0.5897829295233494", "0.9736635784904704", "0.393321565584442", "0.605741386570728", "0.6644442788442779", "0.8541807248539874", "0.9945130750802729", "0.12979277595041627"); List<String> sortedHints = new ArrayList<>(hints); Collections.sort(sortedHints, Comparator.comparingDouble(Double::valueOf)); withCategories(client(), hints.stream().map(CategoryQueryIntegrationTest::categoryWithHint).collect(Collectors.toList()), categories -> { PagedQueryResult<Category> res = client().executeBlocking(CategoryQuery.of().plusSort(m -> m.orderHint().sort().asc()).withLimit(500)); List<String> queryResultHints = res.getResults().stream().filter(cat -> categories.contains(cat)).map(cat -> cat.getOrderHint()).collect(Collectors.toList()); assertThat(queryResultHints).containsExactlyElementsOf(sortedHints); }); }
Source:
<code>public ZooKeeper.States getState() throws KeeperException { <START> return reporter.time(tag, "ensurePath", client::getState); <END> }</code><technical_language>"getState"</technical_language>

Target:
public ZooKeeper.States getState() throws KeeperException { return reporter.time(tag, "getState", client::getState); }
Source:
<code>public void testHistogramConfiguration() throws Exception { HistogramMetric histogramMetric = new HistogramMetric("test", null, new long[] {0, 50, 100, 250}); assertThrowsWithCause(() -> histogramMetric.configure(null), IgniteException.class); assertThrowsWithCause(() -> histogramMetric.configure(""), IgniteException.class); assertThrowsWithCause(() -> histogramMetric.configure("44,43"), IgniteException.class); assertThrowsWithCause(() -> histogramMetric.configure("-1000"), IgniteException.class); assertThrowsWithCause(() -> histogramMetric.configure("1,2,xx"), IgniteException.class); assertThrowsWithCause(() -> histogramMetric.configure("xx"), IgniteException.class); histogramMetric.configure("42,43 ,44, 45"); Object histogramHolder = getFieldValue(histogramMetric, "holder"); <START> long[] bounds = getFieldValue(histogramHolder, "bounds"); <END> assertTrue(Arrays.equals(new long[] {42, 43, 44, 45}, bounds)); }</code><technical_language>Please, add public method returns bounds</technical_language>

Target:
public void testHistogramConfiguration() throws Exception { try (IgniteEx g = startGrid(0)) { MetricsMxBean bean = metricsBean(g); assertThrowsWithCause(() -> bean.configureHistogramMetric(null, BOUNDS), NullPointerException.class); assertThrowsWithCause( () -> bean.configureHistogramMetric(metricName(TX_METRICS, METRIC_SYSTEM_TIME_HISTOGRAM), null), NullPointerException.class); assertThrowsWithCause( () -> bean.configureHistogramMetric(metricName(TX_METRICS, METRIC_SYSTEM_TIME_HISTOGRAM), new long[0]), IllegalArgumentException.class); bean.configureHistogramMetric(metricName(TX_METRICS, METRIC_SYSTEM_TIME_HISTOGRAM), BOUNDS); HistogramMetric systemTime = g.context().metric().registry(TX_METRICS) .findMetric(METRIC_SYSTEM_TIME_HISTOGRAM); assertArrayEquals(BOUNDS, systemTime.bounds()); } }
Source:
<code>public Iterable<EventData> receive(int batchSize) { long start = System.currentTimeMillis(); Iterable<EventData> receivedEvents = null; try { receivedEvents = receiver.receiveSync(batchSize); if (receivedEvents != null) { logger.debug("Batchsize: " + batchSize + ", Received event count: " + Iterables.size(receivedEvents)); } } catch (EventHubException e) { logger.error("Exception occured during receive" + e.toString()); return null; } long end = System.currentTimeMillis(); long millis = (end - start); receiveApiLatencyMean.update(millis); receiveApiCallCount.incr(); <START> return receivedEvents; <END> }</code><technical_language>I safer if empty list instead of null receiving</technical_language>

Target:
public Iterable<EventData> receive(int batchSize) { final long start = System.currentTimeMillis(); final Iterable<EventData> receivedEvents; try { receivedEvents = receiver.receiveSync(batchSize); if (receivedEvents != null) { final long end = System.currentTimeMillis(); final long millis = (end - start); receiveApiLatencyMean.update(millis); receiveApiCallCount.incr(); logger.debug("Batchsize: " + batchSize + ", Received event count: " + Iterables.size(receivedEvents)); } } catch (EventHubException e) { logger.error("Exception occured during receive: " + e.toString()); return null; } return receivedEvents == null ? this.emptyEventBatch : receivedEvents; }
Source:
<code>public RangeResourceEntry(Long begin, Long end) { <START> this.reservationType = reservationType; <END> this.begin = begin; this.end = end; }</code><technical_language>dd (this line is unnecessary)</technical_language>

Target:
public RangeResourceEntry(Long begin, Long end) { this.begin = begin; this.end = end; }
Source:
<code>public void shouldGetColumnInformation() { assertEquals(2, table.getColumnCount()); long columnKey = table.getColumnKey("lastName"); <START> assertNotSame(-1, columnKey); <END> assertEquals(RealmFieldType.STRING, table.getColumnType(columnKey)); }</code><technical_language>1 feels a bit magic...Table.NO_MATCH</technical_language>

Target:
public void shouldGetColumnInformation() { assertEquals(2, table.getColumnCount()); long columnKey = table.getColumnKey("lastName"); assertNotSame(Table.NO_MATCH, columnKey); assertEquals(RealmFieldType.STRING, table.getColumnType(columnKey)); }
Source:
<code>public boolean equals(Object obj) <START> { <END> if (!(obj instanceof DependencyEvent)) { return false; } DependencyEvent other = (DependencyEvent) obj; return Objects.equals(fTrace, other.fTrace) && Objects.equals(fTimestamp, other.fTimestamp); }</code><technical_language>reference equality</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DependencyEvent)) { return false; } DependencyEvent other = (DependencyEvent) obj; return Objects.equals(fTrace, other.fTrace) && Objects.equals(fTimestamp, other.fTimestamp); }
Source:
<code>private void setHtmlTextOrHide(String value, TextView tv) { <START> if (value != null) { <END> tv.setText(Html.fromHtml(value)); } else { tv.setVisibility(View.GONE); } }</code><technical_language>Is comparison null good enough check for empty strings</technical_language>

Target:
private void setHtmlTextOrHide(String value, TextView tv) { if (!TextUtils.isEmpty(value)) { tv.setText(Html.fromHtml(value)); } else { tv.setVisibility(View.GONE); } }
Source:
<code>protected void executeQueryCommand() { List<GlusterVolumeEntity> eligibleVolumeList = new ArrayList<GlusterVolumeEntity>(); Guid masterVolumeId = getParameters().getVolumeId(); <START> DbFacade dbFacadeInstance = getDbFacade(); <END> List<VDSGroup> vdsGroups = dbFacadeInstance.getVdsGroupDao().getAll(); for (VDSGroup vdsGroup : vdsGroups) { if (vdsGroup.getId() != getGlusterVolumeDao().getById(masterVolumeId).getClusterId()) { List<GlusterVolumeEntity> volumes = getGlusterVolumeDao().getByClusterId(vdsGroup.getId()); for (GlusterVolumeEntity volume : volumes) { if (volume.getId() != masterVolumeId && volume.getStatus() == GlusterStatus.UP) { eligibleVolumeList.add(volume); } } } } getQueryReturnValue().setReturnValue(eligibleVolumeList); }</code><technical_language>do need declare this variable? getDbFacade().getVdsGroupDao</technical_language>

Target:
protected void executeQueryCommand() { List<GlusterVolumeEntity> eligibleVolumeList = new ArrayList<GlusterVolumeEntity>(); Guid masterVolumeId = getParameters().getVolumeId(); GlusterVolumeEntity masterVolume = getGlusterVolumeDao().getById(masterVolumeId); List<VDSGroup> vdsGroups = getDbFacade().getVdsGroupDao().getAll(); for (VDSGroup vdsGroup : vdsGroups) { if (vdsGroup.getId() != masterVolume.getClusterId() && vdsGroup.getcompatibility_version().equals(getDbFacade().getVdsGroupDao().get(masterVolume.getClusterId()).getcompatibility_version()) && vdsGroup.supportsGlusterService()) { List<GlusterVolumeEntity> volumes = getGlusterVolumeDao().getByClusterId(vdsGroup.getId()); for (GlusterVolumeEntity volume : volumes) { if (volume.getStatus() == GlusterStatus.UP && volume.getAdvancedDetails().getCapacityInfo().getUsedSize().equals(0L) && volume.getAdvancedDetails().getCapacityInfo().getFreeSize() >= masterVolume.getAdvancedDetails().getCapacityInfo().getUsedSize()) { eligibleVolumeList.add(volume); } } } } getQueryReturnValue().setReturnValue(eligibleVolumeList); }
Source:
<code>public HelpLink getHelpLink() { return new HelpLink( <START> "Reading statistical data using haven", <END> "import_haven", false, true); }</code><technical_language>sort of iffy calling this 'statistical data' (since implies data read haven is statistical). like: Reading data haven Reading foreign datasets haven otherwise</technical_language>

Target:
public HelpLink getHelpLink() { return new HelpLink( "Reading data using haven", "import_haven", false, true); }
Source:
<code>private static void setUpKeyStores() throws Exception { File workingDir = new File(WORKING_DIRECTORY_LOCATION); if (workingDir.exists() == false) { workingDir.mkdirs(); } SelfSignedX509CertificateAndSigningKey issuerSelfSignedX509CertificateAndSigningKey = createIssuer(); <START> File trustFile = new File(workingDir, "ca.truststore"); <END> KeyStore trustStore = createTrustStore(issuerSelfSignedX509CertificateAndSigningKey); File fireflyFile = new File(workingDir, "firefly.keystore"); KeyStore fireflyKeyStore = createFireflyKeyStore(issuerSelfSignedX509CertificateAndSigningKey); File localhostFile = new File(workingDir, "localhost.keystore"); KeyStore localhostKeyStore = createLocalhostKeyStore(issuerSelfSignedX509CertificateAndSigningKey); createTemporaryKeyStoreFile(trustStore, trustFile); createTemporaryKeyStoreFile(fireflyKeyStore, fireflyFile); createTemporaryKeyStoreFile(localhostKeyStore, localhostFile); File crlFile = new File(workingDir, "crl.pem"); X509CRLHolder crlHolder = createCRL(); createTemporaryCRLFile(crlHolder, crlFile); }</code><technical_language>File declarations. Static variables referenced in this method in deleteKeyStoreFiles()</technical_language>

Target:
private static void setUpKeyStores() throws Exception { File workingDir = new File(WORKING_DIRECTORY_LOCATION); if (workingDir.exists() == false) { workingDir.mkdirs(); } SelfSignedX509CertificateAndSigningKey issuerSelfSignedX509CertificateAndSigningKey = createIssuer(); KeyStore trustStore = createTrustStore(issuerSelfSignedX509CertificateAndSigningKey); KeyStore fireflyKeyStore = createFireflyKeyStore(issuerSelfSignedX509CertificateAndSigningKey); KeyStore localhostKeyStore = createLocalhostKeyStore(issuerSelfSignedX509CertificateAndSigningKey); createTemporaryKeyStoreFile(trustStore, TRUST_FILE); createTemporaryKeyStoreFile(fireflyKeyStore, FIREFLY_FILE); createTemporaryKeyStoreFile(localhostKeyStore, LOCALHOST_FILE); X509CRLHolder crlHolder = createCRL(); createTemporaryCRLFile(crlHolder, CRL_FILE); }
Source:
<code>public void shouldGetChangeInfo() throws Exception { StashPatchset patchset = new StashPatchset("a", "b", "c"); String url = StashConnector.createUrl(patchset, StashConnector.CHANGES_URL_FORMAT); stubFor(get(urlEqualTo(StashConnector.createUrl(patchset, StashConnector.CHANGES_URL_FORMAT))) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody(IOUtils.toString(getClass().getResourceAsStream("/stash-changes.json"))))); List<ReviewFile> files = fixture.listFiles(patchset); <START> assertEquals(3, files.size()); <END> verify(getRequestedFor(urlMatching(url))); }</code><technical_language>assertJ please</technical_language>

Target:
public void shouldGetChangeInfo() throws Exception { StashPatchset patchset = new StashPatchset("a", "b", "c"); String url = StashConnector.createUrl(patchset, StashConnector.CHANGES_URL_FORMAT); stubFor(get(urlEqualTo(StashConnector.createUrl(patchset, StashConnector.CHANGES_URL_FORMAT))) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody(IOUtils.toString(getClass().getResourceAsStream("/stash-changes.json"))))); List<ReviewFile> files = fixture.listFiles(patchset); assertThat(files).hasSize(3); verify(getRequestedFor(urlMatching(url))); }
Source:
<code>public void bookRoom(int roomNumber) throws Exception { Optional<Room> room = hotelDao.getById(roomNumber); if (room.isEmpty()) { throw new Exception("Room number: " + roomNumber + " does not exist"); } else { if (room.get().isBooked()) { throw new Exception("Room already booked!"); } else { <START> Room updateRoomBooking = room.get(); <END> updateRoomBooking.setBooked(true); hotelDao.update(updateRoomBooking); } } }</code><technical_language>Please Java's local variable type-inference var</technical_language>

Target:
public void bookRoom(int roomNumber) throws Exception { var room = hotelDao.getById(roomNumber); if (room.isEmpty()) { throw new Exception("Room number: " + roomNumber + " does not exist"); } else { if (room.get().isBooked()) { throw new Exception("Room already booked!"); } else { var updateRoomBooking = room.get(); updateRoomBooking.setBooked(true); hotelDao.update(updateRoomBooking); } } }
Source:
<code>@Test public void annotationsConflict() throws Exception { try { new Moshi.Builder().add(new AnnotationsConflictJsonAdapter()); fail(); } catch (IllegalArgumentException expected) { <START> assertThat(expected.getMessage()).contains("Conflicting @ToJson methods"); <END> } }</code><technical_language>I hasMessageStartingWith. AssertJ is crazy..</technical_language>

Target:
@Test public void annotationsConflict() throws Exception { try { new Moshi.Builder().add(new AnnotationsConflictJsonAdapter()); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessageContaining("Conflicting @ToJson methods"); } }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } IndexInfo other = (IndexInfo) obj; if (dropDuplicates != other.dropDuplicates) { return false; } if (indexFields == null) { if (other.indexFields != null) { return false; } } else if (!indexFields.equals(other.indexFields)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (sparse != other.sparse) { return false; } if (unique != other.unique) { return false; } <START> if (language == null) { <END> if (other.language != null) { return false; } } else if (!language.equals(other.language)) { return false; } return true; }</code><technical_language>ObjectUtils.nullSafeEquals(..) here</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } IndexInfo other = (IndexInfo) obj; if (dropDuplicates != other.dropDuplicates) { return false; } if (indexFields == null) { if (other.indexFields != null) { return false; } } else if (!indexFields.equals(other.indexFields)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (sparse != other.sparse) { return false; } if (unique != other.unique) { return false; } if (!ObjectUtils.nullSafeEquals(language, other.language)) { return false; } return true; }
Source:
<code>public void go(AcceptsOneWidget container) { ProjectConfigDto projectConfig = appContext.getCurrentProject().getProjectConfig(); <START> isPlainJava = "javac".equals(projectConfig.getType()); <END> setReadOnlyMod(); container.setWidget(view); if (!categories.isEmpty()) { view.renderNodes(); return; } classpathContainer.getClasspathEntries(projectConfig.getPath()).then(new Operation<List<ClasspathEntryDto>>() { @Override public void apply(List<ClasspathEntryDto> entries) throws OperationException { categories.clear(); for (ClasspathEntryDto entry : entries) { if (SOURCE == entry.getEntryKind()) { categories.put(entry.getPath(), entry); } } view.setData(categories); view.renderNodes(); } }); }</code><technical_language>contants PlainJavaProjectConstants</technical_language>

Target:
public void go(AcceptsOneWidget container) { ProjectConfigDto projectConfig = appContext.getCurrentProject().getProjectConfig(); isPlainJava = JAVAC.equals(projectConfig.getType()); setReadOnlyMod(); container.setWidget(view); if (!categories.isEmpty()) { view.renderNodes(); return; } classpathContainer.getClasspathEntries(projectConfig.getPath()).then(new Operation<List<ClasspathEntryDto>>() { @Override public void apply(List<ClasspathEntryDto> entries) throws OperationException { categories.clear(); for (ClasspathEntryDto entry : entries) { if (SOURCE == entry.getEntryKind()) { categories.put(entry.getPath(), entry); } } view.setData(categories); view.renderNodes(); } }); }
Source:
<code>private LazyResult queryFlat(int columnCount, ResultTarget result, long limitRows) { if (limitRows > 0 && offsetExpr != null) { int offset = offsetExpr.getValue(session).getInt(); if (offset > 0) { limitRows += offset; } } ArrayList<Row> forUpdateRows = null; if (isForUpdateMvcc) { forUpdateRows = Utils.newSmallArrayList(); } int sampleSize = getSampleSizeValue(session); LazyResultQueryFlat lazyResult = new LazyResultQueryFlat(expressionArray, sampleSize, columnCount); if (result == null) { return lazyResult; } while (lazyResult.next()) { if (isForUpdateMvcc) { topTableFilter.lockRowAdd(forUpdateRows); } result.addRow(lazyResult.currentRow()); if ((sort == null || sortUsingIndex) && limitRows > 0 && result.getRowCount() >= limitRows) { break; } } if (isForUpdateMvcc) { <START> assert forUpdateRows != null; <END> topTableFilter.lockRows(forUpdateRows); } return null; }</code><technical_language>is a similar conditional code ten lines a while loop. detects suspicious here? point of view problems specific Javac, JDT, code inspection in IDEA other tools do lead generation of incorrect code avoided in way. IDE show incorrect warning, next version of IDE show different, another IDE show vision on. actual problem in isForUpdateMvcc copied a local variable avoid potential modification execution of this method. tools smart enough link condition based variable another variable</technical_language>

Target:
private LazyResult queryFlat(int columnCount, ResultTarget result, long limitRows) { if (limitRows > 0 && offsetExpr != null) { int offset = offsetExpr.getValue(session).getInt(); if (offset > 0) { limitRows += offset; } } ArrayList<Row> forUpdateRows = null; boolean lockRows = this.isForUpdateMvcc; if (lockRows) { forUpdateRows = Utils.newSmallArrayList(); } int sampleSize = getSampleSizeValue(session); LazyResultQueryFlat lazyResult = new LazyResultQueryFlat(expressionArray, sampleSize, columnCount); if (result == null) { return lazyResult; } while (lazyResult.next()) { if (lockRows) { topTableFilter.lockRowAdd(forUpdateRows); } result.addRow(lazyResult.currentRow()); if ((sort == null || sortUsingIndex) && limitRows > 0 && result.getRowCount() >= limitRows) { break; } } if (lockRows) { topTableFilter.lockRows(forUpdateRows); } return null; }
Source:
<code>public void nullable_matcher() throws Exception { mock.oneArg((Character) null); <START> mock.oneArg((Character) ' '); <END> verify(mock, times(2)).oneArg(nullable(Character.class)); }</code><technical_language>statement work, need modify source here. If is wrong file encoding git clone other editor changed encoding. clone : $ file src/test/java/org/mockitousage/matchers/MatchersTest.java src/test/java/org/mockitousage/matchers/MatchersTest.java: UTF-8 Unicode c program text</technical_language>

Target:
public void nullable_matcher() throws Exception { mock.oneArg((Character) null); mock.oneArg(Character.valueOf('€')); verify(mock, times(2)).oneArg(nullable(Character.class)); }
Source:
<code>public Member getMemberByExtSourceNameAndExtLogin(PerunSession sess, Vo vo, String extSourceName, String extLogin) throws ExtSourceNotExistsException, UserExtSourceNotExistsException, MemberNotExistsException, UserNotExistsException, InternalErrorException, VoNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); Utils.notNull(extSourceName, "extSourceName"); Utils.notNull(extLogin, "extLogin"); getPerunBl().getVosManagerBl().checkVoExists(sess, vo); <START> if(!AuthzResolver.isAuthorized(sess, Role.VOADMIN)) { <END> throw new PrivilegeException(sess, "getMemberByExtSourceNameAndExtLogin"); } return getMembersManagerBl().getMemberByExtSourceNameAndExtLogin(sess, vo, extSourceName, extLogin); }</code><technical_language>I guess VOOBSERVER role allowed too. code ok</technical_language>

Target:
public Member getMemberByExtSourceNameAndExtLogin(PerunSession sess, Vo vo, String extSourceName, String extLogin) throws ExtSourceNotExistsException, UserExtSourceNotExistsException, MemberNotExistsException, UserNotExistsException, InternalErrorException, VoNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); Utils.notNull(extSourceName, "extSourceName"); Utils.notNull(extLogin, "extLogin"); getPerunBl().getVosManagerBl().checkVoExists(sess, vo); if(!AuthzResolver.isAuthorized(sess, Role.VOADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, vo)) { throw new PrivilegeException(sess, "getMemberByExtSourceNameAndExtLogin"); } return getMembersManagerBl().getMemberByExtSourceNameAndExtLogin(sess, vo, extSourceName, extLogin); }
Source:
<code>public synchronized void checkQueueIntegrity() throws IOException { readHeaderWithoutFileSideEffects(); int position = first.position; int totalSize = HEADER_LENGTH; for (int i = 0; i < elementCount; i++) { if (i == elementCount - 1 && position != last.position) { throw new IOException("Corrupted Element lengths in queue resulted in mis-alignment."); } Element current = readElement(position); totalSize += current.length + Element.HEADER_LENGTH; if (current.length > (fileLength - HEADER_LENGTH)) { <START> throw new IOException("Corrupted Element length larger than file."); <END> } position = wrapPosition(current.position + Element.HEADER_LENGTH + current.length); } if (totalSize > fileLength) { throw new IOException("Element scan reports size larger than file."); } }</code><technical_language>Add totalSize, current.length fileLength message</technical_language>

Target:
public synchronized void checkQueueIntegrity() throws IOException { readHeaderWithoutMovingFilePointer(); int position = first.position; int totalSize = HEADER_LENGTH; for (int i = 0; i < elementCount; i++) { if (i == elementCount - 1 && position != last.position) { throw new IOException("Queue corruption: last (" + i + ") Element has actual position of " + position + " in file, but Queue header reports it should have " + last.position + "."); } Element current = readElement(position); totalSize += current.length + Element.HEADER_LENGTH; if (current.length > (fileLength - HEADER_LENGTH)) { throw new IOException("Queue corruption: Element " + i + " has length: " + current.length + " with cumulative element length of: " + totalSize + " in a file of " + "length: " + fileLength + "."); } position = wrapPosition(current.position + Element.HEADER_LENGTH + current.length); } if (totalSize > fileLength) { throw new IOException("Queue corruption: Total element reported size is: " + totalSize + " in a file of size: " + fileLength + '.'); } }
Source:
<code>public FetchHints build() { if (!isIncludeProperties() && isIncludePropertyMetadata()) { includeAllProperties = true; } <START> if (!includeEdgeIds && !includeEdgeVertexIds) { <END> throw new VertexiumException("Cannot exclude both includeEdgeIds and includeEdgeVertexIds. Instead exclude edge refs."); } return new FetchHints( includeAllProperties, propertyNamesToInclude == null ? null : ImmutableSet.copyOf(propertyNamesToInclude), includeAllPropertyMetadata, metadataKeysToInclude == null ? null : ImmutableSet.copyOf(metadataKeysToInclude), includeHidden, includeAllEdgeRefs, includeOutEdgeRefs || includeAllEdgeRefs, includeInEdgeRefs || includeAllEdgeRefs, includeEdgeIds, includeEdgeVertexIds, edgeLabelsOfEdgeRefsToInclude == null ? null : ImmutableSet.copyOf(edgeLabelsOfEdgeRefsToInclude), includeEdgeLabelsAndCounts, includeExtendedDataTableNames, ignoreAdditionalVisibilities, includePreviousMetadata ); }</code><technical_language>Technically error if excluded edge refs</technical_language>

Target:
public FetchHints build() { if (!isIncludeProperties() && isIncludePropertyMetadata()) { includeAllProperties = true; } if ((includeAllEdgeRefs || includeOutEdgeRefs || includeInEdgeRefs) && !includeEdgeIds && !includeEdgeVertexIds) { throw new VertexiumException("Cannot exclude both includeEdgeIds and includeEdgeVertexIds. Instead exclude edge refs."); } return new FetchHints( includeAllProperties, propertyNamesToInclude == null ? null : ImmutableSet.copyOf(propertyNamesToInclude), includeAllPropertyMetadata, metadataKeysToInclude == null ? null : ImmutableSet.copyOf(metadataKeysToInclude), includeHidden, includeAllEdgeRefs, includeOutEdgeRefs || includeAllEdgeRefs, includeInEdgeRefs || includeAllEdgeRefs, includeEdgeIds, includeEdgeVertexIds, edgeLabelsOfEdgeRefsToInclude == null ? null : ImmutableSet.copyOf(edgeLabelsOfEdgeRefsToInclude), includeEdgeLabelsAndCounts, includeExtendedDataTableNames, ignoreAdditionalVisibilities, includePreviousMetadata ); }
Source:
<code>public Publisher<?> readFrom(Class<Publisher<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { ProvidersImpl providersImpl = (ProvidersImpl) (providers instanceof ThreadLocalProviders ? ((ThreadLocalProviders)providers).get() : providers); Message message = providersImpl.getMessage(); <START> ExecutorService executor = Utils.getExecutorService(message); <END> SsePublisher publisher = new SsePublisher(entityStream, executor, providersImpl); if (genericType instanceof ParameterizedType) { Type typeArgument = ((ParameterizedType)genericType).getActualTypeArguments()[0]; if (typeArgument.equals(InboundSseEvent.class)) { return publisher; } return new SseTypeSafeProcessor<Object>(new GenericType<Object>(typeArgument), publisher); } return null; }</code><technical_language>messageContext check correct executor :-)</technical_language>

Target:
public Publisher<?> readFrom(Class<Publisher<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { ProvidersImpl providersImpl = (ProvidersImpl) (providers instanceof ThreadLocalProviders ? ((ThreadLocalProviders)providers).get() : providers); ExecutorService executor = Utils.getExecutorService(mc); SsePublisher publisher = new SsePublisher(entityStream, executor, providersImpl); if (genericType instanceof ParameterizedType) { Type typeArgument = ((ParameterizedType)genericType).getActualTypeArguments()[0]; if (typeArgument.equals(InboundSseEvent.class)) { return publisher; } return new SseTypeSafeProcessor<Object>(new GenericType<Object>(typeArgument), publisher); } return null; }
Source:
<code>public void stop() throws Exception { <START> if (getStopped()) { <END> return; } setStopped(true); cancel(); }</code><technical_language>correct thread safe code this: if (stopped.compareAndSet(false, true)) { cancel(); }</technical_language>

Target:
public void stop() throws Exception { if (stopped.compareAndSet(false, true)) { cancel(); } }
Source:
<code>public String getConfigurationValue(String miimonValue){ String extraOption = ""; if (value.equals(BondMode.BOND4.value)) { extraOption = " xmit_hash_policy=2"; } return MODE + value + " miimon=" + <START> "100" + <END> extraOption; }</code><technical_language>miimonValue, I suppose</technical_language>

Target:
public String getConfigurationValue(String miimonValue){ String extraOption = ""; if (value.equals(BondMode.BOND4.value)) { extraOption = " xmit_hash_policy=2"; } return MODE + value + " miimon=" + miimonValue + extraOption; }
Source:
<code>static void dropCluster(String zkLayoutPath, String clusterName, String dcs, HelixAdminFactory helixAdminFactory) throws Exception { Map<String, ClusterMapUtils.DcZkInfo> dataCenterToZkAddress = ClusterMapUtils.parseDcJsonAndPopulateDcInfo(Utils.readStringFromFile(zkLayoutPath)); <START> if (dcs != null && !dcs.isEmpty() && !dcs.equalsIgnoreCase("all")) { <END> Set<String> dcsSet = Arrays.stream(dcs.replaceAll("\\p{Space}", "").split(",")).collect(Collectors.toSet()); dataCenterToZkAddress = dataCenterToZkAddress.entrySet() .stream() .filter(e -> dcsSet.contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } info("Dropping cluster from Helix", clusterName); for (Map.Entry<String, ClusterMapUtils.DcZkInfo> entry : dataCenterToZkAddress.entrySet()) { HelixAdmin admin = helixAdminFactory.getHelixAdmin(entry.getValue().getZkConnectStr()); admin.dropCluster(clusterName); info("Dropped cluster from {}", entry.getKey()); } }</code><technical_language>minor: Utils.isNullOrEmpty()</technical_language>

Target:
static void dropCluster(String zkLayoutPath, String clusterName, String dcs, HelixAdminFactory helixAdminFactory) throws Exception { Map<String, ClusterMapUtils.DcZkInfo> dataCenterToZkAddress = parseAndUpdateDcInfoFromArg(dcs, zkLayoutPath); info("Dropping cluster from Helix", clusterName); for (Map.Entry<String, ClusterMapUtils.DcZkInfo> entry : dataCenterToZkAddress.entrySet()) { HelixAdmin admin = helixAdminFactory.getHelixAdmin(entry.getValue().getZkConnectStr()); admin.dropCluster(clusterName); info("Dropped cluster from {}", entry.getKey()); } }
Source:
<code><START> public boolean startConvertion(Recording rec) { <END> IRecordingConverter conv = rec.isInterview() ? interviewConverter : recordingConverter; taskExecutor.execute(() -> conv.startConversion(rec)); return true; }</code><technical_language>need public</technical_language>

Target:
boolean startConvertion(Recording rec) { IRecordingConverter conv = rec.isInterview() ? interviewConverter : recordingConverter; taskExecutor.execute(() -> conv.startConversion(rec)); return true; }
Source:
<code>public boolean onOptionsItemSelected(MenuItem item) { if (super.onOptionsItemSelected(item)) { return true; } switch (item.getItemId()) { case R.id.refresh_item: AutoUpdateManager.runImmediate(requireContext()); return true; case R.id.subscriptions_filter: FeedFilterDialog.showDialog(requireContext()); return true; case R.id.subscriptions_sort: <START> FeedSortDialog.showDialog(requireContext()); <END> case R.id.subscription_num_columns_2: setColumnNumber(2); return true; case R.id.subscription_num_columns_3: setColumnNumber(3); return true; case R.id.subscription_num_columns_4: setColumnNumber(4); return true; case R.id.subscription_num_columns_5: setColumnNumber(5); return true; default: return false; } }</code><technical_language>This is missing a line return true;. Otherwise, fall execute next case, too</technical_language>

Target:
public boolean onOptionsItemSelected(MenuItem item) { if (super.onOptionsItemSelected(item)) { return true; } switch (item.getItemId()) { case R.id.refresh_item: AutoUpdateManager.runImmediate(requireContext()); return true; case R.id.subscriptions_filter: FeedFilterDialog.showDialog(requireContext()); return true; case R.id.subscriptions_sort: FeedSortDialog.showDialog(requireContext()); return true; case R.id.subscription_num_columns_2: setColumnNumber(2); return true; case R.id.subscription_num_columns_3: setColumnNumber(3); return true; case R.id.subscription_num_columns_4: setColumnNumber(4); return true; case R.id.subscription_num_columns_5: setColumnNumber(5); return true; default: return false; } }
Source:
<code><START> public static Class<?> getPreferenceActivity() { <END> if (Build.VERSION.SDK_INT > 10) { return PreferenceActivity.class; } else { return PreferenceActivityGingerbread.class; } }</code><technical_language>Class<? extends Activity>? this a bit useful</technical_language>

Target:
public static Class<? extends Activity> getPreferenceActivity() { if (Build.VERSION.SDK_INT > 10) { return PreferenceActivity.class; } else { return PreferenceActivityGingerbread.class; } }
Source:
<code>public void noQueuedTasksLossWhenRunningRequestCompleteOnSuspendedRC() throws InterruptedException { final AtomicInteger executedTaskCount = new AtomicInteger(); RequestController rc = suspendedRCWithQueuedTasks(TASKS_QTY, () -> { executedTaskCount.incrementAndGet(); }); CountDownLatch latch = new CountDownLatch(THREADS_QTY); createSynchronisedThreads(latch, () -> { rc.requestComplete(); }).forEach(Thread::start); latch.await(); <START> rc.resume(); <END> assertEquals(TASKS_QTY, executedTaskCount.intValue()); }</code><technical_language>AIUI basic problem is more of threads called rc.requestComplete() paused == true is executing findForcedTask drained some tasks taskQueue 'storage' list. time rc.resume is called finds queue empty returns. thread in findForcedTask puts 'storage' tasks in queue is execute them. Is a correct summary</technical_language>

Target:
public void noQueuedTasksLossWhenRunningRequestCompleteOnSuspendedRC() throws InterruptedException { final AtomicInteger executedTaskCount = new AtomicInteger(); RequestController rc = suspendedRCWithQueuedTasks(TASKS_QTY, () -> { executedTaskCount.incrementAndGet(); }); CountDownLatch latch = new CountDownLatch(THREADS_QTY); List<Thread> threads = createSynchronisedThreads(latch, () -> { rc.requestComplete(); }); threads.forEach(Thread::start); latch.await(); rc.resume(); for (Thread t : threads) { t.join(); } for (int requestNo = 0; requestNo < TASKS_QTY; requestNo++) { rc.requestComplete(); } assertEquals(TASKS_QTY, executedTaskCount.intValue()); }
Source:
<code>private void showAnalyticsExplanationDialog() { new AlertDialog.Builder(this) .setTitle(R.string.analytics_usage) <START> .setMessage(R.string.analytics_usage_overview) <END> .setNegativeButton(R.string.optout, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sharedPref.edit().putBoolean("pref_analytics_opt_in", false).apply(); } }) .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sharedPref.edit().putBoolean("pref_analytics_opt_in", true).apply(); GlucosioApplication application = (GlucosioApplication) getApplication(); Analytics analytics = application.getAnalytics(); analytics.reportScreen("Hello Activity"); } }) .show(); }</code><technical_language>adding setCancelable(false) force user a decision</technical_language>

Target:
private void showAnalyticsExplanationDialog() { new AlertDialog.Builder(this) .setTitle(R.string.analytics_usage) .setMessage(R.string.analytics_usage_overview) .setCancelable(false) .setNegativeButton(R.string.optout, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sharedPref.edit().putBoolean("pref_analytics_opt_in", false).apply(); } }) .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sharedPref.edit().putBoolean("pref_analytics_opt_in", true).apply(); GlucosioApplication application = (GlucosioApplication) getApplication(); Analytics analytics = application.getAnalytics(); analytics.reportScreen("Hello Activity"); } }) .show(); }
Source:
<code>public String getScreenTitle() { <START> return "Welcome to Dashboards"; <END> }</code><technical_language>Consider i18n for this title</technical_language>

Target:
public String getScreenTitle() { return i18n.runtimeScreenTitle(); }
Source:
<code>protected void starting() { <END> <START> if (mementos != null) { for (CacheMemento memento : mementos) { memento.cache(); } } }</code><technical_language>I mementos null. suggest Arrays.stream(mementos).foreach(CacheMemento::cache)</technical_language>

Target:
protected void starting() { Arrays.stream(mementos).forEach(CacheMemento::cache); }
Source:
<code>default Stream<T> takeRight(int n) { <START> if(length() <= n) { <END> return this; } else { return reverse().take(n).reverse(); } }</code><technical_language>check for n <= 0</technical_language>

Target:
default Stream<T> takeRight(int n) { if (n <= 0) { return empty(); } else if (length() <= n) { return this; } else { return reverse().take(n).reverse(); } }
Source:
<code>public void onSelectionChanged(int selectedItemCnt) { int numberMergeSelections = adapter.numberMergeSelections; if (adapter.isMergeSelection && selectedItemCnt >= numberMergeSelections) { <START> ToastUtil.showError(getContext(), "We can only merge " + numberMergeSelections + " projects"); <END> } updateSelectionToggle(actionMode.getMenu().findItem(R.id.toggle_selection)); actionMode.setTitle(getResources() .getQuantityString(getActionModeTitleId(actionModeType), selectedItemCnt, selectedItemCnt)); }</code><technical_language>is a reason this is displayed everytime? this is shown project is selected, there</technical_language>

Target:
public void onSelectionChanged(int selectedItemCnt) { updateSelectionToggle(actionMode.getMenu().findItem(R.id.toggle_selection)); actionMode.setTitle(getResources() .getQuantityString(getActionModeTitleId(actionModeType), selectedItemCnt, selectedItemCnt)); }
Source:
<code>public void registerAdditionalCatalog(Achievement achievement) { <START> this.achievementMappings.put(achievement.getId().toLowerCase(), achievement); <END> }</code><technical_language>This check id is registered. This define a locale for lowercase method</technical_language>

Target:
public void registerAdditionalCatalog(Achievement achievement) { checkNotNull(achievement, "null achievement"); this.achievementMappings.put(achievement.getId().toLowerCase(Locale.ENGLISH), achievement); }
Source:
<code>public Observable<Void> register(final InstanceInfo instanceInfo) { if (moveToState(STATE.Idle, STATE.Registered)) { return firstRegistration(instanceInfo); } if (getState() == STATE.Registered) { return registrationUpdate(instanceInfo); } STATE currentState = getState(); if (STATE.Closed == currentState) { return Observable.error(CHANNEL_CLOSED_EXCEPTION); } else { Exception exception = new IllegalStateException("Unknown state error when registering, current state: " + currentState); return sendErrorOnTransport(exception).doOnTerminate(new Action0() { @Override public void call() { <START> close(); <END> } }); } }</code><technical_language>close(exception)</technical_language>

Target:
public Observable<Void> register(final InstanceInfo instanceInfo) { if (moveToState(STATE.Idle, STATE.Registered)) { return firstRegistration(instanceInfo); } if (getState() == STATE.Registered) { return registrationUpdate(instanceInfo); } STATE currentState = getState(); if (STATE.Closed == currentState) { return Observable.error(CHANNEL_CLOSED_EXCEPTION); } else { final Exception exception = new IllegalStateException("Unknown state error when registering, current state: " + currentState); return sendErrorOnTransport(exception).doOnTerminate(new Action0() { @Override public void call() { close(exception); } }); } }
Source:
<code>public void deactivate() { try { consumer.stop(); <START> clearConsumer(); <END> consumer.close(); reliableConsumer.close(); } catch (JCSMPException e) { DTThrowable.rethrow(e); } }</code><technical_language>clearConsumer() is a no-op everywhere. remove definition call is a reason for in future</technical_language>

Target:
public void deactivate() { reliableConsumer.close(); }
Source:
<code>public static boolean isQueryResultEmpty(Connection connection, String query) throws JdbcException { PreparedStatement stmt = null; try { stmt = connection.prepareStatement(query); ResultSet rs = stmt.executeQuery(); try { return rs.isAfterLast(); } finally { rs.close(); } } catch (Exception e) { throw new JdbcException("could not obtain value using query ["+query+"]",e); <START> } finally { if (stmt!=null) { try { stmt.close(); } catch (Exception e) { throw new JdbcException("could not close statement of query ["+query+"]",e); } } } <END> }</code><technical_language>In plaats van try { } finally, kan je hier een dubbele 'try resource' doen op statement en op result set: try (PreparedStatement stmt = connection.prepareStatement(query)) { try (ResultSet rs = stmt.executeQuery()) { return rs.isAfterLast(); } catch (Exception e) { throw new JdbcException("could obtain query ["+query+"]",e); } } De finally clauses gaan dan vanzelf</technical_language>

Target:
public static boolean isQueryResultEmpty(Connection connection, String query) throws JdbcException { try (PreparedStatement stmt = connection.prepareStatement(query)) { try (ResultSet rs = stmt.executeQuery()) { return rs.isAfterLast(); } catch (SQLException e) { throw new JdbcException("could not obtain value using query [" + query + "]", e); } } catch (SQLException e) { throw new JdbcException("could not obtain value using query [" + query + "]", e); } }
Source:
<code>private static boolean isAmbiguousMethod( Symbol.MethodSymbol symbol, @Nullable ExpressionTree receiver, VisitorState state) { if (symbol.isStatic()) { if (symbol.params().size() != 1) { return false; } Symbol.ClassSymbol classSymbol = ASTHelpers.enclosingClass(symbol); if (classSymbol == null) { return false; } <START> Set<Symbol.MethodSymbol> matching = ASTHelpers.findMatchingMethods( <END> symbol.name, sym -> sym != null && !sym.isStatic() && sym.getParameters().isEmpty(), classSymbol.type, state.getTypes()); return !matching.isEmpty(); } else { if (!symbol.params().isEmpty()) { return false; } if (receiver == null) { return false; } Type receiverType = ASTHelpers.getType(receiver); if (receiverType == null) { return false; } Set<Symbol.MethodSymbol> matching = ASTHelpers.findMatchingMethods( symbol.name, sym -> sym != null && sym.isStatic() && sym.getParameters().size() == 1 && state.getTypes() .isAssignable(receiverType, sym.params().get(0).type), receiverType, state.getTypes()); return !matching.isEmpty(); } }</code><technical_language>this is a super cool helper method! existed</technical_language>

Target:
private static boolean isAmbiguousMethod( Symbol.MethodSymbol symbol, @Nullable ExpressionTree receiver, VisitorState state) { if (symbol.isStatic()) { if (symbol.params().size() != 1) { return false; } Symbol.ClassSymbol classSymbol = ASTHelpers.enclosingClass(symbol); if (classSymbol == null) { return false; } Set<Symbol.MethodSymbol> matching = ASTHelpers.findMatchingMethods( symbol.name, sym -> sym != null && !sym.isStatic() && sym.getParameters().isEmpty(), classSymbol.type, state.getTypes()); return !matching.isEmpty(); } else { if (!symbol.params().isEmpty()) { return false; } if (receiver == null) { return false; } Type receiverType = ASTHelpers.getType(receiver); if (receiverType == null) { return false; } Set<Symbol.MethodSymbol> matching = ASTHelpers.findMatchingMethods( symbol.name, sym -> sym != null && sym.isStatic() && sym.getParameters().size() == 1 && state.getTypes() .isAssignable( state.getTypes().erasure(receiverType), state.getTypes() .erasure(sym.params().get(0).type)), receiverType, state.getTypes()); return !matching.isEmpty(); } }
Source:
<code>public MessagePacker writePayload(byte[] src, int off, int len) throws IOException { <START> if (buffer.size() - position < len || len > 8192) { <END> flush(); out.write(src, off, len); totalFlushBytes += len; } else { buffer.putBytes(position, src, off, len); position += len; } return this; }</code><technical_language>create a constant variable replace 8192 it</technical_language>

Target:
public MessagePacker writePayload(byte[] src, int off, int len) throws IOException { if (buffer.size() - position < len || len > bufferFlushThreshold) { flush(); out.write(src, off, len); totalFlushBytes += len; } else { buffer.putBytes(position, src, off, len); position += len; } return this; }