auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void authenticateUserShouldReturnTheAuthenticationResponse() throws Exception { <START> String responseString = "{" + <END> "\"access_token\": \"foo\"," + "\"description\": \"bar\"," + "\"expires_in\": null" + "}"; MockRestAdapter<AuthenticationResponse> adapter = new MockRestAdapter<>("foobar", responseString, null); adapter.request(new RepromiseFunction<BitreserveRestAdapter, AuthenticationResponse>() { @Override public Promise<AuthenticationResponse> call(BitreserveRestAdapter adapter) { BitreserveClient client = new BitreserveClient("foobar"); client.getToken().setBitreserveRestAdapter(adapter); return client.authenticateUser("otp", "user", "password", new AuthenticationRequest("description")); } }); AuthenticationResponse authenticationResponse = adapter.getResult(); Request request = adapter.getRequest(); Assert.assertEquals(request.getHeaders().get(0).getName(), "X-Bitreserve-OTP"); Assert.assertEquals(request.getHeaders().get(0).getValue(), "otp"); Assert.assertEquals(request.getHeaders().get(1).getName(), "Authorization"); Assert.assertEquals(request.getHeaders().get(1).getValue(), "Basic dXNlcjpwYXNzd29yZA=="); Assert.assertEquals(request.getMethod(), "POST"); Assert.assertEquals(request.getUrl(), "<LINK_0>"); Assert.assertEquals(authenticationResponse.getAccessToken(), "foo"); Assert.assertEquals(authenticationResponse.getDescription(), "bar"); Assert.assertNull(authenticationResponse.getExpiresIn()); }</code><technical_language>This is small enough a single line</technical_language>

Target:
public void authenticateUserShouldReturnTheAuthenticationResponse() throws Exception { String responseString = "{ \"access_token\": \"foo\", \"description\": \"bar\", \"expires\": null }"; MockRestAdapter<AuthenticationResponse> adapter = new MockRestAdapter<>("foobar", responseString, null); adapter.request(new RepromiseFunction<BitreserveRestAdapter, AuthenticationResponse>() { @Override public Promise<AuthenticationResponse> call(BitreserveRestAdapter adapter) { BitreserveClient client = new BitreserveClient("foobar"); client.getToken().setBitreserveRestAdapter(adapter); return client.authenticateUser("otp", "user", "password", new AuthenticationRequest("description")); } }); AuthenticationResponse authenticationResponse = adapter.getResult(); Request request = adapter.getRequest(); Assert.assertEquals(request.getHeaders().get(0).getName(), "X-Bitreserve-OTP"); Assert.assertEquals(request.getHeaders().get(0).getValue(), "otp"); Assert.assertEquals(request.getHeaders().get(1).getName(), "Authorization"); Assert.assertEquals(request.getHeaders().get(1).getValue(), "Basic dXNlcjpwYXNzd29yZA=="); Assert.assertEquals(request.getMethod(), "POST"); Assert.assertEquals(request.getUrl(), "<LINK_0>"); Assert.assertEquals(authenticationResponse.getAccessToken(), "foo"); Assert.assertEquals(authenticationResponse.getDescription(), "bar"); Assert.assertNull(authenticationResponse.getExpiresIn()); }
Source:
<code>public InputStream getStream(URL uri) throws IOException { Cache<URL, AudioStreamCache> cache = getCache(); AudioStreamCache stream = cache.get(uri); if (stream == null) { stream = new AudioStreamCache(uri); AudioStreamCache exists = cache.putIfAbsent(uri, stream); if (exists != null) { stream = exists; <START> } <END> } return new ByteArrayInputStream(stream.getBytes()); }</code><technical_language>"else" call getBytes method, remove reentrantlock, thread call getBytes... ?</technical_language>

Target:
public InputStream getStream(URL uri) throws IOException { Cache<URL, ByteStreamCache> cache = getCache(); ByteStreamCache stream = cache.get(uri); if (stream == null) { stream = new ByteStreamCache(); ByteStreamCache exists = cache.putIfAbsent(uri, stream); if (exists != null) { stream = exists; } } return new ByteArrayInputStream(stream.getBytes(uri, sizeChangedListener)); }
Source:
<code>public void exitsSuccessfully() throws IOException { <START> final MemberProfileJson memberprofilejson = <END> Mockito.mock(MemberProfileJson.class); Mockito.when( memberprofilejson.fetch( Mockito.anyString(), Mockito.anyString(), Mockito.any(Href.class) ) ).thenReturn( Json.createReader( new FileInputStream( PsLinkedinTest.class.getResource( "linkedinTestUser.json" ).getPath() ) ).readObject() ); final Response response = new RsWithStatus( new RsWithType( new RsWithBody("<html>This is test response</html>"), "text/html" ), HttpURLConnection.HTTP_OK ); MatcherAssert.assertThat( new PsLinkedin( memberprofilejson ).exit(response, Mockito.mock(Identity.class)), Matchers.is(response) ); }</code><technical_language>@ikhvostenkov json, this part mocking MemberProfileJson adding moved single private method accept filename a parameter</technical_language>

Target:
public void exitsSuccessfully() throws IOException { final Response response = new RsWithStatus( new RsWithType( new RsWithBody("<html>This is test response</html>"), "text/html" ), HttpURLConnection.HTTP_OK ); MatcherAssert.assertThat( new PsLinkedin("someApp", "someTestKey") .exit(response, Mockito.mock(Identity.class)), Matchers.is(response) ); }
Source:
<code>private void setNetworkStats(HWNetworkStore netstore) { String txBytesPath, rxBytesPath, txPacketsPath, rxPacketsPath; List<String> read; txBytesPath = "/sys/class/net/" + netstore.getName() + "/statistics/tx_bytes"; rxBytesPath = "/sys/class/net/" + netstore.getName() + "/statistics/rx_bytes"; txPacketsPath = "/sys/class/net/" + netstore.getName() + "/statistics/tx_packets"; rxPacketsPath = "/sys/class/net/" + netstore.getName() + "/statistics/rx_packets"; try { read = FileUtil.readFile(txBytesPath); <START> netstore.setBytesSent(Long.parseLong(read.get(0))); <END> read = FileUtil.readFile(rxBytesPath); netstore.setBytesRecv(Long.parseLong(read.get(0))); read = FileUtil.readFile(txPacketsPath); netstore.setPacketsSent(Long.parseLong(read.get(0))); read = FileUtil.readFile(rxPacketsPath); netstore.setPacketsRecv(Long.parseLong(read.get(0))); } catch (IOException ex) { LOG.error("Error when retrieving network statistics for interface " + netstore.getName()); LOG.debug("Error message: " + ex.getMessage()); } }</code><technical_language>FileUtil.readFile() potentially return empty array. need test .size() .get(0)</technical_language>

