auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private synchronized void updateReview(TaskTask task) { String summary = task.getSummary(); boolean ourQuery = task.getParentContainers().contains(fCurrentQuery); if (ourQuery && summary != null && !summary.equals("")) { try { TaskData taskData = fConnector.getTaskData(getTaskRepository(), task.getTaskId(), new NullProgressMonitor()); GerritTask gtask = new GerritTask(taskData); if (gtask.getAttribute(GerritTask.DATE_COMPLETION) == null) { fReviewTable.updateReviewItem(gtask); } } catch (CoreException e) { <START> StatusHandler.log(new Status(IStatus.ERROR, GerritCorePlugin.PLUGIN_ID, NLS.bind( "Unable to update the table ''{0}'' ", e))); <END> } } }</code><technical_language>This pass e.getMessage() instead of e</technical_language>

Target:
private synchronized void updateReview(TaskTask task) { String summary = task.getSummary(); boolean ourQuery = task.getParentContainers().contains(fCurrentQuery); if (ourQuery && summary != null && !summary.equals("")) { try { TaskData taskData = fConnector.getTaskData(getTaskRepository(), task.getTaskId(), new NullProgressMonitor()); GerritTask gtask = new GerritTask(taskData); if (gtask.getAttribute(GerritTask.DATE_COMPLETION) == null) { fReviewTable.updateReviewItem(gtask); } } catch (CoreException e) { StatusHandler.log(new Status(IStatus.ERROR, GerritCorePlugin.PLUGIN_ID, NLS.bind( "Unable to update the table ''{0}'' ", e.getMessage()))); } } }
Source:
<code>public boolean tryReserveMemory(String allocationTag, long delta, boolean enforceBroadcastMemoryLimit) { <START> if (enforceBroadcastMemoryLimit && !tryUpdateBroadcastMemoryFunction.test(delta)) { <END> return false; } return tryReserveMemoryFunction.test(allocationTag, delta); }</code><technical_language>put this tryReserveMemoryFunctinon.test()... local memory limit errors thrown</technical_language>

Target:
public boolean tryReserveMemory(String allocationTag, long delta, boolean enforceBroadcastMemoryLimit) { if (!tryReserveMemoryFunction.test(allocationTag, delta)) { return false; } return !enforceBroadcastMemoryLimit || tryUpdateBroadcastMemoryFunction.test(delta); }
Source:
<code>private void drawVertexLane(final SequenceSegment segment) { for (int index = 0; index <= lanes.size(); index++) { if (index >= lanes.size() || lanes.get(index) <= segment.getStart() && segmentFree(index, segment)) { segmentInsert(index, segment); String text = segment.getContent().toString(); <START> drawVertex(text, segment.getStart(), index, segment <END> .getContent().getLength(), segment.getSources().size(), sequenceColor(segment.getMutation())); break; } } }</code><technical_language>Bad readability; create intermediate variables for big arguments</technical_language>

Target:
private void drawVertexLane(final SequenceSegment segment) { String text = segment.getContent().toString(); long start = segment.getStart(); long width = segment.getContent().getLength(); long height = segment.getSources().size(); Color color = sequenceColor(segment.getMutation()); for (int index = 0; index < lanes.size(); index++) { if (lanes.get(index) <= segment.getStart() && segmentFree(index, segment)) { drawVertex(text, start, index, width, height, color); segmentInsert(index, segment); return; } } drawVertex(text, start, lanes.size(), width, height, color); segmentInsert(lanes.size(), segment); }
Source:
<code>public static String getMetricsJMXDomain(Map reporterConf) { <START> return Utils.getString(reporterConf.get(Config.STORM_DAEMON_METRICS_REPORTER_PLUGIN_DOMAIN), null); <END> }</code><technical_language>JMX_DOMAIN initially is Config.STORM_DAEMON_METRICS_REPORTER_PLUGIN_DOMAIN I stick JMX_DOMAIN config key @ptgoetz thinks this is good</technical_language>

Target:
public static String getMetricsJMXDomain(Map reporterConf) { return Utils.getString(reporterConf.get(JMX_DOMAIN), null); }
Source:
<code>private void initAllContentViews() { mLoginToMyAccountView = getLayoutInflater().inflate(R.layout.my_account, null); mUsername = mLoginToMyAccountView.findViewById(R.id.username); mPassword = mLoginToMyAccountView.findViewById(R.id.password); mPassword.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: <START> case KeyEvent.KEYCODE_ENTER: <END> login(); return true; default: break; } } return false; }); Button loginButton = mLoginToMyAccountView.findViewById(R.id.login_button); loginButton.setOnClickListener(v -> login()); Button resetPWButton = mLoginToMyAccountView.findViewById(R.id.reset_password_button); resetPWButton.setOnClickListener(v -> resetPassword()); Button signUpButton = mLoginToMyAccountView.findViewById(R.id.sign_up_button); Uri url = Uri.parse(getResources().getString(R.string.register_url)); signUpButton.setOnClickListener(v -> openUrl(url)); mLoggedIntoMyAccountView = getLayoutInflater().inflate(R.layout.my_account_logged_in, null); mUsernameLoggedIn = mLoggedIntoMyAccountView.findViewById(R.id.username_logged_in); Button logoutButton = mLoggedIntoMyAccountView.findViewById(R.id.logout_button); logoutButton.setOnClickListener(v -> logout()); }</code><technical_language>suggestion case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_NUMPAD_ENTER:</technical_language>

