auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void execute(JobExecutionContext context) throws JobExecutionException { String noteId = context.getJobDetail().getJobDataMap().getString("noteId"); Note note = notebook.getNote(noteId); note.runAll(); while (!note.isTerminated()) { try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.toString(), e); } } boolean releaseResource = false; try { Map<String, Object> config = note.getConfig(); if (config != null && config.containsKey("releaseresource")) { releaseResource = (boolean) note.getConfig().get("releaseresource"); } } catch (ClassCastException e) { logger.error(e.getMessage(), e); } if (releaseResource) { for (InterpreterSetting setting : notebook.getInterpreterSettingManager() .getInterpreterSettings(note.getId())) { try { notebook.getInterpreterSettingManager().restart(setting.getId()); } catch (InterpreterException e) { <START> logger.warn("Fail to resetart interpreter: " + setting.getId(), e); <END> } } } }</code><technical_language>I this error..</technical_language>

Target:
public void execute(JobExecutionContext context) throws JobExecutionException { String noteId = context.getJobDetail().getJobDataMap().getString("noteId"); Note note = notebook.getNote(noteId); note.runAll(); while (!note.isTerminated()) { try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.toString(), e); } } boolean releaseResource = false; try { Map<String, Object> config = note.getConfig(); if (config != null && config.containsKey("releaseresource")) { releaseResource = (boolean) note.getConfig().get("releaseresource"); } } catch (ClassCastException e) { logger.error(e.getMessage(), e); } if (releaseResource) { for (InterpreterSetting setting : notebook.getInterpreterSettingManager() .getInterpreterSettings(note.getId())) { try { notebook.getInterpreterSettingManager().restart(setting.getId()); } catch (InterpreterException e) { logger.error("Fail to restart interpreter: " + setting.getId(), e); } } } }
Source:
<code>private void togglePostLike() { if (!isAdded() || !hasPost() || !NetworkUtils.checkConnection(getActivity())) { return; } boolean isAskingToLike = !mPost.isLikedByCurrentUser; ReaderIconCountView likeCount = (ReaderIconCountView) getView().findViewById(R.id.count_likes); likeCount.setSelected(isAskingToLike); ReaderAnim.animateLikeButton(likeCount.getImageView(), isAskingToLike); boolean success = ReaderPostActions.performLikeAction(mPost, isAskingToLike); if (!success) { likeCount.setSelected(!isAskingToLike); return; } <START> mPost = ReaderPostTable.getPost(mPost.blogId, mPost.postId, false); <END> refreshLikes(); refreshIconCounts(); if (isAskingToLike) { AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_LIKED, mPost); } else { AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_UNLIKED, mPost); } }</code><technical_language>a big deal, curious this changed mPost.blogId mPost.postId</technical_language>

Target:
private void togglePostLike() { if (!isAdded() || !hasPost() || !NetworkUtils.checkConnection(getActivity())) { return; } boolean isAskingToLike = !mPost.isLikedByCurrentUser; ReaderIconCountView likeCount = (ReaderIconCountView) getView().findViewById(R.id.count_likes); likeCount.setSelected(isAskingToLike); ReaderAnim.animateLikeButton(likeCount.getImageView(), isAskingToLike); boolean success = ReaderPostActions.performLikeAction(mPost, isAskingToLike); if (!success) { likeCount.setSelected(!isAskingToLike); return; } mPost = ReaderPostTable.getBlogPost(mPost.blogId, mPost.postId, false); refreshLikes(); refreshIconCounts(); if (isAskingToLike) { AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_LIKED, mPost); } else { AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_UNLIKED, mPost); } }
Source:
<code>void close() { <START> closed = true; <END> if (!client.isOutputClosed()) { client .sendClose(WebSocket.NORMAL_CLOSURE, CLIENT_DISCONNECT_MESSAGE) .exceptionally(logWebSocketError("Failed to close")); } }</code><technical_language>If a websocket is closed properly client side, is a user send a bug report over? Secondarily, a pop-up message "failed close" helpful a user. If show error message a user, inform of happened do it. is real impact them, if need show message all</technical_language>

Target:
void close() { closed = true; if (client != null && !client.isOutputClosed()) { client .sendClose(WebSocket.NORMAL_CLOSURE, CLIENT_DISCONNECT_MESSAGE) .exceptionally(logWebSocketError(Level.INFO, "Failed to close")); } }
Source:
<code>private static boolean getWritePermission(int permission) { <START> return permission / 2 % 2 == 1; <END> }</code><technical_language>Similarly: java return permission & 2;</technical_language>

Target:
private static boolean getWritePermission(int permission) { return (permission & 2) == 2; }
Source:
<code>public Response addOrUpdateCompactionConfig( final DataSourceCompactionConfig newConfig, @PathParam("dataSource") String dataSource, @HeaderParam(AuditManager.X_DRUID_AUTHOR) @DefaultValue("") final String author, @HeaderParam(AuditManager.X_DRUID_COMMENT) @DefaultValue("") final String comment, @Context HttpServletRequest req ) { CoordinatorCompactionConfig current = manager.watch( CoordinatorCompactionConfig.CONFIG_KEY, CoordinatorCompactionConfig.class ).get(); final CoordinatorCompactionConfig newCompactionConfig; if (current != null) { final Map<String, DataSourceCompactionConfig> newConfigs = current .getCompactionConfigs() .stream() .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, Function.identity())); newConfigs.put(dataSource, newConfig); newCompactionConfig = CoordinatorCompactionConfig.from(current, ImmutableList.copyOf(newConfigs.values())); } else { newCompactionConfig = CoordinatorCompactionConfig.from(ImmutableList.of(newConfig)); } if (!manager.set( CoordinatorCompactionConfig.CONFIG_KEY, newCompactionConfig, new AuditInfo(author, comment, req.getRemoteAddr()) )) { <START> return Response.status(Response.Status.BAD_REQUEST).build(); <END> } return Response.ok().build(); }</code><technical_language>minor nit: same, please add more details for error if possible</technical_language>