Target:
private void setNetworkStats(HWNetworkStore netstore) { String txBytesPath, rxBytesPath, txPacketsPath, rxPacketsPath, speed; txBytesPath = String.format("/sys/class/net/%s/statistics/tx_bytes", netstore.getName()); rxBytesPath = String.format("/sys/class/net/%s/statistics/rx_bytes", netstore.getName()); txPacketsPath = String.format("/sys/class/net/%s/statistics/tx_packets", netstore.getName()); rxPacketsPath = String.format("/sys/class/net/%s/statistics/rx_packets", netstore.getName()); speed = String.format("/sys/class/net/%s/speed", netstore.getName()); netstore.setBytesSent(this.readFile(txBytesPath)); netstore.setBytesRecv(this.readFile(rxBytesPath)); netstore.setPacketsSent(this.readFile(txPacketsPath)); netstore.setPacketsRecv(this.readFile(rxPacketsPath)); netstore.setSpeed(this.readFile(speed)); }
Source:
<code>private RevisionInfo resolveRevisionToDisplay(ChangeInfo info) { if (revision == null) { revision = info.current_revision(); } else if (!info.revisions().containsKey(revision)) { JsArray<RevisionInfo> list = info.revisions().values(); for (int i = 0; i < list.length(); i++) { RevisionInfo r = list.get(i); if (revision.equals(String.valueOf(r._number()))) { revision = r.name(); break; } } } if (revision != null) { <START> return info.revision(revision); <END> } else { JsArray<RevisionInfo> revisions = info.revisions().values(); if (revisions.length() > 0) { RevisionInfo.sortRevisionInfoByNumber(revisions); RevisionInfo rev = revisions.get(revisions.length() - 1); revision = rev.name(); return rev; } else { new ErrorDialog( Resources.M.changeWithNoRevisions(info.legacy_id().get())).center(); throw new IllegalStateException("no revision, cannot proceed"); } } }</code><technical_language>This fail. If current_revision in revisions collection hosed. Rewrite this as: RevisionInfo rev = revision != null ? info.revision(revision) : null; if (rev != null) { return rev; } // revision undefined missing if revision is a draft, // if is corruption in metadata database. Display // revision instead</technical_language>

Target:
private RevisionInfo resolveRevisionToDisplay(ChangeInfo info) { if (revision == null) { revision = info.current_revision(); } else if (!info.revisions().containsKey(revision)) { JsArray<RevisionInfo> list = info.revisions().values(); for (int i = 0; i < list.length(); i++) { RevisionInfo r = list.get(i); if (revision.equals(String.valueOf(r._number()))) { revision = r.name(); break; } } } RevisionInfo rev = revision != null ? info.revision(revision) : null; if (rev != null) { return rev; } JsArray<RevisionInfo> revisions = info.revisions().values(); if (revisions.length() > 0) { RevisionInfo.sortRevisionInfoByNumber(revisions); rev = revisions.get(revisions.length() - 1); revision = rev.name(); return rev; } else { new ErrorDialog( Resources.M.changeWithNoRevisions(info.legacy_id().get())).center(); throw new IllegalStateException("no revision, cannot proceed"); } }
Source:
<code>public long getEstimatedSize() { return INSTANCE_SIZE + values.getRetainedSizeInBytes() + counts.sizeOf() + valueStore.getEstimatedSize() + nextPointers.sizeOf() + headPointers.sizeOf() <START> + buckets.sizeOf() <END> + groupIds.sizeOf(); }</code><technical_language>static import checkArgument</technical_language>

Target:
public long getEstimatedSize() { return INSTANCE_SIZE + counts.sizeOf() + groupIds.sizeOf() + nextPointers.sizeOf() + valuePositions.sizeOf() + valueAndGroupHashes.sizeOf() + buckets.sizeOf() + values.getRetainedSizeInBytes() + valueStore.getEstimatedSize() + headPointers.sizeOf(); }
Source:
<code>void request() throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; <DTO> DTO request(@NotNull Class<DTO> dtoInterface) throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; String requestString() throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; Map<String, String> requestProperties() throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; <DTO> List<DTO> requestList(@NotNull Class<DTO> dtoInterface) throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; <T> T request(@NotNull Class<T> clazz, @Nullable Type typeOfT) throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; <START> default HttpJsonRequest useGetMethod() { <END> return setMethod(HttpMethod.GET); }</code><technical_language>I prefer name setGetMethod</technical_language>

Target:
HttpJsonResponse request() throws IOException, ServerException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, BadRequestException; default HttpJsonRequest useGetMethod() { return setMethod(HttpMethod.GET); }
Source:
<code>public List<ByteBuffer> sliceBuffers(long len) throws EOFException { if (len <= 0) { return Collections.emptyList(); } if (current == null) { throw new EOFException(); } List<ByteBuffer> buffers = new ArrayList<>(); int bytesAccumulated = 0; while (bytesAccumulated < len) { <START> if (current.remaining() > 0) { <END> int bufLen = (int) Math.min(len - bytesAccumulated, current.remaining()); ByteBuffer slice = current.duplicate(); slice.limit(slice.position() + bufLen); buffers.add(slice); bytesAccumulated += bufLen; current.position(current.position() + bufLen); this.position += bufLen; } else if (!nextBuffer()) { throw new EOFException(); } } return buffers; }</code><technical_language>avoid slicing ByteBuffers fit in requested range, a cheap operation, is worth effort of explicitly handling them</technical_language>