Target:
private void initAllContentViews() { mLoginToMyAccountView = getLayoutInflater().inflate(R.layout.my_account, null); mUsername = mLoginToMyAccountView.findViewById(R.id.username); mPassword = mLoginToMyAccountView.findViewById(R.id.password); mPassword.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_NUMPAD_ENTER: login(); return true; default: break; } } return false; }); Button loginButton = mLoginToMyAccountView.findViewById(R.id.login_button); loginButton.setOnClickListener(v -> login()); Button resetPWButton = mLoginToMyAccountView.findViewById(R.id.reset_password_button); resetPWButton.setOnClickListener(v -> resetPassword()); Button signUpButton = mLoginToMyAccountView.findViewById(R.id.sign_up_button); Uri url = Uri.parse(getResources().getString(R.string.register_url)); signUpButton.setOnClickListener(v -> openUrl(url)); mLoggedIntoMyAccountView = getLayoutInflater().inflate(R.layout.my_account_logged_in, null); mUsernameLoggedIn = mLoggedIntoMyAccountView.findViewById(R.id.username_logged_in); Button logoutButton = mLoggedIntoMyAccountView.findViewById(R.id.logout_button); logoutButton.setOnClickListener(v -> logout()); }
Source:
<code>public String makeValidTableName(String requestedName) { if ( StringHelper.isEmpty( requestedName ) ) { throw new org.hibernate.AssertionFailure( "qualifiedName is not expected to be null at this point" ); } else if ( requestedName.startsWith( "system." ) ) { throw log.collectionNameHasInvalidSystemPrefix( requestedName ); } else if ( requestedName.contains( "\u0000" ) ) { throw log.collectionNameContainsNULCharacter( requestedName ); } else if ( requestedName.contains( "$" ) ) { throw log.collectionNameContainsDollarCharacter( requestedName ); <START> } <END> return requestedName; }</code><technical_language>adapting ;-)</technical_language>

Target:
public String makeValidTableName(String requestedName) { Contracts.assertStringParameterNotEmpty( requestedName, "requestedName" ); if ( requestedName.startsWith( "system." ) ) { throw log.collectionNameHasInvalidSystemPrefix( requestedName ); } else if ( requestedName.contains( "\u0000" ) ) { throw log.collectionNameContainsNULCharacter( requestedName ); } else if ( requestedName.contains( "$" ) ) { throw log.collectionNameContainsDollarCharacter( requestedName ); } return requestedName; }
Source:
<code>public List<VDSGroup> getAllWithQuery(String query) { List<VDSGroup> groups = jdbcTemplate.query(query, VdsGroupRowMapper.instance); try { return getHostsAndVmsForClusters(groups); } catch (Exception e) { <START> log.error("Can't load host and vm count for vds group for query " + query, e); <END> } return groups; }</code><technical_language>vds group => cluster (we correct term in messages)</technical_language>

Target:
public List<VDSGroup> getAllWithQuery(String query) { List<VDSGroup> groups = jdbcTemplate.query(query, VdsGroupRowMapper.instance); try { return getHostsAndVmsForClusters(groups); } catch (Exception e) { log.error("Can't load host and vm count for cluster. Query is " + query, e); } return groups; }
Source:
<code>public void testFileReadingAndWriting() throws IOException { String randomizedTestString = TEST_STRING + System.currentTimeMillis(); for (String ext : TEST_FILE_EXTENSIONS) { File f = File.createTempFile(TEST_FILE_PREFIX, ext); IOUtil.assertFileIsReadable(f); <START> CodeUtil.applyIfNotNull(f,IOUtil::assertFileIsReadable); <END> f.deleteOnExit(); OutputStream os = IOUtil.openFileForWriting(f); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(randomizedTestString); writer.close(); InputStream is = IOUtil.openFileForReading(f); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine(); Assert.assertEquals(randomizedTestString, line); } }</code><technical_language>This is a strange test for this method... give test case in a new CodeUtilUnitTest class</technical_language>

Target:
public void testFileReadingAndWriting() throws IOException { String randomizedTestString = TEST_STRING + System.currentTimeMillis(); for (String ext : TEST_FILE_EXTENSIONS) { File f = File.createTempFile(TEST_FILE_PREFIX, ext); f.deleteOnExit(); OutputStream os = IOUtil.openFileForWriting(f); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(randomizedTestString); writer.close(); InputStream is = IOUtil.openFileForReading(f); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine(); Assert.assertEquals(randomizedTestString, line); } }
Source:
<code>public void close() { synchronized (lock) { if (!running) { return; } running = false; LOG.info("Closing {}.", this); <START> leaderElectorRunFuture.complete(null); <END> kubernetesWatch.close(); } }</code><technical_language>completing leaderElectorRunFuture here? is purpose of leaderElectorRunFuture</technical_language>

Target:
public void close() { if (!running) { return; } running = false; LOG.info("Closing {}.", this); leaderElector.stop(); kubernetesWatch.close(); }
Source:
<code>private ProcessOvfUpdateForStorageDomainCommandParameters createProcessOvfUpdateForDomainParams() { ProcessOvfUpdateForStorageDomainCommandParameters params = new ProcessOvfUpdateForStorageDomainCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId()); params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); params.setParentCommand(getParameters().getParentCommand()); <START> params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); <END> params.setParentParameters(getParameters().getParentParameters()); return params; }</code><technical_language>This set done in line 115</technical_language>

Target:
private ProcessOvfUpdateForStorageDomainCommandParameters createProcessOvfUpdateForDomainParams() { ProcessOvfUpdateForStorageDomainCommandParameters params = new ProcessOvfUpdateForStorageDomainCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId()); params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); params.setParentCommand(getParameters().getParentCommand()); params.setParentParameters(getParameters().getParentParameters()); return params; }
Source:
<code>public void clear() throws CacheAccessException { try { map.clear(); <START> currentUsageinBytes.set(0l); <END> } catch (RuntimeException re) { handleRuntimeException(re); } }</code><technical_language>not, I if alternatives worse? iterate mappings remove slightly worried performance impact</technical_language>