Target:
public Response addOrUpdateCompactionConfig( final DataSourceCompactionConfig newConfig, @PathParam("dataSource") String dataSource, @HeaderParam(AuditManager.X_DRUID_AUTHOR) @DefaultValue("") final String author, @HeaderParam(AuditManager.X_DRUID_COMMENT) @DefaultValue("") final String comment, @Context HttpServletRequest req ) { CoordinatorCompactionConfig current = manager.watch( CoordinatorCompactionConfig.CONFIG_KEY, CoordinatorCompactionConfig.class ).get(); final CoordinatorCompactionConfig newCompactionConfig; if (current != null) { final Map<String, DataSourceCompactionConfig> newConfigs = current .getCompactionConfigs() .stream() .collect(Collectors.toMap(DataSourceCompactionConfig::getDataSource, Function.identity())); newConfigs.put(dataSource, newConfig); newCompactionConfig = CoordinatorCompactionConfig.from(current, ImmutableList.copyOf(newConfigs.values())); } else { newCompactionConfig = CoordinatorCompactionConfig.from(ImmutableList.of(newConfig)); } final SetResult setResult = manager.set( CoordinatorCompactionConfig.CONFIG_KEY, newCompactionConfig, new AuditInfo(author, comment, req.getRemoteAddr()) ); if (setResult.isOk()) { return Response.ok().build(); } else { return Response.status(Response.Status.BAD_REQUEST).build(); } }
Source:
<code>public void validateEnums(Host host) { if (host.isSetPowerManagement()) { if (host.getPowerManagement().isSetPmProxies()) { for (PmProxy proxy : host.getPowerManagement().getPmProxies().getPmProxy()) { validateEnum(PmProxyType.class, proxy.getType(), true); } } } if (host.isSetSsh()) { if (host.getSsh().isSetAuthenticationMethod()) { validateEnum(AuthenticationMethod.class, host.getSsh().getAuthenticationMethod(), true); } <START> } <END> }</code><technical_language>SshValidator class, validate Ssh entity, invoke HostValidator ActionValidator. critical</technical_language>

Target:
public void validateEnums(Host host) { if (host.isSetPowerManagement()) { if (host.getPowerManagement().isSetPmProxies()) { for (PmProxy proxy : host.getPowerManagement().getPmProxies().getPmProxy()) { validateEnum(PmProxyType.class, proxy.getType(), true); } } } if (host.isSetSsh()) { sshValidator.validateEnums(host.getSsh()); } }
Source:
<code>private List<PackageDescr> generatedResourcesToPackageDescr(Resource resource, List<PMMLResource> resources) throws DroolsParserException { <START> List<PackageDescr> pkgDescrs = new ArrayList<>(); <END> DrlParser parser = new DrlParser(configuration.getLanguageLevel()); for (PMMLResource res : resources) { for (String key: res.getRules().keySet()) { String src = res.getRules().get(key); PackageDescr descr = null; descr = parser.parse(false, src); if (descr != null) { descr.setResource(resource); pkgDescrs.add(descr); dumpGeneratedRule(descr,key,src); } else { addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0)); } } } return pkgDescrs; }</code><technical_language>Nitpicking: Please doublecheck if indentation in this method is tabs spaces. tabs used</technical_language>

Target:
private List<PackageDescr> generatedResourcesToPackageDescr(Resource resource, List<PMMLResource> resources) throws DroolsParserException { List<PackageDescr> pkgDescrs = new ArrayList<>(); DrlParser parser = new DrlParser(configuration.getLanguageLevel()); for (PMMLResource res : resources) { for (Map.Entry<String, String> entry: res.getRules().entrySet()) { String key = entry.getKey(); String src = entry.getValue(); PackageDescr descr = null; descr = parser.parse(false, src); if (descr != null) { descr.setResource(resource); pkgDescrs.add(descr); dumpGeneratedRule(descr,key,src); } else { addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0)); } } } return pkgDescrs; }
Source:
<code>public void handleCommand(ChannelUID channelUID, Command command) { if (command instanceof RefreshType) { logger.debug("Refreshing channel {}", channelUID); coapClient.asyncGet(this); return; } <START> logger.warn("The controller is a read-only device and cannot handle commands."); <END> }</code><technical_language>reduce debug</technical_language>

Target:
public void handleCommand(ChannelUID channelUID, Command command) { if (command instanceof RefreshType) { logger.debug("Refreshing channel {}", channelUID); coapClient.asyncGet(this); return; } logger.debug("The controller is a read-only device and cannot handle commands."); }
Source:
<code><START> protected void refreshContent(){ <END> if (FluxCUtils.isSignedInWPComOrHasWPOrgSite(mAccountStore, mSiteStore)) { List<SiteModel> visibleSites = mSiteStore.getVisibleSites(); if (visibleSites.size() == 0) { ToastUtils.showToast(this, R.string.cant_share_no_visible_blog, ToastUtils.Duration.LONG); finish(); } else if (visibleSites.size() == 1 && isSharingText()) { share(ShareAction.SHARE_TO_POST, visibleSites.get(0).getId()); }else { initShareFragment(false); } } else { ActivityLauncher.loginForShareIntent(this); } }</code><technical_language>Minor this method is a local helper, close private. Chances of ShareIntentReceiverActivity subclassed in future slim if open method. Usually, reading code encounter a protected (let public) method, expect find subclasses (or other classes) it. find classes tend is missing this method a relic a refactor. Again, big still, more clear if turn private. WDYT</technical_language>