Target:
public List<ByteBuffer> sliceBuffers(long len) throws EOFException { if (len <= 0) { return Collections.emptyList(); } if (current == null) { throw new EOFException(); } List<ByteBuffer> buffers = new ArrayList<>(); long bytesAccumulated = 0; while (bytesAccumulated < len) { if (current.remaining() > 0) { int bufLen = (int) Math.min(len - bytesAccumulated, current.remaining()); ByteBuffer slice = current.duplicate(); slice.limit(slice.position() + bufLen); buffers.add(slice); bytesAccumulated += bufLen; current.position(current.position() + bufLen); this.position += bufLen; } else if (!nextBuffer()) { throw new EOFException(); } } return buffers; }
Source:
<code>public String getDescription() { <START> return "Dropping an Association to generate a CreateLinkAction"; <END> }</code><technical_language>Missing NLS</technical_language>

Target:
public String getDescription() { return Messages.AssociationToCreateLinkActionDropStrategy_Description; }
Source:
<code>public R visitInsert(Insert<?> node, C context) { node.table().accept(this, context); <START> if (node.subQuery() != null) { <END> node.subQuery().accept(this, context); } return null; }</code><technical_language>insert source</technical_language>

Target:
public R visitInsert(Insert<?> node, C context) { node.table().accept(this, context); node.insertSource().accept(this, context); return null; }
Source:
<code>public void revertChanges() { <START> view.setName(preferencesManager.getValue(COMMITTER_NAME)); <END> view.setEmail(preferencesManager.getValue(COMMITTER_EMAIL)); dirty = false; }</code><technical_language>is happening is committer name in preferences</technical_language>

Target:
public void revertChanges() { name = firstNonNull(preferencesManager.getValue(COMMITTER_NAME), DEFAULT_COMMITTER_NAME); email = firstNonNull(preferencesManager.getValue(COMMITTER_EMAIL), DEFAULT_COMMITTER_EMAIL); view.setName(name); view.setEmail(email); dirty = false; }
Source:
<code>public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { <START> return endpoint.getRowType(relDataTypeFactory); <END> }</code><technical_language>return relDataType here, if is null. rename field relDataType rowType, represents schema of row</technical_language>

Target:
public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { if (rowType == null) { rowType = endpoint.getRowType(relDataTypeFactory); } return rowType; }
Source:
<code>public String getUrlFromInternalLinkaAfterPageIsLoaded() { <START> wait.forElementPresent(By.cssSelector(".header-title")); <END> return driver.getCurrentUrl(); }</code><technical_language>declared part of UI mapping top of class</technical_language>

Target:
public String getUrlFromInternalLinkaAfterPageIsLoaded() { wait.forElementVisible(headerTitle); return driver.getCurrentUrl(); }
Source:
<code>public void testProjectNameInAFolderDisplayName() throws Exception { final String projectName1 = "job-1"; final String displayName1 = "job-1"; final String projectName2 = "job-2"; final String displayName2 = "my-folder-1 job-2"; FreeStyleProject project1 = j.createFreeStyleProject(projectName1); <START> project1.setDisplayName(displayName1); <END> FreeStyleProject project2 = j.createFolder("my-folder-1").createProject(FreeStyleProject.class, projectName2); project2.setDisplayName(displayName2); WebClient wc = j.createWebClient(); Page result = wc.goTo("job/my-folder-1/search/suggest?query=" + projectName2, "application/json"); assertNotNull(result); j.assertGoodStatus(result); String content = result.getWebResponse().getContentAsString(); JSONObject jsonContent = (JSONObject)JSONSerializer.toJSON(content); assertNotNull(jsonContent); JSONArray jsonArray = jsonContent.getJSONArray("suggestions"); assertNotNull(jsonArray); assertEquals(1, jsonArray.size()); boolean foundDisplayName = false; for(Object suggestion : jsonArray) { JSONObject jsonSuggestion = (JSONObject)suggestion; String name = (String)jsonSuggestion.get("name"); if(displayName2.equals(name)) { foundDisplayName = true; } } assertTrue(foundDisplayName); }</code><technical_language>this is a no-op</technical_language>

Target:
public void testProjectNameInAFolderDisplayName() throws Exception { final String projectName1 = "job-1"; final String displayName1 = "job-1 display"; final String projectName2 = "job-2"; final String displayName2 = "my-folder-1 job-2"; FreeStyleProject project1 = j.createFreeStyleProject(projectName1); project1.setDisplayName(displayName1); MockFolder myMockFolder = j.createFolder("my-folder-1"); FreeStyleProject project2 = myMockFolder.createProject(FreeStyleProject.class, projectName2); project2.setDisplayName(displayName2); WebClient wc = j.createWebClient(); Page result = wc.goTo(myMockFolder.getUrl() + "search/suggest?query=" + projectName2, "application/json"); assertNotNull(result); j.assertGoodStatus(result); String content = result.getWebResponse().getContentAsString(); JSONObject jsonContent = (JSONObject)JSONSerializer.toJSON(content); assertNotNull(jsonContent); JSONArray jsonArray = jsonContent.getJSONArray("suggestions"); assertNotNull(jsonArray); assertEquals(1, jsonArray.size()); boolean foundDisplayName = false; for(Object suggestion : jsonArray) { JSONObject jsonSuggestion = (JSONObject)suggestion; String name = (String)jsonSuggestion.get("name"); if(displayName2.equals(name)) { foundDisplayName = true; } } assertTrue(foundDisplayName); }
Source:
<code>private boolean signalIsForUs(ITmfTrace sender) { for (ITmfTrace childtrace : TmfTraceManager.getTraceSet(sender)) { <START> if (sp.getTrace() == childtrace) { <END> return true; } } return false; }</code><technical_language>Ah true. I first, for .getTraceSet() enough..</technical_language>