Target:
public void clear() throws CacheAccessException { try { long current = currentUsageinBytes.get(); map.clear(); current = currentUsageinBytes.addAndGet(-current); if(current < 0L) { currentUsageinBytes.addAndGet(current); } } catch (RuntimeException re) { handleRuntimeException(re); } }
Source:
<code>private void addBaseGroup(TargetEnvironment env) throws WdbaGlueException { SPSkyObject so = env.getPrimaryTargetFromAsterism(); if (so instanceof SPTarget) { final SPTarget spt = (SPTarget) so; if (isEmpty(spt.getName())) <START> spt.setName(TccNames.BASE); <END> add(new TargetConfig(spt, TccNames.BASE)); } if (so instanceof SPCoordinates) { add(new TargetConfig((SPCoordinates)so, TccNames.BASE)); } int pos = 1; for (UserTarget user : env.getUserTargets()) { final SPTarget t = user.target; if (isEmpty(t.getName())) { t.setName(TargetConfig.formatName("User", pos)); } ++pos; add(new TargetConfig(t, user.type.displayName)); } add(TargetGroupConfig.createBaseGroup(env)); }</code><technical_language>I this too, suggesting change necessarily, mutating target name a weird do here</technical_language>

Target:
private void addBaseGroup(TargetEnvironment env) throws WdbaGlueException { final SPSkyObject so = env.getSlewPositionObjectFromAsterism(); if (so instanceof SPTarget) { final SPTarget spt = (SPTarget) so; if (isEmpty(spt.getName())) spt.setName(TccNames.BASE); add(new TargetConfig(spt, TccNames.BASE)); } else if (so instanceof SPCoordinates) { add(new TargetConfig((SPCoordinates)so, TccNames.BASE)); } int pos = 1; for (UserTarget user : env.getUserTargets()) { final SPTarget t = user.target; if (isEmpty(t.getName())) { t.setName(TargetConfig.formatName("User", pos)); } ++pos; add(new TargetConfig(t, user.type.displayName)); } add(TargetGroupConfig.createBaseGroup(env)); }
Source:
<code>public void visitNode(Tree tree) { if (tree.is(Tree.Kind.TRY_STATEMENT)) { withinTry.push((TryStatementTree) tree); } else if (withinStandardTry() && ((NewClassTree) tree).symbolType().isSubtypeOf("java.lang.AutoCloseable") && !reported.contains(withinTry.peek())) { reported.add(withinTry.peek()); <START> reportIssue(withinTry.peek().tryKeyword(), "Change this \"try\" to a try-with-resources." + context.getJavaVersion().java7CompatibilityMessage()); <END> } }</code><technical_language>@benzonico current implementation is clear is of issue. create issue instantiated resource a message Change enclosing "try" a try-with-resources</technical_language>

Target:
public void visitNode(Tree tree) { if (tree.is(Tree.Kind.TRY_STATEMENT)) { withinTry.push((TryStatementTree) tree); toReport.push(new ArrayList<Tree>()); } else if (withinStandardTryWithFinally() && ((NewClassTree) tree).symbolType().isSubtypeOf("java.lang.AutoCloseable")) { toReport.peek().add(tree); } }
Source:
<code>public Expr toExpr() { <START> return new DoubleExpr(value == null ? null : (value).doubleValue()); <END> }</code><technical_language>unnecessary parentheses</technical_language>

Target:
public Expr toExpr() { return new DoubleExpr(value == null ? null : value.doubleValue()); }
Source:
<code>public Response findStaffMemberAddress(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) { StaffMember staffMember = userController.findStaffMemberById(staffMemberId); if (staffMember == null) { return Response.status(Status.NOT_FOUND).build(); } if (staffMember.getArchived()) { return Response.status(Status.NOT_FOUND).build(); } <START> if (!restSecurity.hasPermission(new String[] { UserPermissions.LIST_STAFFMEMBERADDRESES }, staffMember ) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson() )) { <END> return Response.status(Status.FORBIDDEN).build(); } Address address = commonController.findAddressById(id); if (address == null) { return Response.status(Status.NOT_FOUND).build(); } if (!address.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(objectFactory.createModel(address)).build(); }</code><technical_language>Wrong permission</technical_language>

Target:
public Response findStaffMemberAddress(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) { StaffMember staffMember = userController.findStaffMemberById(staffMemberId); if (staffMember == null) { return Response.status(Status.NOT_FOUND).build(); } if (staffMember.getArchived()) { return Response.status(Status.NOT_FOUND).build(); } if (!restSecurity.hasPermission(new String[] { UserPermissions.FIND_STAFFMEMBERADDRESS }, staffMember ) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson() )) { return Response.status(Status.FORBIDDEN).build(); } Address address = commonController.findAddressById(id); if (address == null) { return Response.status(Status.NOT_FOUND).build(); } if (!address.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(objectFactory.createModel(address)).build(); }
Source:
<code>public void addChild(Group parent, Group child, boolean broadcast) throws Exception { if (log.isTraceEnabled()) { Tools.logMethodIn( log, LogLevel.TRACE, "addChild", new Object[]{ "parent", parent, "child", child, "broadcast", broadcast } ); } org.picketlink.idm.api.Group parentGroup = null; String childPLGroupName = getPLIDMGroupName(child.getGroupName()); if (parent != null) { String parentPLGroupName = getPLIDMGroupName(parent.getGroupName()); try { parentGroup = getIdentitySession().getPersistenceManager(). findGroup(parentPLGroupName, orgService.getConfiguration().getGroupType(parent.getParentId())); } catch (Exception e) { log.info("Cannot obtain group: " + parentPLGroupName, e); <START> orgService.recoverFromIDMError(); <END> } ((ExtGroup)child).setId(parent.getId() + "/" + child.getGroupName()); } else { ((ExtGroup)child).setId("/" + child.getGroupName()); } if (broadcast) { preSave(child, true); } if (parentGroup != null) { ((ExtGroup)child).setParentId(parent.getId()); } org.picketlink.idm.api.Group childGroup = persistGroup(child); try { if (parentGroup != null) { getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup); } else { getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup); } } catch (Exception e) { log.info("Cannot associate groups: ", e); orgService.recoverFromIDMError(); } if (broadcast) { postSave(child, true); } }</code><technical_language>Original error transmitted</technical_language>