Target:
private void refreshContent() { if (FluxCUtils.isSignedInWPComOrHasWPOrgSite(mAccountStore, mSiteStore)) { List<SiteModel> visibleSites = mSiteStore.getVisibleSites(); if (visibleSites.size() == 0) { ToastUtils.showToast(this, R.string.cant_share_no_visible_blog, ToastUtils.Duration.LONG); finish(); } else if (visibleSites.size() == 1 && isSharingText()) { share(ShareAction.SHARE_TO_POST, visibleSites.get(0).getId()); } else { initShareFragment(false); } } else { ActivityLauncher.loginForShareIntent(this); } }
Source:
<code>public void resolvePropertiesNotSetAndOverrideTrue() { <START> Map<String, String> originalProperties = new HashMap<>(); <END> originalProperties.put("foo", "bar"); Map<String, String> resolvedProperties = cloudHubArtifactDeployer.resolveProperties(originalProperties, null, true); assertThat("originalProperties should have the same size", resolvedProperties.size(), equalTo(1)); assertThat("resolvedProperties should contains the (foo,bar) entry", resolvedProperties, hasEntry("foo", "bar")); }</code><technical_language>Extract this a setUp method in a test _originalProperties_ a field</technical_language>

Target:
public void resolvePropertiesNotSetAndOverrideTrue() { Map<String, String> resolvedProperties = cloudHubArtifactDeployer.resolveProperties(originalProperties, null, true); assertThat("originalProperties should have the same size", resolvedProperties.size(), equalTo(1)); assertThat("resolvedProperties should contains the (foo,bar) entry", resolvedProperties, hasEntry("foo", "bar")); }
Source:
<code><START> public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix) { <END> return listIncompleteUploads(bucketName, prefix, true, true); }</code><technical_language>is problem of keeping throws XmlPullParserException</technical_language>

Target:
public Iterable<Result<Upload>> listIncompleteUploads(String bucketName, String prefix) throws XmlPullParserException { return listIncompleteUploads(bucketName, prefix, true, true); }
Source:
<code>private SimpleClientHttpRequestFactory streamingClientHttpRequestFactory() { val factory = new SimpleClientHttpRequestFactory(); <START> factory.setReadTimeout(properties.getReadTimeoutSeconds() * 1000); <END> factory.setConnectTimeout(properties.getConnectTimeoutSeconds() * 1000); factory.setOutputStreaming(true); factory.setBufferRequestBody(false); return factory; }</code><technical_language>this a no-op</technical_language>

Target:
private SimpleClientHttpRequestFactory streamingClientHttpRequestFactory() { val factory = new SimpleClientHttpRequestFactory(); System.setProperty("sun.net.client.defaultConnectTimeout", Long.toString(properties.getConnectTimeoutSeconds() * 1000)); System.setProperty("sun.net.client.defaultReadTimeout", Long.toString(properties.getReadTimeoutSeconds() * 1000)); factory.setOutputStreaming(true); factory.setBufferRequestBody(false); return factory; }
Source:
<code>public void renameContainer(final String containerId, final String name) throws DockerException, InterruptedException { WebTarget resource = resource() .path("containers").path(containerId).path("rename"); <START> if (name != null) { <END> checkArgument(CONTAINER_NAME_PATTERN.matcher(name).matches(), "Invalid container name: \"%s\"", name); resource = resource.queryParam("name", name); } log.info("Renaming container with id {}. New name {}.", containerId, name); try { request(POST, resource, resource.request()); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ContainerNotFoundException(containerId, e); case 409: throw new ContainerRenameConflictException(containerId, name, e); default: throw e; } } }</code><technical_language>name null? I thought [rename operation](<LINK_0> returned error if name parameter supplied</technical_language>

Target:
public void renameContainer(final String containerId, final String name) throws DockerException, InterruptedException { WebTarget resource = resource() .path("containers").path(containerId).path("rename"); if (name == null) { throw new IllegalArgumentException("Cannot rename container to null"); } checkArgument(CONTAINER_NAME_PATTERN.matcher(name).matches(), "Invalid container name: \"%s\"", name); resource = resource.queryParam("name", name); log.info("Renaming container with id {}. New name {}.", containerId, name); try { request(POST, resource, resource.request()); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ContainerNotFoundException(containerId, e); case 409: throw new ContainerRenameConflictException(containerId, name, e); default: throw e; } } }
Source:
<code>private void ingestChildren(ContentContainerObject destObj, Resource parentResc, AccessGroupSet groupSet) throws DepositException, IOException { NodeIterator iterator = getChildIterator(parentResc); if (iterator == null) { return; } try { while (iterator.hasNext()) { Resource childResc = (Resource) iterator.next(); if (childResc.hasProperty(RDF.type, Cdr.Folder)) { ingestFolder(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.Work)) { ingestWork(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.FileObject) <START> || !childResc.hasProperty(RDF.type)) { <END> if (destObj instanceof WorkObject) { ingestFileObject(destObj, parentResc, childResc); } else { ingestFileObjectAsWork(destObj, parentResc, childResc); } } else if (childResc.hasProperty(RDF.type, Cdr.Collection)) { ingestCollection(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.AdminUnit)) { ingestAdminUnit(destObj, parentResc, childResc, groupSet); } } } finally { iterator.close(); } }</code><technical_language>i this condition moved higher in block, a bunch of unnecessary calls of childResc.hasProperty(RDF.type)</technical_language>