Target:
private boolean signalIsForUs(ITmfTrace sender) { if (sender == sp.getTrace()) { return true; } else if (sender instanceof TmfExperiment) { for (ITmfTrace childtrace : TmfTraceManager.getTraceSet(sender)) { if (sp.getTrace() == childtrace) { return true; } } } return false; }
Source:
<code>public EAttribute[] getImagePathAttributes() { <START> EAttribute[] attrs = {DescriptionPackage.eINSTANCE.getLayer_Icon(), StylePackage.eINSTANCE.getWorkspaceImageDescription_WorkspacePath(), ToolPackage.eINSTANCE.getContainerCreationDescription_IconPath(), ToolPackage.eINSTANCE.getEdgeCreationDescription_IconPath(), ToolPackage.eINSTANCE.getNodeCreationDescription_IconPath(), ToolPackage.eINSTANCE.getToolSection_Icon()}; <END> return attrs; }</code><technical_language>This is constant defined in a "private static final" field</technical_language>

Target:
public EAttribute[] getImagePathAttributes() { return attrs; }
Source:
<code>public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_FACILITY_ATTR_DEF); attr.setFriendlyName("login_namespace"); attr.setDisplayName("Login namespace"); attr.setType(String.class.getName()); <START> attr.setDescription("All available home mount points."); <END> return attr; }</code><technical_language>mistake, please, fix too. is description for other attribute</technical_language>

Target:
public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_FACILITY_ATTR_DEF); attr.setFriendlyName("login_namespace"); attr.setDisplayName("Login namespace"); attr.setType(String.class.getName()); attr.setDescription("Namespace for logins which can use specific facility."); return attr; }
Source:
<code>public URI getProcessSubTypeURI(Integer processId, String processTitle, URI processDataDirectory, ProcessSubType processSubType, String resourceName) { if (processDataDirectory == null) { try { <START> ProcessService processService = getProcessService(); <END> Process process = processService.getById(processId); processDataDirectory = processService.getProcessDataDirectory(process); } catch (DAOException e) { processDataDirectory = URI.create(String.valueOf(processId)); } } if (resourceName == null) { resourceName = ""; } return fileManagement.getProcessSubTypeUri(processDataDirectory, processTitle, processSubType, resourceName); }</code><technical_language>ServiceManager.getProcessService() in method, done before? problem of infinite initialisation. need process service class level</technical_language>

Target:
public URI getProcessSubTypeURI(Integer processId, String processTitle, URI processDataDirectory, ProcessSubType processSubType, String resourceName) { if (Objects.isNull(processDataDirectory)) { try { Process process = ServiceManager.getProcessService().getById(processId); processDataDirectory = ServiceManager.getProcessService().getProcessDataDirectory(process); } catch (DAOException e) { processDataDirectory = URI.create(String.valueOf(processId)); } } if (Objects.isNull(resourceName)) { resourceName = ""; } return fileManagementModule.getProcessSubTypeUri(processDataDirectory, processTitle, processSubType, resourceName); }
Source:
<code>static String spliceOrAppendString(final String destination, final String toInsert, final int insertIdx) { if (insertIdx <= destination.length()) { return destination.substring(0, insertIdx) + toInsert + destination.substring(insertIdx); } else { <START> if (destination.length() > 0 && destination.charAt(destination.length()-1) == '*') { <END> return destination; } else { return destination + toInsert; } } }</code><technical_language>Also, instead of '*', Allele.SPAN_DEL_STRING</technical_language>

Target:
static String spliceOrAppendString(final String destination, final String toInsert, final int insertIdx) { if (insertIdx <= destination.length()) { return destination.substring(0, insertIdx) + toInsert + destination.substring(insertIdx); } else { if (destination.length() > 0 && destination.substring(destination.length()-1).equals(Allele.SPAN_DEL_STRING)) { return destination; } else { return destination + toInsert; } } }
Source:
<code>public void creationOf${bindingIdCamelCase}Handler() { assertThat(bridge.getHandler(), is(nullValue())); managedThingProvider.add(bridge); <START> waitForAssert(() -> assertThat(managedThingProvider.get(bridge.getUID()), is(notNullValue()))); <END> }</code><technical_language>I know, hamcrest matcher before, while please change java waitForAssert(() -> assertNotNull(managedThingProvider.get(bridge.getUID())));</technical_language>

Target:
public void creationOf${bindingIdCamelCase}Handler() { assertNull(bridge.getHandler()); managedThingProvider.add(bridge); waitForAssert(() -> assertNotNull(managedThingProvider.get(bridge.getUID()))); }
Source:
<code><START> protected void markCleanMerges() throws MergeException { <END> if (mergeTip == null) { return; } try { rw.reset(); rw.sort(RevSort.TOPO); rw.sort(RevSort.REVERSE, true); rw.markStart(mergeTip); for (RevCommit c : alreadyAccepted) { rw.markUninteresting(c); } CodeReviewCommit c; while ((c = (CodeReviewCommit) rw.next()) != null) { if (c.patchsetId != null) { c.statusCode = CommitMergeStatus.CLEAN_MERGE; if (branchUpdate.getRefLogIdent() == null) { setRefLogIdent(getSubmitter(c.patchsetId)); } } } } catch (IOException e) { throw new MergeException("Cannot mark clean merges", e); } }</code><technical_language>subclasses allowed override this method</technical_language>

Target:
protected final void markCleanMerges() throws MergeException { if (mergeTip == null) { return; } try { rw.reset(); rw.sort(RevSort.TOPO); rw.sort(RevSort.REVERSE, true); rw.markStart(mergeTip); for (RevCommit c : alreadyAccepted) { rw.markUninteresting(c); } CodeReviewCommit c; while ((c = (CodeReviewCommit) rw.next()) != null) { if (c.patchsetId != null) { c.statusCode = CommitMergeStatus.CLEAN_MERGE; if (branchUpdate.getRefLogIdent() == null) { setRefLogIdent(getSubmitter(c.patchsetId)); } } } } catch (IOException e) { throw new MergeException("Cannot mark clean merges", e); } }
Source:
<code>public void open(IPath file) { File statFile = file.toFile(); BufferedReader fileReader = null; try { fileReader = new BufferedReader(new FileReader(statFile)); final StringBuilder contents = new StringBuilder(); final StringBuilder title = new StringBuilder(); String line; while ((line = fileReader.readLine()) != null) { if (title.length() == 0 && line.contains(TITLE_EXCERPT)) { <START> title.append(line); <END> continue; } contents.append(line); contents.append("\n"); } if (title.length() == 0) { title.append(NLS.bind(Messages.PerfEditorLauncher_stat_title, statFile.getName())); } PerfPlugin.getDefault().setStatData(new IPerfData() { @Override public String getTitle() { return title.toString(); } @Override public String getPerfData() { return contents.toString(); } }); StatView.refreshView(); } catch (FileNotFoundException e) { PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_dne_error, statFile.getName())); } catch (IOException e) { PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_read_error, statFile.getName())); } finally { if (fileReader != null) { try { fileReader.close(); } catch (IOException e) { PerfPlugin.getDefault().openError(e, ""); } } } }</code><technical_language>Note perf stat data is displayed a result of a profiling run, title appears in text content description (ie. appending contents well)</technical_language>