Target:
public void addChild(Group parent, Group child, boolean broadcast) throws Exception { if (log.isTraceEnabled()) { Tools.logMethodIn( log, LogLevel.TRACE, "addChild", new Object[]{ "parent", parent, "child", child, "broadcast", broadcast } ); } org.picketlink.idm.api.Group parentGroup = null; String childPLGroupName = getPLIDMGroupName(child.getGroupName()); if (parent != null) { String parentPLGroupName = getPLIDMGroupName(parent.getGroupName()); try { parentGroup = getIdentitySession().getPersistenceManager(). findGroup(parentPLGroupName, orgService.getConfiguration().getGroupType(parent.getParentId())); } catch (Exception e) { log.info("Cannot obtain group: " + parentPLGroupName, e); orgService.recoverFromIDMError(e); } ((ExtGroup)child).setId(parent.getId() + "/" + child.getGroupName()); } else { ((ExtGroup)child).setId("/" + child.getGroupName()); } if (broadcast) { preSave(child, true); } if (parentGroup != null) { ((ExtGroup)child).setParentId(parent.getId()); } org.picketlink.idm.api.Group childGroup = persistGroup(child); try { if (parentGroup != null) { getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup); } else { getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup); } } catch (Exception e) { log.info("Cannot associate groups: ", e); orgService.recoverFromIDMError(e); } if (broadcast) { postSave(child, true); } }
Source:
<code>private void updateAnnotationModelForRemoves(IAnnotationModel annotationModel) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (Annotation <START> fOccurrenceAnnotation : <END> fOccurrenceAnnotations) { annotationModel.removeAnnotation(fOccurrenceAnnotation); } } fOccurrenceAnnotations = null; }</code><technical_language>rename annotation</technical_language>

Target:
private void updateAnnotationModelForRemoves(IAnnotationModel annotationModel) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (Annotation annotation : fOccurrenceAnnotations) { annotationModel.removeAnnotation(annotation); } } fOccurrenceAnnotations = null; }
Source:
<code>protected void runPipeline(final JavaSparkContext ctx) { <START> if (! new HDF5Library().load(null)){ <END> throw new UserException.HardwareFeatureException("Cannot load the required HDF5 library"); } final ReadCountCollection analysisReadCounts = composeAnalysisReadCounts(); final List<String> targetNames = analysisReadCounts.targets().stream().map(Target::getName).collect(Collectors.toList()); final List<String> sampleNames = analysisReadCounts.columnNames(); final double[][] counts = analysisReadCounts.counts().getData(); final PCA pca = PCA.createPCA(targetNames, sampleNames, new Array2DRowRealMatrix(counts), SVDFactory::createSVD); try (final HDF5File output = new HDF5File(outputFile, HDF5File.OpenMode.CREATE)) { PCA.writeHDF5(pca, output); } catch (final GATKException ex) { throw new UserException.CouldNotCreateOutputFile(outputFile, ex); } }</code><technical_language>passing in null? passing in a tempdir use</technical_language>

Target:
protected void runPipeline(final JavaSparkContext ctx) { if (! new HDF5Library().load(null)){ throw new UserException.HardwareFeatureException("Cannot load the required HDF5 library. " + "HDF5 is currently supported on x86-64 architecture and Linux or OSX systems."); } final ReadCountCollection analysisReadCounts = composeAnalysisReadCounts(); final List<String> targetNames = analysisReadCounts.targets().stream().map(Target::getName).collect(Collectors.toList()); final List<String> sampleNames = analysisReadCounts.columnNames(); final double[][] counts = analysisReadCounts.counts().getData(); final PCA pca = PCA.createPCA(targetNames, sampleNames, new Array2DRowRealMatrix(counts), SVDFactory::createSVD); try (final HDF5File output = new HDF5File(outputFile, HDF5File.OpenMode.CREATE)) { PCA.writeHDF5(pca, output); } catch (final GATKException ex) { throw new UserException.CouldNotCreateOutputFile(outputFile, ex); } }
Source:
<code>private List<ColumnMetadata> loadColumns(ElasticsearchTableDescription table) { if (table.getColumns().isPresent()) { return buildMetadata(table.getColumns().get()); } List<ElasticsearchColumn> columns = buildColumns(table); <START> return buildMetadata(columns); <END> }</code><technical_language>inline columns</technical_language>

Target:
private List<ColumnMetadata> loadColumns(ElasticsearchTableDescription table) { if (table.getColumns().isPresent()) { return buildMetadata(table.getColumns().get()); } return buildMetadata(buildColumns(table)); }
Source:
<code>public void channelRead( ChannelHandlerContext ctx, Object msg ) { ByteBuf buf = (ByteBuf) msg; try { assertEncryptedIfRequired(); handshakeBuffer.writeBytes( buf, Math.min( buf.readableBytes(), handshakeBuffer.writableBytes() ) ); if ( handshakeBuffer.writableBytes() == 0 ) { if ( verifyBoltPreamble() ) { if ( performHandshake() ) { ctx.writeAndFlush( ctx.alloc().buffer( 4 ).writeInt( (int)protocol.version() ) ); protocol.install(); ctx.pipeline().remove( this ); if ( buf.readableBytes() > 0 ) { ctx.fireChannelRead( buf.readRetainedSlice( buf.readableBytes() ) ); } } else { <START> ctx.writeAndFlush( Unpooled.wrappedBuffer( new byte[]{0, 0, 0, 0} ) ).addListener( ChannelFutureListener.CLOSE ); <END> } } else { ctx.close(); } } } finally { buf.release(); } }</code><technical_language>ctx.alloc() instead of Unpooled</technical_language>