Target:
private void ingestChildren(ContentContainerObject destObj, Resource parentResc, AccessGroupSet groupSet) throws DepositException, IOException { NodeIterator iterator = getChildIterator(parentResc); if (iterator == null) { return; } try { while (iterator.hasNext()) { Resource childResc = (Resource) iterator.next(); if (!childResc.hasProperty(RDF.type) || childResc.hasProperty(RDF.type, Cdr.FileObject)) { if (destObj instanceof WorkObject) { ingestFileObject(destObj, parentResc, childResc); } else { ingestFileObjectAsWork(destObj, parentResc, childResc); } } else if (childResc.hasProperty(RDF.type, Cdr.Folder)) { ingestFolder(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.Work)) { ingestWork(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.Collection)) { ingestCollection(destObj, parentResc, childResc, groupSet); } else if (childResc.hasProperty(RDF.type, Cdr.AdminUnit)) { ingestAdminUnit(destObj, parentResc, childResc, groupSet); } } } finally { iterator.close(); } }
Source:
<code>private void createVolumeFromSnapshot(HostVO hostVO, SnapshotInfo snapshotInfo, boolean keepGrantedAccess) { SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "tempVolume", "create"); try { snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null); } finally { _snapshotDetailsDao.remove(snapshotDetails.getId()); } CopyCmdAnswer copyCmdAnswer = performResignature(snapshotInfo, hostVO, keepGrantedAccess); if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) { if (copyCmdAnswer != null && !StringUtils.isEmpty(copyCmdAnswer.getDetails())) { throw new CloudRuntimeException(copyCmdAnswer.getDetails()); } else { <START> throw new CloudRuntimeException("Unable to perform host-side operation"); <END> } } }</code><technical_language>Please include more detail operation performed assist operational debugging</technical_language>

Target:
private void createVolumeFromSnapshot(HostVO hostVO, SnapshotInfo snapshotInfo, boolean keepGrantedAccess) { SnapshotDetailsVO snapshotDetails = handleSnapshotDetails(snapshotInfo.getId(), "tempVolume", "create"); try { snapshotInfo.getDataStore().getDriver().createAsync(snapshotInfo.getDataStore(), snapshotInfo, null); } finally { _snapshotDetailsDao.remove(snapshotDetails.getId()); } CopyCmdAnswer copyCmdAnswer = performResignature(snapshotInfo, hostVO, keepGrantedAccess); if (copyCmdAnswer == null || !copyCmdAnswer.getResult()) { if (copyCmdAnswer != null && !StringUtils.isEmpty(copyCmdAnswer.getDetails())) { throw new CloudRuntimeException(copyCmdAnswer.getDetails()); } else { throw new CloudRuntimeException("Unable to create volume from snapshot"); } } }
Source:
<code>static void handleHyperloglogLog2mOverride(BrokerRequest brokerRequest, int hllLog2mOverride) { if (brokerRequest.getAggregationsInfo() != null) { for (AggregationInfo aggregationInfo : brokerRequest.getAggregationsInfo()) { switch (AggregationFunctionType.valueOf(aggregationInfo.getAggregationType().toUpperCase())) { case DISTINCTCOUNTHLL: case DISTINCTCOUNTHLLMV: case DISTINCTCOUNTRAWHLL: case DISTINCTCOUNTRAWHLLMV: if (aggregationInfo.getExpressionsSize() == 1) { aggregationInfo.addToExpressions(Integer.toString(hllLog2mOverride)); } } } } <START> if (brokerRequest.getPinotQuery() != null && brokerRequest.getSelections() != null) { <END> for (Expression expr : brokerRequest.getPinotQuery().getSelectList()) { updateDistinctCountHllExpr(expr, hllLog2mOverride); } } }</code><technical_language>do need brokerRequest.getSelections() != null here? true for aggregation right</technical_language>

Target:
static void handleHyperloglogLog2mOverride(BrokerRequest brokerRequest, int hllLog2mOverride) { if (brokerRequest.getAggregationsInfo() != null) { for (AggregationInfo aggregationInfo : brokerRequest.getAggregationsInfo()) { switch (aggregationInfo.getAggregationType().toUpperCase()) { case "DISTINCTCOUNTHLL": case "DISTINCTCOUNTHLLMV": case "DISTINCTCOUNTRAWHLL": case "DISTINCTCOUNTRAWHLLMV": if (aggregationInfo.getExpressionsSize() == 1) { aggregationInfo.addToExpressions(Integer.toString(hllLog2mOverride)); } } } } if (brokerRequest.getPinotQuery() != null && brokerRequest.getPinotQuery().getSelectList() != null) { for (Expression expr : brokerRequest.getPinotQuery().getSelectList()) { updateDistinctCountHllExpr(expr, hllLog2mOverride); } } }
Source:
<code>public Player(float x, float y, float z, float width, float height, AnimationBundle bundle, CMouse mouse, CKeyboard keyboard, CGamePad gamepad){ traits.add(new PositionTrait(this, x, y, z)); traits.add(new SizeTrait(this, width, height)); traits.add(new DrawableTrait(this, new Sprite())); animator = new AnimatorTrait(this, bundle.getAnimations()); <START> animator.setState("basic"); <END> traits.add(animator); hitboxes = new TimedHitboxTrait(this, bundle.getHitboxes()); traits.add(hitboxes); traits.add(new ControlTrait(this, mouse, keyboard, gamepad)); CBody body = new PlayerBody(width, height).init(new Vector2(x, y)); physical = new PhysicalTrait(this, body); traits.add(physical); traits.add(new DebugTrait(this)); traits.add(new UpdatableTrait(this) { @Override public void update(float delta) { ((Player)self).update(delta); } }); initializeTraits(); body.setFriction(1); }</code><technical_language>this out</technical_language>