Target:
public void open(IPath file) { File statFile = file.toFile(); BufferedReader fileReader = null; try { fileReader = new BufferedReader(new FileReader(statFile)); final StringBuilder contents = new StringBuilder(); final StringBuilder title = new StringBuilder(); String line; while ((line = fileReader.readLine()) != null) { if (title.length() == 0 && line.contains(TITLE_EXCERPT)) { title.append(line); } contents.append(line); contents.append("\n"); } if (title.length() == 0) { title.append(NLS.bind(Messages.PerfEditorLauncher_stat_title, statFile.getName())); } PerfPlugin.getDefault().setStatData(new IPerfData() { @Override public String getTitle() { return title.toString(); } @Override public String getPerfData() { return contents.toString(); } }); StatView.refreshView(); } catch (FileNotFoundException e) { PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_dne_error, statFile.getName())); } catch (IOException e) { PerfPlugin.getDefault().openError(e, NLS.bind(Messages.PerfEditorLauncher_file_read_error, statFile.getName())); } finally { if (fileReader != null) { try { fileReader.close(); } catch (IOException e) { PerfPlugin.getDefault().openError(e, ""); } } } }
Source:
<code>protected abstract void processMessage() throws Throwable; protected void sendResponse(Object response) { try { ClientMessage clientMessage = encodeResponse(response); sendClientMessage(clientMessage); } catch (Exception e) { sendClientMessage(e); <START> } <END> }</code><technical_language>want log exception finest here? if wrong able send exception. lose it</technical_language>

Target:
protected abstract void processMessage() throws Throwable; protected void sendResponse(Object response) { try { ClientMessage clientMessage = encodeResponse(response); sendClientMessage(clientMessage); } catch (Exception e) { handleProcessingFailure(e); } }
Source:
<code>public boolean test(ICubicWorld world) { if (!super.test(world)) return false; <START> if (world.getClass() == (Class<?>) WorldClient.class && ((World) world).getChunkProvider().getClass() != ChunkProviderClient.class) { <END> return true; } return super.test(world) && world.getClass() != (Class<?>) WorldClient.class; }</code><technical_language>is needed? If chunk provider is of wrong type, matter if WorldClient</technical_language>

Target:
public boolean test(ICubicWorld world) { return !allowedClientWorldClasses.contains(world.getClass()) || !allowedClientChunkProviderClasses.contains(((World) world).getChunkProvider().getClass()); }
Source:
<code>public void allDataPointsOldSchemaTest() { final Long surveyId = 300L; final List<SurveyedLocale> allDataPoints = createDataPoints(surveyId, 20); final List<Long> deviceIds = Arrays.asList(5L, 6L); final List<Long> formIds = Arrays.asList(10L, 11L); final SurveyAssignment sa = createAssignment(surveyId, deviceIds, formIds); <START> final DataPointServlet servlet = new DataPointServlet(); final List<SurveyedLocale> foundDataPoints = servlet.getDataPointList(surveyId, 6L); final Set<Long> allDataPointIds = getEntityIds(allDataPoints); final Set<Long> foundDataPointIds = getEntityIds(foundDataPoints); assertEquals(allDataPointIds, foundDataPointIds); <END> }</code><technical_language>This is duplicated times</technical_language>

Target:
public void allDataPointsOldSchemaTest() { final Long surveyId = randomId(); final List<SurveyedLocale> allDataPoints = createDataPoints(surveyId, 20); final List<Long> deviceIds = Arrays.asList(randomId(), randomId()); final List<Long> formIds = Arrays.asList(randomId(), randomId()); final SurveyAssignment sa = createAssignment(surveyId, deviceIds, formIds); final DataPointServlet servlet = new DataPointServlet(); final List<SurveyedLocale> foundDataPoints = servlet.getDataPointList(surveyId, deviceIds.get(0)); final Set<Long> allDataPointIds = getEntityIds(allDataPoints); final Set<Long> foundDataPointIds = getEntityIds(foundDataPoints); assertEquals(allDataPointIds, foundDataPointIds); }
Source:
<code>public static final String getPreferenceNodeId () { return <START> JAVA_UI_ID_PLUGIN; <END> }</code><technical_language>rename, too</technical_language>

Target:
public static final String getPreferenceNodeId () { return PREFERENCE_NODE_ID; }
Source:
<code><START> public synchronized boolean isFinished() <END> { StageExecutionState rootStageState = rootStage.getStageExecution().getState(); return rootStageState.isDone() && !rootStageState.isFailure(); }</code><technical_language>Defensive synchronized methods everywhere</technical_language>