Target:
public void channelRead( ChannelHandlerContext ctx, Object msg ) { ByteBuf buf = (ByteBuf) msg; try { assertEncryptedIfRequired(); handshakeBuffer.writeBytes( buf, Math.min( buf.readableBytes(), handshakeBuffer.writableBytes() ) ); if ( handshakeBuffer.writableBytes() == 0 ) { if ( verifyBoltPreamble() ) { if ( performHandshake() ) { ctx.writeAndFlush( ctx.alloc().buffer( 4 ).writeInt( (int)protocol.version() ) ); protocol.install(); ctx.pipeline().remove( this ); if ( buf.readableBytes() > 0 ) { ctx.fireChannelRead( buf.readRetainedSlice( buf.readableBytes() ) ); } } else { ctx.writeAndFlush( ctx.alloc().buffer().writeBytes( new byte[]{0, 0, 0, 0} ) ).addListener( ChannelFutureListener.CLOSE ); } } else { ctx.close(); } } } finally { buf.release(); } }
Source:
<code>public void success(PageCombo pageCombo, Response response) { L.v(response.getUrl()); if (pageCombo.hasError()) { onError(); return; } final Page page = pageCombo.toPage(title); new SavePageTask(WikipediaApp.getInstance(), page.getTitle(), page).execute(); L.d("Downloaded page " + title.getDisplayText()); <START> onComplete(); <END> }</code><technical_language>this in callback of SavePageTask</technical_language>

Target:
public void success(PageCombo pageCombo, Response response) { L.v(response.getUrl()); if (pageCombo.hasError()) { onError(); return; } final Page page = pageCombo.toPage(title); new SavePageTask(WikipediaApp.getInstance(), page.getTitle(), page) { @Override public void onFinish(Boolean result) { L.d("Downloaded page " + title.getDisplayText()); onComplete(); } }.execute(); }
Source:
<code>public StructApi getPlatformStruct() { return new FakeStructApi( new ImmutableMap.Builder<String, Object>() <START> .put("ios_device", "ios_device") <END> .put("ios_simulator", "ios_simulator") .put("tvos_device", "tvos_device") .put("tvos_simulator", "tvos_simulator") .put("watchos_device", "watchos_device") .put("watchos_simulator", "watchos_simulator") .build()); }</code><technical_language>Please add macos :)</technical_language>

Target:
public StructApi getPlatformStruct() { return new FakeStructApi( new ImmutableMap.Builder<String, Object>() .put("ios_device", "ios_device") .put("ios_simulator", "ios_simulator") .put("macos", "macos") .put("tvos_device", "tvos_device") .put("tvos_simulator", "tvos_simulator") .put("watchos_device", "watchos_device") .put("watchos_simulator", "watchos_simulator") .build()); }
Source:
<code>private List<DiskImage> getAllDiskImagesInSrcAndDstToValidate() { List<DiskImage> allDiskImages = new ArrayList<>(); List<DiskImage> sourceImages = getSourceImages(); <START> sourceImages.stream().map(DiskImage::getImageId).forEach(d -> allDiskImages.addAll(diskImageDao.getAllSnapshotsForParent(d))); <END> allDiskImages.addAll(sourceImages); return allDiskImages; }</code><technical_language>avoid running a stored procedure in a loop DiskImageDao#getAllSnapshotsForParents</technical_language>

Target:
private List<DiskImage> getAllDiskImagesInSrcAndDstToValidate() { List<Guid> parentsIds = getSourceImages().stream().map(DiskImage::getImageId).collect(Collectors.toList()); List<DiskImage> allDiskImages = new ArrayList<>(diskImageDao.getAllSnapshotsForParents(parentsIds)); allDiskImages.addAll(getSourceImages()); return allDiskImages; }
Source:
<code>public void builderShouldThrowsExceptionIfFileDoesntExists() throws Exception { thrown.expect(FileNotFoundException.class); <START> thrown.expectMessage("File exists doesn't exists"); <END> DownloadBuilder.of(new File("/path/that/doesnt/exists")).build(); }</code><technical_language>2x "exists"</technical_language>

Target:
public void builderShouldThrowsExceptionIfFileDoesntExists() throws Exception { thrown.expect(FileNotFoundException.class); thrown.expectMessage("File picture.jpg doesn't exists"); DownloadBuilder.of(new File("/path/that/doesnt/exists/picture.jpg")).build(); }
Source:
<code>protected TaskResult run(TaskExecutionContext ctx, BqClient bq, String projectId) { List<BqOperation> operations = Stream.of( params.getListOrEmpty("delete_datasets", JsonNode.class).stream().map(this::deleteDataset), params.getListOrEmpty("empty_datasets", JsonNode.class).stream().map(this::emptyDataset), params.getListOrEmpty("create_datasets", JsonNode.class).stream().map(this::createDataset), params.getListOrEmpty("delete_tables", JsonNode.class).stream().map(this::deleteTable), params.getListOrEmpty("empty_tables", JsonNode.class).stream().map(this::emptyTable), params.getListOrEmpty("create_tables", JsonNode.class).stream().map(this::createTable)) .flatMap(s -> s) .collect(Collectors.toList()); int operation = state.params().get("operation", int.class, 0); for (int i = operation; i < operations.size(); i++) { state.params().set("operation", i); BqOperation o = operations.get(i); <START> pollingRetryExecutor(state, "retry") <END> .retryUnless(GoogleJsonResponseException.class, BqDdlOperatorFactory::isDeterministicException) .withErrorMessage("BiqQuery DDL operation failed") .runAction(s -> o.perform(bq, projectId)); } return TaskResult.empty(request); }</code><technical_language>[minor] other state key avoid confusion PollingRetryExecutor#RETRY</technical_language>