Target:
public Player(float x, float y, float z, float width, float height, AnimationBundle bundle, CMouse mouse, CKeyboard keyboard, CGamePad gamepad){ traits.add(new PositionTrait(this, x, y, z)); traits.add(new SizeTrait(this, width, height)); traits.add(new DrawableTrait(this, new Sprite())); animator = new AnimatorTrait(this, bundle.getAnimations()); traits.add(animator); hitboxes = new TimedHitboxTrait(this, bundle.getHitboxes()); traits.add(hitboxes); traits.add(new ControlTrait(this, mouse, keyboard, gamepad)); CBody body = new PlayerBody(width, height).init(new Vector2(x, y)); physical = new PhysicalTrait(this, body); traits.add(physical); traits.add(new DebugTrait(this)); traits.add(new UpdatableTrait(this) { @Override public void update(float delta) { ((Player)self).update(delta); } }); initializeTraits(); body.setFriction(1); }
Source:
<code>public ResponseEntity<Object> editLabel(@PathVariable("id") String id, @RequestParam("label") String label) { Map<String, Object> result = new HashMap<>(); result.put("action", "editLabel"); result.put("pid", id); PID pid = PIDs.get(id); try { service.editLabel(AgentPrincipals.createFromThread(), pid, label); } catch (Exception e) { result.put("error", e.getMessage()); Throwable t = e.getCause(); if (t instanceof AuthorizationException || t instanceof AccessRestrictionException) { return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } else { <START> log.error("Failed to edit label for due to {}", pid, e); <END> return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } } result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }</code><technical_language>want log stacktrace here, I want remove due part</technical_language>

Target:
public ResponseEntity<Object> editLabel(@PathVariable("id") String id, @RequestParam("label") String label) { Map<String, Object> result = new HashMap<>(); result.put("action", "editLabel"); result.put("pid", id); PID pid = PIDs.get(id); try { service.editLabel(AgentPrincipals.createFromThread(), pid, label); } catch (Exception e) { result.put("error", e.getMessage()); Throwable t = e.getCause(); if (t instanceof AuthorizationException || t instanceof AccessRestrictionException) { return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } else { log.error("Failed to edit label for {}", pid, e); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } } result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }
Source:
<code>public boolean isDynamic() throws <START> AlreadyExistsException <END> { try { return mGroup.isDynamic(); } catch (Exception e) { throw ExceptionWrapper.wrap(e); } }</code><technical_language>throws AlreadyExistsException ? weird</technical_language>

Target:
public boolean isDynamic() { try { return mGroup.isDynamic(); } catch (Exception e) { throw ExceptionWrapper.wrap(e); } }
Source:
<code>public void parsesInvalidLastNameField() 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( "linkedinTestUserInvalidLastName.json" ).getPath() ) ).readObject() ); MatcherAssert.assertThat( new PsLinkedin(memberprofilejson) .enter(REQUEST).next() .properties().get("last_name"), Matchers.is("?") ); }</code><technical_language>@ikhvostenkov please name json</technical_language>

Target:
public void parsesInvalidLastNameField() throws IOException { MatcherAssert.assertThat( new PsLinkedin( this.mockRequest( "linkedinTestUserInvalidLastName.json" ), "tapp", "tkey" ).enter(REQUEST).next() .properties().get("last_name"), Matchers.is("?") ); }
Source:
<code>protected List<FormItem> modifyFormItemsAfterCreation(PluginDescriptor focusedInfrastructurePlugin, PluginDescriptor focusedPolicyPlugin) { List<PluginDescriptor.Field> policyDynamicFields = focusedPolicyPlugin.getConfigurableFields() .stream() .filter(PluginDescriptor.Field::isDynamic) .collect(Collectors.toList()); List<PluginDescriptor.Field> infrastructureDynamicIFields = focusedInfrastructurePlugin.getConfigurableFields() .stream() .filter(PluginDescriptor.Field::isDynamic) .collect(Collectors.toList()); List<PluginDescriptor.Field> allDynamicFields = new LinkedList<>(); allDynamicFields.addAll(policyDynamicFields); allDynamicFields.addAll(infrastructureDynamicIFields); List<FormItem> allFormItemsWithHiddenFields = new LinkedList<>(); for (FormItem formItem : this.allFormItems) { allFormItemsWithHiddenFields.add(formItem); if (allDynamicFields.stream() .noneMatch(field -> isPartOfDynamicFields(focusedInfrastructurePlugin, focusedPolicyPlugin, formItem, field))) { if (this.allFormItemsPerPlugin.keySet() .stream() .anyMatch(pluginName -> formItem.getName().startsWith(pluginName)) || <START> formItem.getName().equals("infra") || formItem.getName().equals("policy")) { <END> disableNonDynamicItem(allFormItemsWithHiddenFields, formItem); } } } return allFormItemsWithHiddenFields; }</code><technical_language>Infra eaten</technical_language>