Target:
public boolean isFinished() { StageExecutionState rootStageState = rootStage.getStageExecution().getState(); return rootStageState.isDone() && !rootStageState.isFailure(); }
Source:
<code>public void testGenerateKeyPairDefault() throws CredentialStoreException { String storageLocation = getStoragePathForNewFile(); String storagePassword = "cspassword"; String aliasName = "testalias"; String[] args = { "--location=" + storageLocation, "--create", "--generate-key-pair", aliasName, "--summary", "--password", storagePassword }; executeCommandAndCheckStatus(args); CredentialStore store = getCredentialStoreStorageFromExistsFile(storageLocation, storagePassword); KeyPairCredential credential = store.retrieve(aliasName, KeyPairCredential.class); KeyPair keyPair = credential.getKeyPair(); Assert.assertNotNull(keyPair); Assert.assertNotNull(keyPair.getPrivate()); Assert.assertNotNull(keyPair.getPublic()); Assert.assertEquals(Pem.RSA_ALGORITHM, keyPair.getPrivate().getAlgorithm()); <START> Assert.assertEquals(Pem.RSA_ALGORITHM, keyPair.getPrivate().getAlgorithm()); <END> Assert.assertEquals(new File(System.getProperty("user.home"), ".ssh"), credential.getSshDirectory()); Assert.assertEquals("known_hosts", credential.getKnownHostsFile()); }</code><technical_language>keyPair.getPublic()</technical_language>

Target:
public void testGenerateKeyPairDefault() throws CredentialStoreException { String storageLocation = getStoragePathForNewFile(); String storagePassword = "cspassword"; String aliasName = "testalias"; String[] args = { "--location=" + storageLocation, "--create", "--generate-key-pair", aliasName, "--summary", "--password", storagePassword }; executeCommandAndCheckStatus(args); CredentialStore store = getCredentialStoreStorageFromExistsFile(storageLocation, storagePassword); KeyPairCredential credential = store.retrieve(aliasName, KeyPairCredential.class); KeyPair keyPair = credential.getKeyPair(); Assert.assertNotNull(keyPair); Assert.assertNotNull(keyPair.getPrivate()); Assert.assertNotNull(keyPair.getPublic()); Assert.assertEquals(RSA_ALGORITHM, keyPair.getPrivate().getAlgorithm()); Assert.assertEquals(RSA_ALGORITHM, keyPair.getPublic().getAlgorithm()); }
Source:
<code>private boolean checkAllRights(DocumentReference oldReference, DocumentReference newReference) { if (this.request.isDeleteSource() && !hasAccess(Right.DELETE, oldReference)) { this.logger.error("You are not allowed to delete [{}].", oldReference); return false; } else if (!hasAccess(Right.VIEW, oldReference)) { this.logger.error("You don't have sufficient permissions over the source document [{}].", oldReference); return false; <START> } else if (!hasAccess(Right.VIEW, newReference) || !hasAccess(Right.EDIT, newReference) <END> || (this.modelBridge.exists(newReference) && !hasAccess(Right.DELETE, newReference))) { this.logger.error("You don't have sufficient permissions over the destination document [{}].", newReference); return false; } return true; }</code><technical_language>is need check VIEW right, EDIT is enough</technical_language>

Target:
private boolean checkAllRights(DocumentReference oldReference, DocumentReference newReference) { if (this.request.isDeleteSource() && !hasAccess(Right.DELETE, oldReference)) { this.logger.error("You are not allowed to delete [{}].", oldReference); return false; } else if (!hasAccess(Right.VIEW, oldReference)) { this.logger.error("You don't have sufficient permissions over the source document [{}].", oldReference); return false; } else if (!hasAccess(Right.EDIT, newReference) || (this.modelBridge.exists(newReference) && !hasAccess(Right.DELETE, newReference))) { this.logger.error("You don't have sufficient permissions over the destination document [{}].", newReference); return false; } return true; }
Source:
<code>public void updateData(@Nullable List<Object> data) { if (data == null || mRecyclerView == null) { setDataBound(false); return; } if (data.isEmpty()) { setDataBound(false); return; } if (mMapper == null) { <START> throw new RuntimeException(this.getClass().getName() + " does not have a RecyclerViewBinderMapper set!"); <END> } long startTime = System.currentTimeMillis(); Log.d(Constants.LOG_TAG, "BINDING DATA"); if (mAdapter == null) { SmartAdapter.MultiAdaptersCreator creator = SmartAdapter.items(new ArrayList<>(data)); mMapper.initializeMaps(creator); mAdapter = creator.into(mRecyclerView); } else { mAdapter.clearItems(); mAdapter.addItems(new ArrayList<>(data)); } if (mProgressBar != null) { mProgressBar.setVisibility(View.GONE); } mRecyclerView.setVisibility(View.VISIBLE); mNoDataBinder.unbindData(); Log.d(Constants.LOG_TAG, "BINDING COMPLETE; ELAPSED TIME: " + (System.currentTimeMillis() - startTime) + "ms"); setDataBound(true); }</code><technical_language>handle this more gracefully? Throwing a RuntimeException crashes. complain Log.e bind noDataView instead</technical_language>

Target:
public void updateData(@Nullable List<Object> data) { mList = data; if (data == null || mRecyclerView == null) { setDataBound(false); return; } if (data.isEmpty()) { setDataBound(false); return; } if (mMapper == null) { throw new RuntimeException(this.getClass().getName() + " does not have a RecyclerViewBinderMapper set!"); } if (mAdapter == null) { createAndInitializeAdapterForData(new ArrayList<>(data)); } else { mAdapter.clearItems(); mAdapter.addItems(new ArrayList<>(data)); } if (mProgressBar != null) { mProgressBar.setVisibility(View.GONE); } mRecyclerView.setVisibility(View.VISIBLE); mNoDataBinder.unbindData(); setDataBound(true); }
Source:
<code>public synchronized List<TagDto> getAllTags() { List<TagEntity> tags = (List<TagEntity>) (entityManager.createQuery("select te from TagEntity as te")).getResultList(); List<TagDto> allTags = new ArrayList<TagDto>(); if (!tags.isEmpty()) { <START> allTags = new ArrayList<TagDto>(); <END> for (TagEntity tagEntity : tags) { allTags.add(new TagDto(tagEntity.getName(), tagEntity.getDescription())); } } return allTags; }</code><technical_language>in line 45</technical_language>

Target:
public List<TagDto> getAllTags() { List<TagEntity> tags = (List<TagEntity>) (entityManager.createQuery("select te from TagEntity as te")).getResultList(); List<TagDto> allTags = new ArrayList<TagDto>(); if (!tags.isEmpty()) { for (TagEntity tagEntity : tags) { allTags.add(new TagDto(tagEntity.getName(), tagEntity.getDescription())); } } return allTags; }
Source:
<code>private static String validateTableName(String tableName) <START> { <END> return validateName(tableName, "Table"); }</code><technical_language>is modifier private? set modifiers validateDatabaseName validateTableNamet methods</technical_language>