Target:
protected TaskResult run(TaskExecutionContext ctx, BqClient bq, String projectId) { List<BqOperation> operations = Stream.of( params.getListOrEmpty("delete_datasets", JsonNode.class).stream().map(this::deleteDataset), params.getListOrEmpty("empty_datasets", JsonNode.class).stream().map(this::emptyDataset), params.getListOrEmpty("create_datasets", JsonNode.class).stream().map(this::createDataset), params.getListOrEmpty("delete_tables", JsonNode.class).stream().map(this::deleteTable), params.getListOrEmpty("empty_tables", JsonNode.class).stream().map(this::emptyTable), params.getListOrEmpty("create_tables", JsonNode.class).stream().map(this::createTable)) .flatMap(s -> s) .collect(Collectors.toList()); int operation = state.params().get("operation", int.class, 0); for (int i = operation; i < operations.size(); i++) { state.params().set("operation", i); BqOperation o = operations.get(i); pollingRetryExecutor(state, "request") .retryUnless(GoogleJsonResponseException.class, BqDdlOperatorFactory::isDeterministicException) .withErrorMessage("BiqQuery DDL operation failed") .runAction(s -> o.perform(bq, projectId)); } return TaskResult.empty(request); }
Source:
<code>public GeneMongoBean mapLine(String line, int lineNumber) throws Exception { String[] lineSplit = line.split("\t"); String[] attributesSplit = lineSplit[8].split(";"); Map<String, String> attributes = new TreeMap<>(); for (String attribute : attributesSplit) { String[] keyValue = attribute.split(" "); String value = keyValue[keyValue.length - 1]; String valueWithoutQuotes = value.substring(1, value.length() - 1); attributes.put(keyValue[keyValue.length - 2], valueWithoutQuotes); } return new GeneMongoBean(attributes.get("gene_id"), attributes.get("gene_name"), lineSplit[2], lineSplit[0], <START> Integer.parseInt(lineSplit[3]), Integer.parseInt(lineSplit[4])); <END> }</code><technical_language>GTF represents transcripts, lines get "transcript_id" "transcript_name" instead of "gene_id" "gene_name". GeneMongoBean class renamed Feature FeatureCoordinates (it serialized other databases reference Mongo dropped)</technical_language>

Target:
public FeatureCoordinates mapLine(String line, int lineNumber) throws Exception { String[] lineSplit = line.split("\t"); String[] attributesSplit = lineSplit[8].split(";"); Map<String, String> attributes = new TreeMap<>(); for (String attribute : attributesSplit) { String[] keyValue = attribute.split(" "); int valueLength = keyValue[keyValue.length - 1].length(); attributes.put(keyValue[keyValue.length - 2], keyValue[keyValue.length - 1].substring(1, valueLength - 1)); } String feature = lineSplit[2]; return new FeatureCoordinates(attributes.get(feature + "_id"), attributes.get(feature + "_name"), feature, lineSplit[0], Integer.parseInt(lineSplit[3]), Integer.parseInt(lineSplit[4])); }
Source:
<code>public void start(final ServiceProvider serviceProvider) { final ManagementRegistryService managementRegistry = serviceProvider.getService(ManagementRegistryService.class); final EhcacheManager ehcacheManager = serviceProvider.getService(CacheManagerProviderService.class).getCacheManager(); final Context cmContext = managementRegistry.getConfiguration().getContext(); ehcacheManager.registerListener(new CacheManagerListener() { @Override public void cacheAdded(String alias, Cache<?, ?> cache) { } @Override public void cacheRemoved(String alias, Cache<?, ?> cache) { } @Override <START> @SuppressFBWarnings("SF_SWITCH_NO_DEFAULT") <END> public void stateTransition(Status from, Status to) { switch (to) { case AVAILABLE: delegates.put(cmContext, managementRegistry); break; case UNINITIALIZED: delegates.remove(cmContext); ehcacheManager.deregisterListener(this); break; } } }); }</code><technical_language>Default again</technical_language>

Target:
public void start(final ServiceProvider serviceProvider) { final ManagementRegistryService managementRegistry = serviceProvider.getService(ManagementRegistryService.class); final Context cmContext = managementRegistry.getConfiguration().getContext(); final EhcacheManager ehcacheManager = serviceProvider.getService(CacheManagerProviderService.class).getCacheManager(); ehcacheManager.registerListener(new CacheManagerListener() { @Override public void cacheAdded(String alias, Cache<?, ?> cache) { } @Override public void cacheRemoved(String alias, Cache<?, ?> cache) { } @Override public void stateTransition(Status from, Status to) { switch (to) { case AVAILABLE: delegates.put(cmContext, managementRegistry); break; case UNINITIALIZED: delegates.remove(cmContext); ehcacheManager.deregisterListener(this); break; case MAINTENANCE: break; default: throw new AssertionError(to); } } }); }
Source:
<code>private String copyProject(Long targetId, Long folderId) { SurveyGroup projectSource = surveyGroupDao.getByKey(targetId); <START> SurveyGroup projectCopy = new SurveyGroup(); <END> projectCopy.setCode(projectSource.getCode() + " copy"); projectCopy.setName(projectSource.getName() + " copy"); projectCopy.setMonitoringGroup(projectSource.getMonitoringGroup()); projectCopy.setParentId(folderId); SurveyGroup savedProjectCopy = surveyGroupDao.save(projectCopy); List<Survey> surveys = surveyDao.listSurveysByGroup(targetId); for (Survey survey : surveys) { SurveyDto surveyDto = new SurveyDto(); surveyDto.setCode(survey.getCode()); surveyDto.setName(survey.getName()); surveyDto.setSurveyGroupId(savedProjectCopy.getKey().getId()); Survey surveyCopy = SurveyUtils.copySurvey(survey, surveyDto); surveyCopy.setSurveyGroupId(savedProjectCopy.getKey().getId()); surveyDao.save(surveyCopy); } return "success"; }</code><technical_language>check if a projectSource avoid a NPE</technical_language>