Target:
protected List<FormItem> modifyFormItemsAfterCreation(PluginDescriptor focusedInfrastructurePlugin, PluginDescriptor focusedPolicyPlugin) { List<PluginDescriptor.Field> policyDynamicFields = focusedPolicyPlugin.getConfigurableFields() .stream() .filter(PluginDescriptor.Field::isDynamic) .collect(Collectors.toList()); List<PluginDescriptor.Field> infrastructureDynamicIFields = focusedInfrastructurePlugin.getConfigurableFields() .stream() .filter(PluginDescriptor.Field::isDynamic) .collect(Collectors.toList()); List<PluginDescriptor.Field> allDynamicFields = new LinkedList<>(); allDynamicFields.addAll(policyDynamicFields); allDynamicFields.addAll(infrastructureDynamicIFields); List<FormItem> allFormItemsWithHiddenFields = new LinkedList<>(); for (FormItem formItem : this.allFormItems) { allFormItemsWithHiddenFields.add(formItem); if (allDynamicFields.stream() .noneMatch(field -> isPartOfDynamicFields(focusedInfrastructurePlugin, focusedPolicyPlugin, formItem, field))) { if (this.allFormItemsPerPlugin.keySet() .stream() .anyMatch(pluginName -> formItem.getName().startsWith(pluginName)) || formItem.getName().equals(INFRASTRUCTURE_FORM_KEY) || formItem.getName().equals(POLICY_FORM_KEY)) { disableNonDynamicItem(allFormItemsWithHiddenFields, formItem); } } } return allFormItemsWithHiddenFields; }
Source:
<code>private synchronized Optional<ConnectorId> getConnectorId(String catalogName) { Optional<Catalog> catalog = catalogByName.get(catalogName); if (catalog == null) { catalog = catalogManager.getCatalog(catalogName); catalogByName.put(catalogName, catalog); if (catalog.isPresent()) { registerCatalog(catalog.get()); } if (catalogManager.hasFederations(catalogName)) { Set<Optional<Catalog>> federatedCatalogs = catalogManager.getFederatedCatalogs(catalogName); if (!federatedCatalogs.stream().allMatch(Optional::isPresent)) { throw new IllegalStateException("Not all federated catalogs exist"); } <START> federatedCatalogs.forEach(federatedCatalog -> registerCatalog(federatedCatalog.get())); <END> } } return catalog.map(Catalog::getConnectorId); }</code><technical_language>This necessary. CatalogManager is injected. catalogs visible long installed</technical_language>

Target:
private synchronized Optional<ConnectorId> getConnectorId(String catalogName) { Optional<Catalog> catalog = catalogByName.get(catalogName); if (catalog == null) { catalog = catalogManager.getCatalog(catalogName); catalogByName.put(catalogName, catalog); if (catalog.isPresent()) { registerCatalog(catalog.get()); } if (companionCatalogs.containsKey(catalogName)) { Optional<Catalog> companionCatalog = catalogManager.getCatalog(companionCatalogs.get(catalogName)); checkArgument(companionCatalog.isPresent(), format("Invalid config, no catalog exists for catalog name %s: %s", catalogName, companionCatalogs.get(catalogName))); registerCatalog(companionCatalog.get()); } } return catalog.map(Catalog::getConnectorId); }
Source:
<code>public void testJavaScriptJsonString() throws ParseException { StringHolder pattern = new StringHolder(); <START> StringHolder input = new StringHolder("2019-01-18T12:42:03.409Z"); <END> pattern.setValue(IValueFormatConstants.DEFAULT_DATE_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input.getValue())); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input.getValue())); pattern.setValue(IValueFormatConstants.TIMESTAMP_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input.getValue())); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input.getValue())); pattern.setValue(IValueFormatConstants.TIMESTAMP_WITH_TIMEZONE_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input.getValue())); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input.getValue())); pattern.setValue(IValueFormatConstants.DATE_PATTERN); new SimpleDateFormat(pattern.getValue()).parse(input.getValue()); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input.getValue())); }</code><technical_language>input a standard String</technical_language>

Target:
public void testJavaScriptJsonString() throws ParseException { final StringHolder pattern = new StringHolder(); final String input = "2019-01-18T12:42:03.409Z"; pattern.setValue(IValueFormatConstants.DEFAULT_DATE_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input)); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input)); pattern.setValue(IValueFormatConstants.TIMESTAMP_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input)); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input)); pattern.setValue(IValueFormatConstants.TIMESTAMP_WITH_TIMEZONE_PATTERN); ScoutAssert.assertThrows(ParseException.class, () -> new SimpleDateFormat(pattern.getValue()).parse(input)); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input)); pattern.setValue(IValueFormatConstants.DATE_PATTERN); new SimpleDateFormat(pattern.getValue()).parse(input); ScoutAssert.assertThrows(ParseException.class, () -> new StrictSimpleDateFormat(pattern.getValue()).parse(input)); }
Source:
<code>public void evaluate() throws Throwable { IBeforeTest before = null; log.debug("Run before test extensions for test class " + testClass.getJavaClass().getName()); try { for (IBeforeTest bfr : befores) { before = bfr; if (before.hasToRun()){ log.debug("Run method runBeforeTest() of class " + before.getClass().getCanonicalName()); before.runBeforeTest(config, target, frameworkMethod); } } } catch (Throwable e) { <START> log.error("Run method runBeforeTest() of class " + before.getClass().getCanonicalName() + " failed", e); <END> if (isScreenshotRequired(e)) { createScreenshot("BeforeTestExt", before.getClass()); } throw e; } nextStatement.evaluate(); }</code><technical_language>move error log condition body</technical_language>

Target:
public void evaluate() throws Throwable { IBeforeTest before = null; log.debug("Run before test extensions for test class " + testClass.getJavaClass().getName()); try { for (IBeforeTest bfr : befores) { before = bfr; if (before.hasToRun()){ log.debug("Run method runBeforeTest() of class " + before.getClass().getCanonicalName()); before.runBeforeTest(config, target, frameworkMethod); } } } catch (Throwable e) { if(ScreenshotCapturer.shouldCaptureScreenshotOnException(e)){ log.error("Run method runBeforeTest() of class " + before.getClass().getCanonicalName() + " failed", e); createScreenshot("BeforeTestExt", before.getClass()); } throw e; } nextStatement.evaluate(); }
Source:
<code>public Pair<FilterExpression, FilterExpression> visitAndExpression(final AndFilterExpression expression) { Pair<FilterExpression, FilterExpression> left = expression.getLeft().accept(this); Pair<FilterExpression, FilterExpression> right = expression.getRight().accept(this); if (isWhereExpression(left) && isWhereExpression(right)) { return Pair.of( new AndFilterExpression( extractWhereExpression(left), extractWhereExpression(right) ), null ); } else if (isHavingExpression(left) && isWhereExpression(right)) { return Pair.of( <START> extractHavingExpression(left), <END> extractWhereExpression(right) ); } else if (isWhereExpression(left) && isHavingExpression(right)) { return Pair.of( extractWhereExpression(left), extractHavingExpression(right) ); } else { return Pair.of( AndFilterExpression.withLeftAndRight( extractWhereExpression(left), extractWhereExpression(right) ), AndFilterExpression.withLeftAndRight( extractHavingExpression(left), extractHavingExpression(right) ) ); } }</code><technical_language>I swapped</technical_language>