Target:
static String validateTableName(String tableName) { return validateName(tableName, "Table"); }
Source:
<code>protected Object getValueInternal(ProgressListener listener) throws Exception { Object getCoverage = null; InputReferenceType ref = input.getReference(); if (ref.getMethod() == MethodType.POST_LITERAL) { getCoverage = ref.getBody(); } else { String version = getVersion(ref.getHref()); KvpRequestReader reader; if (version.equals("1.0.0") || version.equals("1.0")) { reader = (KvpRequestReader) context.getBean("wcs100GetCoverageRequestReader"); <START> } else if(version.equals("2.0.1") ){ <END> reader = (KvpRequestReader) context.getBean("wcs20getCoverageKvpParser"); } else { reader = (KvpRequestReader) context.getBean("wcs111GetCoverageRequestReader"); } getCoverage = kvpParse(ref.getHref(), reader); } if (getCoverage instanceof GetCoverageType) { WebCoverageService111 wcs = (WebCoverageService111) context .getBean("wcs111ServiceTarget"); return wcs.getCoverage((net.opengis.wcs11.GetCoverageType) getCoverage)[0]; } else if (getCoverage instanceof net.opengis.wcs10.GetCoverageType) { WebCoverageService100 wcs = (WebCoverageService100) context .getBean("wcs100ServiceTarget"); return wcs.getCoverage((net.opengis.wcs10.GetCoverageType) getCoverage)[0]; } else if (getCoverage instanceof net.opengis.wcs20.GetCoverageType) { WebCoverageService20 wcs = (WebCoverageService20) context .getBean("wcs20ServiceTarget"); return wcs.getCoverage((net.opengis.wcs20.GetCoverageType) getCoverage); } else { throw new WPSException("Unrecognized request type " + getCoverage); } }</code><technical_language>relax this check a bit allow for 2.0.0</technical_language>

Target:
protected Object getValueInternal(ProgressListener listener) throws Exception { Object getCoverage = null; InputReferenceType ref = input.getReference(); if (ref.getMethod() == MethodType.POST_LITERAL) { getCoverage = ref.getBody(); } else { String version = getVersion(ref.getHref()); KvpRequestReader reader; if ("1.0.0".equals(version) || "1.0".equals(version)) { reader = (KvpRequestReader) context.getBean("wcs100GetCoverageRequestReader"); } else if ("2.0.1".equals(version) || "2.0.0".equals(version)) { reader = (KvpRequestReader) context.getBean("wcs20getCoverageKvpParser"); } else { reader = (KvpRequestReader) context.getBean("wcs111GetCoverageRequestReader"); } getCoverage = kvpParse(ref.getHref(), reader); } if (getCoverage instanceof GetCoverageType) { WebCoverageService111 wcs = (WebCoverageService111) context .getBean("wcs111ServiceTarget"); return wcs.getCoverage((net.opengis.wcs11.GetCoverageType) getCoverage)[0]; } else if (getCoverage instanceof net.opengis.wcs10.GetCoverageType) { WebCoverageService100 wcs = (WebCoverageService100) context .getBean("wcs100ServiceTarget"); return wcs.getCoverage((net.opengis.wcs10.GetCoverageType) getCoverage)[0]; } else if (getCoverage instanceof net.opengis.wcs20.GetCoverageType) { WebCoverageService20 wcs = (WebCoverageService20) context .getBean("wcs20ServiceTarget"); return wcs.getCoverage((net.opengis.wcs20.GetCoverageType) getCoverage); } else { throw new WPSException("Unrecognized request type " + getCoverage); } }
Source:
<code>private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception { context.turnOffAuthorisationSystem(); <START> EPerson ePerson = EPersonBuilder.createEPerson(context).withEmail("user@test.com").build(); <END> String token = getAuthToken(asUser.getEmail(), password); new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/epersons/" + ePerson.getID(), expectedStatus); }</code><technical_language>Again, needs a context.restoreAuthSystemState();</technical_language>

Target:
private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception { context.turnOffAuthorisationSystem(); EPerson ePerson = EPersonBuilder.createEPerson(context).withEmail("user@test.com").build(); context.restoreAuthSystemState(); String token = getAuthToken(asUser.getEmail(), password); new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/epersons/" + ePerson.getID(), expectedStatus); }
Source:
<code>public HookResult call() throws Exception { HookResult result = null; StringBuilder output = new StringBuilder(); try { final List<String> argv = new ArrayList<String>(1 + args.size()); argv.add(hook.getAbsolutePath()); argv.addAll(args); final ProcessBuilder pb = new ProcessBuilder(argv); pb.redirectErrorStream(true); if (repo != null) { pb.directory(repo.getDirectory()); final Map<String, String> env = pb.environment(); env.put("GIT_DIR", repo.getDirectory().getAbsolutePath()); } Process ps = pb.start(); ps.getOutputStream().close(); BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream())); try { String line = br.readLine(); while (line != null) { output.append(line); line = br.readLine(); if(line != null) { <START> output.append(System.getProperty("line.separator")); <END> } } } finally { try { br.close(); } catch (IOException closeErr) { } ps.waitFor(); result = new HookResult(ps.exitValue(), output.toString()); } } catch (Throwable err) { log.error("Error running hook " + hook.getAbsolutePath(), err); } finally { if (repo != null) { repo.close(); } } return result; }</code><technical_language>dont want separator change based server, I making effort newlines in ssh outputs. Or, perhpas output hook outputs</technical_language>

Target:
public HookResult call() throws Exception { return super.runHook(); }
Source:
<code>private OSDisk createOSDisk(Image image) { OsFamily osFamily = image.getOperatingSystem().getFamily(); String osType = osFamily == OsFamily.WINDOWS ? "Windows" : "Linux"; return OSDisk.builder() .osType(osType) .caching(DataDisk.CachingTypes.READ_WRITE.toString()) <START> .createOption("FromImage") <END> .managedDiskParameters(ManagedDiskParameters.create(null, ManagedDiskParameters.StorageAccountTypes.STANDARD_LRS.toString())) .build(); }</code><technical_language>enum? CreateOptions.FROM_IMAGE.toString()</technical_language>