Target:
private String copyProject(Long targetId, Long folderId) { SurveyGroup projectSource = surveyGroupDao.getByKey(targetId); if (projectSource == null) { logger.log(Level.WARNING, String.format("Failed to copy project %s to folder %s", targetId, folderId)); return "failed"; } SurveyGroup projectCopy = new SurveyGroup(); projectCopy.setCode(projectSource.getCode() + " copy"); projectCopy.setName(projectSource.getName() + " copy"); projectCopy.setMonitoringGroup(projectSource.getMonitoringGroup()); projectCopy.setParentId(folderId); SurveyGroup savedProjectCopy = surveyGroupDao.save(projectCopy); List<Survey> surveys = surveyDao.listSurveysByGroup(targetId); for (Survey survey : surveys) { SurveyDto surveyDto = new SurveyDto(); surveyDto.setCode(survey.getCode()); surveyDto.setName(survey.getName()); surveyDto.setSurveyGroupId(savedProjectCopy.getKey().getId()); Survey surveyCopy = SurveyUtils.copySurvey(survey, surveyDto); surveyCopy.setSurveyGroupId(savedProjectCopy.getKey().getId()); surveyDao.save(surveyCopy); } return "success"; }
Source:
<code>public void testUnmanagedEntityGcedOnUnmanageEvenIfEffectorInvoked() throws Exception { app = TestApplication.Factory.newManagedInstanceForTests(); BasicAttributeSensor<Object> byteArrayAttrib = new BasicAttributeSensor<Object>(Object.class, "test.byteArray", ""); <START> for (int i = 0; i < 200; i++) { <END> if (i<10 || i%10==0) LOG.info(JavaClassNames.niceClassAndMethod()+": iteration "+i); try { LOG.debug(JavaClassNames.niceClassAndMethod()+": iteration="+i); TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); entity.setAttribute(byteArrayAttrib, new BigObject(10*1000*1000)); entity.invoke(TestEntity.MY_EFFECTOR, ImmutableMap.<String,Object>of()).get(); Entities.destroy(entity); forceGc(); System.gc(); System.gc(); } catch (OutOfMemoryError e) { LOG.warn(JavaClassNames.niceClassAndMethod()+": OOME at iteration="+i); ExecutionManager em = app.getManagementContext().getExecutionManager(); Collection<Task<?>> tasks = ((BasicExecutionManager)em).getAllTasks(); LOG.info("TASKS count "+tasks.size()+": "+tasks); throw e; } } }</code><technical_language>I presume changed this is crazily slow test? If remove calls System.gc(); System.gc(); a lot faster. need call that</technical_language>

Target:
public void testUnmanagedEntityGcedOnUnmanageEvenIfEffectorInvoked() throws Exception { app = TestApplication.Factory.newManagedInstanceForTests(); BasicAttributeSensor<Object> byteArrayAttrib = new BasicAttributeSensor<Object>(Object.class, "test.byteArray", ""); for (int i = 0; i < 1000; i++) { if (i<100 && i%10==0 || i%100==0) LOG.info(JavaClassNames.niceClassAndMethod()+": iteration "+i); try { LOG.debug(JavaClassNames.niceClassAndMethod()+": iteration="+i); TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); entity.setAttribute(byteArrayAttrib, new BigObject(10*1000*1000)); entity.invoke(TestEntity.MY_EFFECTOR, ImmutableMap.<String,Object>of()).get(); Entities.unmanage(entity); forceGc(); } catch (OutOfMemoryError e) { LOG.warn(JavaClassNames.niceClassAndMethod()+": OOME at iteration="+i); ExecutionManager em = app.getManagementContext().getExecutionManager(); Collection<Task<?>> tasks = ((BasicExecutionManager)em).getAllTasks(); LOG.info("TASKS count "+tasks.size()+": "+tasks); throw e; } } }
Source:
<code>public void getDb() throws Exception { String dbName = "testdb"; TestDatabase.genTable(1, 2); mException.expect(NotFoundException.class); <START> mCatalog.getDatabase(dbName); <END> mCatalog.attachDatabase(NoopJournalContext.INSTANCE, TestUdbFactory.TYPE, "connect_URI", TestDatabase.TEST_UDB_NAME, dbName, Collections.emptyMap()); assertEquals(dbName, mCatalog.getDatabase(dbName).getDbName()); }</code><technical_language>similarly, lines this executed</technical_language>

Target:
public void getDb() throws Exception { String dbName = "testdb"; TestDatabase.genTable(1, 2); try { mCatalog.getDatabase(dbName); fail(); } catch (IOException e) { assertEquals("Database " + dbName + " does not exist", e.getMessage()); } mCatalog.attachDatabase(NoopJournalContext.INSTANCE, TestUdbFactory.TYPE, "connect_URI", TestDatabase.TEST_UDB_NAME, dbName, Collections.emptyMap()); assertEquals(dbName, mCatalog.getDatabase(dbName).getDbName()); }
Source:
<code>public void onConnect(Session wssession) { logger.debug("Connected to server"); session = wssession; connected = true; if (eventHandler != null) { <START> scheduler.submit(new Runnable() { <END> @Override public void run() { try { eventHandler.onConnectionOpened(uri); } catch (Exception e) { logger.error("Error handling onConnectionOpened() {}", e.getMessage(), e); } } }); } }</code><technical_language>lambda syntax here: scheduler.submit(() -> { try { eventHandler.onConnectionOpened(uri); } catch (Exception e) { logger.error("Error handling onConnectionOpened() {}", e.getMessage(), e); } });</technical_language>