Target:
public FilterConstraints visitAndExpression(final AndFilterExpression expression) { FilterConstraints left = expression.getLeft().accept(this); FilterConstraints right = expression.getRight().accept(this); if (left.isPureWhere() && right.isPureWhere()) { return FilterConstraints.pureWhere( new AndFilterExpression( left.getWhereExpression(), right.getWhereExpression() ) ); } else if (left.isPureHaving() && right.isPureHaving()) { return FilterConstraints.pureHaving( new AndFilterExpression( left.getHavingExpression(), right.getHavingExpression() ) ); } else { return FilterConstraints.withWhereAndHaving( AndFilterExpression.fromPair( left.getWhereExpression(), right.getWhereExpression() ), AndFilterExpression.fromPair( left.getHavingExpression(), right.getHavingExpression() ) ); } }
Source:
<code>public MaxwellKinesisProducer(MaxwellContext context, String kinesisStream) { super(context); this.inflightMessages = new InflightMessageList(); this.kinesisStream = kinesisStream; <START> KinesisProducerConfiguration config = KinesisProducerConfiguration.fromPropertiesFile("kinesis-producer-library.properties"); <END> this.kinesisProducer = new KinesisProducer(config); }</code><technical_language>this crash if file exist? Is valid simply run kinesis extra configuration</technical_language>

Target:
public MaxwellKinesisProducer(MaxwellContext context, String kinesisStream) { super(context); String partitionKey = context.getConfig().producerPartitionKey; String partitionColumns = context.getConfig().producerPartitionColumns; String partitionFallback = context.getConfig().producerPartitionFallback; boolean kinesisMd5Keys = context.getConfig().kinesisMd5Keys; this.partitioner = new MaxwellKinesisPartitioner(partitionKey, partitionColumns, partitionFallback, kinesisMd5Keys); this.kinesisStream = kinesisStream; Path path = Paths.get("kinesis-producer-library.properties"); if(Files.exists(path) && Files.isRegularFile(path)) { KinesisProducerConfiguration config = KinesisProducerConfiguration.fromPropertiesFile(path.toString()); this.kinesisProducer = new KinesisProducer(config); } else { this.kinesisProducer = new KinesisProducer(); } }
Source:
<code>public String exec(String service, String action, String callbackId, String arguments) throws JSONException { if (arguments == null) { PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, "Null arguments"); <START> jsMessageQueue.addPluginResult(pluginResult, callbackId); <END> return jsMessageQueue.popAndEncode(); } jsMessageQueue.setPaused(true); try { boolean wasSync = pluginManager.exec(service, action, callbackId, arguments); String ret = ""; if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING || wasSync) { ret = jsMessageQueue.popAndEncode(); } return ret; } finally { jsMessageQueue.setPaused(false); } }</code><technical_language>a plugin result JS side distinguish this special-case actual plugin-response. Instead, I do: if (arguments == null) { return "null args"; }</technical_language>

Target:
public String exec(String service, String action, String callbackId, String arguments) throws JSONException { if (arguments == null) { return "@Null arguments."; } jsMessageQueue.setPaused(true); try { boolean wasSync = pluginManager.exec(service, action, callbackId, arguments); String ret = ""; if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING || wasSync) { ret = jsMessageQueue.popAndEncode(); } return ret; } finally { jsMessageQueue.setPaused(false); } }
Source:
<code>public Direction getFirstDirection() { switch (this.getMetadata()) { <START> case 0: case 5: case 8: case 9: return Direction.NORTH; case 1: case 3: return Direction.EAST; case 4: case 6: case 7: return Direction.SOUTH; case 2: <END> return Direction.WEST; default: throw new AssertionError(); } }</code><technical_language>of magic numbers need Constants in org.spongepowered.common.util.Constants, in a new nested class for Rail Directions whatever</technical_language>

Target:
public Direction getFirstDirection() { return Constants.RailDirections.getFirstDirection((BlockRailBase.EnumRailDirection) (Object) this); }
Source:
<code>public static void addInstagramExtensions(Activity activity, MediaFeedData item) { Map<String, Object> extensions = ensureExtensions(activity); addLocationExtension(activity, item); if(item.getLikes() != null) { Map<String, Object> likes = new HashMap<String, Object>(); likes.put("count", item.getLikes().getCount()); extensions.put("likes", likes); } extensions.put("hashtags", item.getTags()); Image standardResolution = new Image(); if(item.getType() == "image" && item.getImages() != null) { ImageData standardResolutionData = item.getImages().getStandardResolution(); standardResolution.setHeight((double)standardResolutionData.getImageHeight()); standardResolution.setWidth((double)standardResolutionData.getImageWidth()); standardResolution.setUrl(standardResolutionData.getImageUrl()); } else if(item.getType() == "video" && item.getVideos() != null) { VideoData standardResolutionData = item.getVideos().getStandardResolution(); standardResolution.setHeight((double)standardResolutionData.getHeight()); standardResolution.setWidth((double)standardResolutionData.getWidth()); standardResolution.setUrl(standardResolutionData.getUrl()); } <START> extensions.put("image", standardResolution); <END> }</code><technical_language>This extension, object directly</technical_language>