Target:
private OSDisk createOSDisk(Image image) { OsFamily osFamily = image.getOperatingSystem().getFamily(); String osType = osFamily == OsFamily.WINDOWS ? "Windows" : "Linux"; return OSDisk.builder() .osType(osType) .caching(DataDisk.CachingTypes.READ_WRITE.toString()) .createOption(CreationData.CreateOptions.FROM_IMAGE.toString()) .managedDiskParameters(ManagedDiskParameters.create(null, ManagedDiskParameters.StorageAccountTypes.STANDARD_LRS.toString())) .build(); }
Source:
<code>protected void endScope() { <START> if (this != CURRENT_SCOPE.get().peek()) { <END> throw new IllegalStateException( "Incorrectly trying to end another Scope then which the calling process is contained in." ); } CURRENT_SCOPE.get().pop(); if (CURRENT_SCOPE.get().isEmpty()) { logger.debug("Clearing out ThreadLocal current Scope, as no Scopes are present"); CURRENT_SCOPE.remove(); } }</code><technical_language>multiple invocations of CURRENT_SCOPE.get(). is a ThreadLocal, concurrency entry. optimized Thread Locals are, assigning a local variable help</technical_language>

Target:
protected void endScope() { Deque<Scope> scopes = CURRENT_SCOPE.get(); if (this != scopes.peek()) { throw new IllegalStateException( "Incorrectly trying to end another Scope then which the calling process is contained in." ); } scopes.pop(); if (scopes.isEmpty()) { logger.debug("Clearing out ThreadLocal current Scope, as no Scopes are present"); CURRENT_SCOPE.remove(); } }
Source:
<code>public void testNoOfflineMessageIfNotLoggedIn() throws IOException, InterruptedException { System.out.println("testNoOfflineMessageIfNotLoggedIn"); TestClient client2 = createTestClient(); client2.disconnect(); <START> Thread.sleep(1000); <END> assertNoMessage(client1); }</code><technical_language>Thread.sleep proper handle this. explain problem in more detail? figure out another solution. messages if this is here? is race condition exactly</technical_language>

Target:
public void testNoOfflineMessageIfNotLoggedIn() throws IOException, InterruptedException { shutdown(); class TestServer extends Server { private CountDownLatch latch; @Override public void onDisconnected(ClientIO client) { super.onDisconnected(client); if (latch != null) { latch.countDown(); } } public void setLatch(CountDownLatch latch) { this.latch = latch; } } CountDownLatch disconnectionLatch = new CountDownLatch(1); startServer(new TestServer()); ((TestServer) server).setLatch(disconnectionLatch); TestClient client2 = createTestClient(); client2.disconnect(); disconnectionLatch.await(); assertNoMessage(client1); }
Source:
<code>public Handler buildHandler(Class<?> sqlObjectType, Method method) { <START> return (obj, m, args, handle) -> { <END> return "foo"; }; }</code><technical_language>this -> "foo"</technical_language>

Target:
public Handler buildHandler(Class<?> sqlObjectType, Method method) { return (obj, m, args, handle) -> "foo"; }
Source:
<code>private ListenableFuture<List<DataSource>> syncDataSources() { ListenableFuture<List<DataSource>> future = exec.submit(() -> { <START> List<DataSource> dataSources1 = controller.getSleuthKitCase().getDataSources(); <END> synchronized (dataSourcesViewable) { dataSourcesViewable.clear(); dataSourcesViewable.put(null, controller.hasTooManyFiles(null)); for (DataSource ds : dataSources1) { dataSourcesViewable.put(ds, controller.hasTooManyFiles(ds)); } } return dataSources1; }); Futures.addCallback(future, new FutureCallback<List<DataSource>>() { @Override public void onSuccess(List<DataSource> result) { List<Optional<DataSource>> newDataSources = new ArrayList<>(); newDataSources.add(Optional.empty()); result.forEach(dataSource -> newDataSources.add(Optional.of(dataSource))); dataSources.setAll(newDataSources); } @Override public void onFailure(Throwable t) { logger.log(Level.SEVERE, "Unable to get datasources for current case.", t); } }, Platform::runLater); return future; }</code><technical_language>'dataSources1' named better</technical_language>

Target:
private ListenableFuture<List<DataSource>> syncDataSources() { ListenableFuture<List<DataSource>> future = exec.submit(() -> { List<DataSource> dataSourcesInCase = controller.getSleuthKitCase().getDataSources(); synchronized (dataSourcesViewable) { dataSourcesViewable.clear(); dataSourcesViewable.put(null, controller.hasTooManyFiles(null)); for (DataSource ds : dataSourcesInCase) { dataSourcesViewable.put(ds, controller.hasTooManyFiles(ds)); } } return dataSourcesInCase; }); Futures.addCallback(future, new FutureCallback<List<DataSource>>() { @Override public void onSuccess(List<DataSource> result) { List<Optional<DataSource>> newDataSources = new ArrayList<>(); newDataSources.add(Optional.empty()); result.forEach(dataSource -> newDataSources.add(Optional.of(dataSource))); dataSources.setAll(newDataSources); } @Override public void onFailure(Throwable t) { logger.log(Level.SEVERE, "Unable to get datasources for current case.", t); } }, Platform::runLater); return future; }
Source:
<code>private Retrofit createRetrofit() { <START> String baseUrl = SEApiConstants.API_BASE_URL + (SEApiConstants.BASE_API_PATH); <END> return new Retrofit.Builder() .baseUrl(baseUrl) .client(createOkHttpClient()) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); }</code><technical_language>remove braces SEApiConstants.BASE_API_PATH</technical_language>

Target:
private Retrofit createRetrofit() { String baseUrl = SEApiConstants.API_BASE_URL + SEApiConstants.BASE_API_PATH; return new Retrofit.Builder() .baseUrl(baseUrl) .client(createOkHttpClient()) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); }