Target:
public void onConnect(Session wssession) { logger.debug("Connected to server"); session = wssession; connected = true; if (eventHandler != null) { scheduler.submit(() -> { try { eventHandler.onConnectionOpened(uri); } catch (Exception e) { logger.error("Error handling onConnectionOpened() {}", e.getMessage(), e); } }); } }
Source:
<code>public void addLight (PointLight point, Set<CubemapSide> sides) { PointLightProperties plProperty = new PointLightProperties(); for (int i = 0; i < 6; i++) { CubemapSide cubemapSide = Cubemap.CubemapSide.values()[i]; if (sides.contains(cubemapSide)) { PerspectiveCamera camera = new PerspectiveCamera(90, 0, 0); camera.position.set(point.position); camera.direction.set(cubemapSide.direction); camera.up.set(cubemapSide.up); camera.near = 0.1f; <START> camera.far = 1000; <END> LightProperties p = new LightProperties(camera); plProperty.properties.put(cubemapSide, p); } } pointCameras.put(point, plProperty); }</code><technical_language>1f 100f so</technical_language>

Target:
public void addLight (PointLight point, Set<CubemapSide> sides) { PointLightProperties plProperty = new PointLightProperties(); for (int i = 0; i < 6; i++) { CubemapSide cubemapSide = Cubemap.CubemapSide.values()[i]; if (sides.contains(cubemapSide)) { PerspectiveCamera camera = new PerspectiveCamera(90, 0, 0); camera.position.set(point.position); camera.direction.set(cubemapSide.direction); camera.up.set(cubemapSide.up); camera.near = 1; camera.far = 100; LightProperties p = new LightProperties(camera); plProperty.properties.put(cubemapSide, p); } } pointCameras.put(point, plProperty); }
Source:
<code>public void handleFormSubmission(FormEntrySession session, HttpServletRequest submission) throws Exception{ lastSubmission = submission; String optedIn = Context.getAdministrationService().getGlobalProperty("htmlformentry.archiveHtmlForms","No"); if(Boolean.parseBoolean(optedIn)) { try { Patient patient = session.getPatient(); Encounter encounter = session.getEncounter(); SerializableFormObject formObject; if (patient != null && encounter != null) { formObject = new SerializableFormObject(session.getXmlDefinition(), submission.getParameterMap(), patient.getPatientIdentifier().getIdentifier(), patient.getUuid(), encounter.getUuid(),session.getHtmlFormId()); } else { <START> formObject = new SerializableFormObject(session.getXmlDefinition(), submission.getParameterMap(), <END> session.getHtmlFormId()); } if (formObject != null) { serializeFormData(formObject); } } finally { for (FormSubmissionControllerAction element : actions) { element.handleSubmission(session, submission); } } } else { for (FormSubmissionControllerAction element : actions) { element.handleSubmission(session, submission); } } }</code><technical_language>Sorry, I I asked this before, I forget... :) is case a patient encounter</technical_language>

Target:
public void handleFormSubmission(FormEntrySession session, HttpServletRequest submission) throws Exception{ lastSubmission = submission; String optedIn = Context.getAdministrationService().getGlobalProperty("htmlformentry.archiveHtmlForms","No"); if(Boolean.parseBoolean(optedIn)) { try { Patient patient = session.getPatient(); Encounter encounter = session.getEncounter(); SerializableFormObject formObject = null; if (patient != null && encounter != null) { formObject = new SerializableFormObject(session.getXmlDefinition(), submission.getParameterMap(), patient.getPatientIdentifier().getIdentifier(), patient.getUuid(), encounter.getUuid(),session.getHtmlFormId()); } else if(patient==null || encounter==null) { if(log.isDebugEnabled()) log.debug("Either patient or encounter or both are null"); formObject = new SerializableFormObject(session.getXmlDefinition(), submission.getParameterMap(), session.getHtmlFormId()); } if (formObject != null) { serializeFormData(formObject); } } finally { for (FormSubmissionControllerAction element : actions) { element.handleSubmission(session, submission); } } } else { for (FormSubmissionControllerAction element : actions) { element.handleSubmission(session, submission); } } }
Source:
<code>private boolean filter(Position position) { StringBuilder filterType = new StringBuilder(); if (filterInvalid(position)) { filterType.append("Invalid "); } if (filterZero(position)) { filterType.append("Zero "); } if (filterDuplicate(position)) { filterType.append("Duplicate "); } if (filterFuture(position)) { filterType.append("Future "); } if (filterApproximate(position)) { filterType.append("Approximate "); } if (filterStatic(position)) { filterType.append("Static "); } if (filterDistance(position)) { filterType.append("Distance "); } if (filterType.length() > 0 && !filterLimit(position)) { <START> StringBuilder logmsg = new StringBuilder(); <END> logmsg.append("Position filtered by "); logmsg.append(filterType.toString()); logmsg.append("filters from device: "); logmsg.append(Context.getIdentityManager().getDeviceById(position.getDeviceId()).getUniqueId()); logmsg.append(" with id: "); logmsg.append(position.getDeviceId()); Log.info(logmsg.toString()); return true; } return false; }</code><technical_language>Please proper name for variable. I "message" do</technical_language>

Target:
private boolean filter(Position position) { StringBuilder filterType = new StringBuilder(); if (filterInvalid(position)) { filterType.append("Invalid "); } if (filterZero(position)) { filterType.append("Zero "); } if (filterDuplicate(position)) { filterType.append("Duplicate "); } if (filterFuture(position)) { filterType.append("Future "); } if (filterApproximate(position)) { filterType.append("Approximate "); } if (filterStatic(position)) { filterType.append("Static "); } if (filterDistance(position)) { filterType.append("Distance "); } if (filterType.length() > 0 && !filterLimit(position)) { StringBuilder message = new StringBuilder(); message.append("Position filtered by "); message.append(filterType.toString()); message.append("filters from device: "); message.append(Context.getIdentityManager().getDeviceById(position.getDeviceId()).getUniqueId()); message.append(" with id: "); message.append(position.getDeviceId()); Log.info(message.toString()); return true; } return false; }
Source:
<code>public String getWebsocketEndpoint() { <START> return protocol + "://" + getHost() + ":" + getPort() + "/ws/"; <END> }</code><technical_language>correct. URI path ws/, assume be. This method simply return URI</technical_language>

Target:
public URI getWebsocketEndpoint() { return uri; }