Target:
public static void addInstagramExtensions(Activity activity, MediaFeedData item) { Map<String, Object> extensions = ensureExtensions(activity); addLocationExtension(activity, item); if(item.getLikes() != null) { Map<String, Object> likes = new HashMap<String, Object>(); likes.put("count", item.getLikes().getCount()); extensions.put("likes", likes); } extensions.put("hashtags", item.getTags()); Comments comments = item.getComments(); String commentsConcat = ""; for(CommentData commentData : comments.getComments()) { commentsConcat += " " + commentData.getText(); } if(item.getCaption() != null) { commentsConcat += " " + item.getCaption().getText(); } extensions.put("keywords", commentsConcat); }
Source:
<code>private boolean connectFileStorageServers(StorageType storageType, List<StorageServerConnections> connections) { Map<StorageDomainType, List<StorageServerConnections>> connByType = connections.stream() .collect(Collectors.groupingBy(c -> storageDomainDao.getAllByConnectionId(Guid.createGuidFromString( c.getId())).get(0) .getStorageDomainType())); boolean connectSucceeded = connectStorageServer(storageType, connByType.get(StorageDomainType.Data), true); try { <START> connectStorageServer(storageType, connByType.get(StorageDomainType.ISO), false); connectStorageServer(storageType, connByType.get(StorageDomainType.ImportExport), false); <END> } catch (EngineException e) { log.info("Ignoring failed connection to domain of type ISO/Import-Export.'"); } return connectSucceeded; }</code><technical_language>1. if connecting iso domain fails exp, try connect ImportExport domain 2. worth adding a variable hold name of domain failed connect, log message domain failed connect. that: String domType = "ISO"; try { connect_to_iso; domType = "ImportExport"; connect_to_import)export; } catch (EngineExp e) { log.info("Ignoring ... of type {}", domType) }</technical_language>

Target:
private boolean connectFileStorageServers(StorageType storageType, List<StorageServerConnections> connections) { Map<StorageDomainType, List<StorageServerConnections>> connByType = connections.stream() .collect(Collectors.groupingBy(c -> storageDomainDao.getAllByConnectionId(Guid.createGuidFromString( c.getId())).get(0) .getStorageDomainType())); boolean connectSucceeded = connectStorageServer(storageType, connByType.get(StorageDomainType.Data), true); connectStorageServerIgnoreFailure(storageType, connByType.get(StorageDomainType.ISO), StorageDomainType.ISO); connectStorageServerIgnoreFailure(storageType, connByType.get(StorageDomainType.ImportExport), StorageDomainType.ImportExport); return connectSucceeded; }
Source:
<code>public Registration update(Registration registration) { Identity identity = this.identity != null ? this.identity : registration.getIdentity(); Link[] linkObject = this.objectLinks != null ? this.objectLinks : registration.getObjectLinks(); long lifeTimeInSec = this.lifeTimeInSec != null ? this.lifeTimeInSec : registration.getLifeTimeInSec(); BindingMode bindingMode = this.bindingMode != null ? this.bindingMode : registration.getBindingMode(); String smsNumber = this.smsNumber != null ? this.smsNumber : registration.getSmsNumber(); <START> Map<String, String> additionalAttributes = this.additionalAttributes != null <END> ? updateAdditionalAttributes(registration.getAdditionalRegistrationAttributes()) : registration.getAdditionalRegistrationAttributes(); Date lastUpdate = new Date(); Registration.Builder builder = new Registration.Builder(registration.getId(), registration.getEndpoint(), identity, registration.getRegistrationEndpointAddress()); builder.lwM2mVersion(registration.getLwM2mVersion()).lifeTimeInSec(lifeTimeInSec).smsNumber(smsNumber) .bindingMode(bindingMode).objectLinks(linkObject).registrationDate(registration.getRegistrationDate()) .lastUpdate(lastUpdate).additionalRegistrationAttributes(additionalAttributes); return builder.build(); }</code><technical_language>additionalAttributes null</technical_language>

Target:
public Registration update(Registration registration) { Identity identity = this.identity != null ? this.identity : registration.getIdentity(); Link[] linkObject = this.objectLinks != null ? this.objectLinks : registration.getObjectLinks(); long lifeTimeInSec = this.lifeTimeInSec != null ? this.lifeTimeInSec : registration.getLifeTimeInSec(); BindingMode bindingMode = this.bindingMode != null ? this.bindingMode : registration.getBindingMode(); String smsNumber = this.smsNumber != null ? this.smsNumber : registration.getSmsNumber(); Map<String, String> additionalAttributes = this.additionalAttributes.isEmpty() ? registration.getAdditionalRegistrationAttributes() : updateAdditionalAttributes(registration.getAdditionalRegistrationAttributes()); Date lastUpdate = new Date(); Registration.Builder builder = new Registration.Builder(registration.getId(), registration.getEndpoint(), identity, registration.getRegistrationEndpointAddress()); builder.lwM2mVersion(registration.getLwM2mVersion()).lifeTimeInSec(lifeTimeInSec).smsNumber(smsNumber) .bindingMode(bindingMode).objectLinks(linkObject).registrationDate(registration.getRegistrationDate()) .lastUpdate(lastUpdate).additionalRegistrationAttributes(additionalAttributes); return builder.build(); }
Source:
<code>public Set<RebalanceOperation> getRebalanceOperations() { synchronized (this.inProgressRebalanceOperationsLock) { <START> return new HashSet<>(this.inProgressRebalanceOperations); <END> } }</code><technical_language>unmodifiable set wrapped a concurrent map? of this. qualifier is necessary in this context</technical_language>

Target:
public Set<RebalanceOperation> getRebalanceOperations() { return Collections.unmodifiableSet(inProgressRebalanceOperations.keySet()); }