auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public String getProxyTicketIdFor(final String proxyGrantingTicketId, final String targetService) { try { <START> final String url = constructUrl(proxyGrantingTicketId, targetService); <END> final String response = CommonUtils.getResponseFromServer(new URL(url), this.urlConnectionFactory, this.encoding); final String error = XmlUtils.getTextForElement(response, "proxyFailure"); if (CommonUtils.isNotEmpty(error)) { logger.debug(error); return null; } return XmlUtils.getTextForElement(response, "proxyTicket"); } catch (final MalformedURLException ex) { throw new RuntimeException(ex); } }</code><technical_language>if this is a private method, return a URL this do try/catch in there? this pretty good</technical_language>

Target:
public String getProxyTicketIdFor(final String proxyGrantingTicketId, final String targetService) { CommonUtils.assertNotNull(proxyGrantingTicketId, "proxyGrantingTicketId cannot be null."); CommonUtils.assertNotNull(targetService, "targetService cannot be null."); final URL url = constructUrl(proxyGrantingTicketId, targetService); final String response = CommonUtils.getResponseFromServer(url, this.urlConnectionFactory, this.encoding); final String error = XmlUtils.getTextForElement(response, "proxyFailure"); if (CommonUtils.isNotEmpty(error)) { logger.debug(error); return null; } return XmlUtils.getTextForElement(response, "proxyTicket"); }
Source:
<code>public void waitForFinish() { try { shutdownLatch.await(); <START> } catch (Throwable t) { <END> log.error("Wait is interrupted by exception", t); throw new SamzaException(t); } }</code><technical_language>Catch exception</technical_language>

Target:
public void waitForFinish() { try { shutdownLatch.await(); } catch (Exception e) { log.error("Wait is interrupted by exception", e); throw new SamzaException(e); } }
Source:
<code>private void updateFilteringWarning() { final SharedPreferences p = SharedPrefsHelper.getSharedPrefs(MachineActivity.this); boolean filtering = p.getBoolean("filter", false); if(filterWarningBar == null) { filterWarningBar = Snackbar.make(mMainContent, "Only showing available machines.", Snackbar.LENGTH_INDEFINITE) .setAction("Show all", new View.OnClickListener() { @Override public void onClick(View v) { setFilter(false); } <START> }).setCallback(new Snackbar.Callback() { <END> @Override public void onDismissed(Snackbar snackbar, int event) { filterWarningBar = null; } @Override public void onShown(Snackbar snackbar) { } }); } if(filtering) { filterWarningBar.show(); } else { filterWarningBar.dismiss(); } }</code><technical_language>@vidia do</technical_language>

Target:
private void updateFilteringWarning() { final SharedPreferences p = SharedPrefsHelper.getSharedPrefs(MachineActivity.this); boolean filtering = p.getBoolean("filter", false); if(filterWarningBar == null) { filterWarningBar = Snackbar.make(mMainContent, "Only showing available machines.", Snackbar.LENGTH_INDEFINITE) .setAction("Show all", new View.OnClickListener() { @Override public void onClick(View v) { setFilter(false); } }) .addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() { @Override public void onDismissed(Snackbar transientBottomBar, int event) { super.onDismissed(transientBottomBar, event); filterWarningBar = null; } }); } if(filtering) { filterWarningBar.show(); } else { filterWarningBar.dismiss(); } }
Source:
<code>public void setControlling(boolean isControlling) { this.logger.info(() -> "Changing agent " + this.toString() + " role from controlling = " <START> + this.isControlling + " to controlling = " + isControlling); <END> this.isControlling = isControlling; for (IceMediaStream stream : getStreams()) { CheckList list = stream.getCheckList(); if (list != null) { list.recomputePairPriorities(); } } }</code><technical_language>this log for role changes (which is good), ordinary startup for a controlled node (which a lot of unnecessary noise)</technical_language>

Target:
public void setControlling(boolean isControlling) { if (this.isControlling != isControlling) { this.logger.info(() -> "Changing agent " + this.toString() + " role from controlling = " + this.isControlling + " to controlling = " + isControlling); } this.isControlling = isControlling; for (IceMediaStream stream : getStreams()) { CheckList list = stream.getCheckList(); if (list != null) { list.recomputePairPriorities(); } } }
Source:
<code>public static LogicalUnit map(LUNs entity, LogicalUnit template) { LogicalUnit model = template != null ? template : new LogicalUnit(); model.setId(entity.getLUN_id()); if (entity.getVendorId()!=null && !entity.getVendorId().isEmpty()) { model.setVendorId(entity.getVendorId()); } if (entity.getProductId()!=null && !entity.getProductId().isEmpty()) { model.setProductId(entity.getProductId()); } if (entity.getSerial()!=null && !entity.getSerial().isEmpty()) { model.setSerial(entity.getSerial()); } if (entity.getLunMapping()!=null) { model.setLunMapping(entity.getLunMapping()); } if (entity.getvolume_group_id() != null && !entity.getvolume_group_id().isEmpty()) { model.setVolumeGroupId(entity.getvolume_group_id()); } if (entity.getStorageDomainId() != null) { model.setStorageDomainId(entity.getStorageDomainId().toString()); } if (entity.getDiskId() != null) { model.setDiskId(entity.getDiskId().toString()); } if (entity.getStatus() != null) { <START> model.setStatus(entity.getStatus().name()); <END> } model.setSize(SizeConverter.gigasToBytes(entity.getDeviceSize())); model.setPaths(entity.getPathCount()); model.setPartitioned(entity.isPartitioned()); return model; }</code><technical_language>need map Backend enum equivalent Rest-API enum value, .value()</technical_language>

Target:
public static LogicalUnit map(LUNs entity, LogicalUnit template) { LogicalUnit model = template != null ? template : new LogicalUnit(); model.setId(entity.getLUN_id()); if (entity.getVendorId()!=null && !entity.getVendorId().isEmpty()) { model.setVendorId(entity.getVendorId()); } if (entity.getProductId()!=null && !entity.getProductId().isEmpty()) { model.setProductId(entity.getProductId()); } if (entity.getSerial()!=null && !entity.getSerial().isEmpty()) { model.setSerial(entity.getSerial()); } if (entity.getLunMapping()!=null) { model.setLunMapping(entity.getLunMapping()); } if (entity.getvolume_group_id() != null && !entity.getvolume_group_id().isEmpty()) { model.setVolumeGroupId(entity.getvolume_group_id()); } if (entity.getStorageDomainId() != null) { model.setStorageDomainId(entity.getStorageDomainId().toString()); } if (entity.getDiskId() != null) { model.setDiskId(entity.getDiskId().toString()); } if (entity.getStatus() != null) { model.setStatus(map(entity.getStatus(), null).value()); } model.setSize(SizeConverter.gigasToBytes(entity.getDeviceSize())); model.setPaths(entity.getPathCount()); return model; }
Source:
<code>public void progress() { if (!this.bPlayer.canBendIgnoreCooldowns(this)) { this.remove(); return; } if (System.currentTimeMillis() > this.getStartTime() + this.chargeTime && !this.charged) { this.charged = true; } if (!this.player.isSneaking()) { if (this.charged) { this.sphereBurst(); } else { this.remove(); } } else if (this.charged) { <START> final Location location = this.player.getEyeLocation().clone(); <END> location.add(location.getDirection().clone()); playFirebendingParticles(location, 1, .01, .01, .01); } }</code><technical_language>Cloning calling getEyeLocation is unnecessary</technical_language>

Target:
public void progress() { if (!this.bPlayer.canBendIgnoreCooldowns(this)) { this.remove(); return; } if (System.currentTimeMillis() > this.getStartTime() + this.chargeTime && !this.charged) { this.charged = true; } if (!this.player.isSneaking()) { if (this.charged) { this.sphereBurst(); } else { this.remove(); } } else if (this.charged) { final Location location = this.player.getEyeLocation(); location.add(location.getDirection()); playFirebendingParticles(location, 1, .01, .01, .01); } }
Source:
<code>private void cleanUpSuperfluousContainers(DockerClient client, Map<String, Node> nodeMap, ContainerNodeNameMap csm, DockerCloud dc, Instant snapshotInstant) { Collection<Container> allContainers = csm.getAllContainers(); for (Container container : allContainers) { String nodeName = csm.getNodeName(container.getId()); Node node = nodeMap.get(nodeName); if (node != null) { continue; } if (isStillTooYoung(container.getCreated(), snapshotInstant)) { continue; } <START> this.checkForTimeout(snapshotInstant); <END> LOGGER.info("Container {}, which is reported to be assigned to node {}, " + "is no longer associated (node might be gone already?). " + "The container's last status is {}; it was created on {}", container.getId(), nodeName, container.getStatus(), container.getCreated()); try { terminateContainer(dc, client, container); } catch (Exception e) { LOGGER.warn("Graceful termination of Container failed; terminating directly via API - this may cause remnants to be left behind", container.getId(), e); } } }</code><technical_language>Code style: This plugin code this necessary</technical_language>

Target:
private void cleanUpSuperfluousContainers(DockerClient client, Map<String, Node> nodeMap, ContainerNodeNameMap csm, DockerCloud dc, Instant snapshotInstant) { Collection<Container> allContainers = csm.getAllContainers(); for (Container container : allContainers) { String nodeName = csm.getNodeName(container.getId()); Node node = nodeMap.get(nodeName); if (node != null) { continue; } if (isStillTooYoung(container.getCreated(), snapshotInstant)) { continue; } checkForTimeout(snapshotInstant); LOGGER.info("Container {}, which is reported to be assigned to node {}, " + "is no longer associated (node might be gone already?). " + "The container's last status is {}; it was created on {}", container.getId(), nodeName, container.getStatus(), container.getCreated()); try { terminateContainer(dc, client, container); } catch (Exception e) { LOGGER.warn("Graceful termination of Container failed; terminating directly via API - this may cause remnants to be left behind", container.getId(), e); } } }
Source:
<code>public BPMNShapeFactory(final BasicShapesFactory basicShapesFactory, final SVGShapeFactory svgShapeFactory, final DelegateShapeFactory<BPMNDefinition, Shape> delegateShapeFactory, final ManagedInstance<WorkItemDefinitionRegistry> workItemDefinitionRegistry, final DefinitionUtils definitionUtils, final StunnerPreferencesRegistries preferencesRegistries) { this.basicShapesFactory = basicShapesFactory; this.svgShapeFactory = svgShapeFactory; this.delegateShapeFactory = delegateShapeFactory; <START> this.workItemDefinitionRegistry = () -> workItemDefinitionRegistry.get(); <END> this.definitionUtils = definitionUtils; this.preferencesRegistries = preferencesRegistries; }</code><technical_language>sure, replaced it, I prefer was, is matter of taste, needs revert</technical_language>

Target:
public BPMNShapeFactory(final BasicShapesFactory basicShapesFactory, final SVGShapeFactory svgShapeFactory, final DelegateShapeFactory<BPMNDefinition, Shape> delegateShapeFactory, final ManagedInstance<WorkItemDefinitionRegistry> workItemDefinitionRegistry, final DefinitionUtils definitionUtils, final StunnerPreferencesRegistries preferencesRegistries) { this.basicShapesFactory = basicShapesFactory; this.svgShapeFactory = svgShapeFactory; this.delegateShapeFactory = delegateShapeFactory; this.workItemDefinitionRegistry = workItemDefinitionRegistry::get; this.definitionUtils = definitionUtils; this.preferencesRegistries = preferencesRegistries; }
Source:
<code>MultiRange(List<Filter> filters, boolean nullAllowed) { super(nullAllowed); this.filters = filters.toArray(new Filter[0]); if (filters.get(0) instanceof BigintRange) { this.longLowerBounds = filters.stream() .mapToLong(filter -> ((BigintRange) filter).getLower()) .toArray(); <START> <END> long[] upperBounds = filters.stream() .mapToLong(filter -> ((BigintRange) filter).getUpper()) .toArray(); for (int i = 1; i < longLowerBounds.length; i++) { checkArgument(longLowerBounds[i] >= upperBounds[i - 1], "bigint ranges must not overlap"); } } else { this.longLowerBounds = null; } }</code><technical_language>a empty check for filters get(0)</technical_language>

Target:
MultiRange(List<Filter> filters, boolean nullAllowed) { super(nullAllowed); requireNonNull(filters, "filters is null"); checkArgument(filters.size() > 0, "filters is empty"); this.filters = filters.toArray(new Filter[0]); if (filters.get(0) instanceof BigintRange) { this.longLowerBounds = filters.stream() .mapToLong(filter -> ((BigintRange) filter).getLower()) .toArray(); long[] upperBounds = filters.stream() .mapToLong(filter -> ((BigintRange) filter).getUpper()) .toArray(); for (int i = 1; i < longLowerBounds.length; i++) { checkArgument(longLowerBounds[i] >= upperBounds[i - 1], "bigint ranges must not overlap"); } } else { this.longLowerBounds = null; } }
Source:
<code><START> public void clickCancel() { <END> String label = PropUtils.get("modals.window.cancel.label"); clickButton(label); }</code><technical_language>public, I say, private. If is required cancelAndDismissReloadRequiredWindow, improved in order for this method required public</technical_language>

Target:
protected void clickCancel() { String label = PropUtils.get("modals.window.cancel.label"); clickButton(label); }
Source:
<code>BaseVerification(Algorithm algorithm) throws IllegalArgumentException { if (algorithm == null) { throw new IllegalArgumentException("The Algorithm cannot be null."); } this.algorithm = algorithm; <START> this.claims = new HashMap<>(48); <END> this.defaultLeeway = 0; }</code><technical_language>magic numbers please. move a constant give a proper name/description</technical_language>

Target:
BaseVerification(Algorithm algorithm) throws IllegalArgumentException { if (algorithm == null) { throw new IllegalArgumentException("The Algorithm cannot be null."); } this.algorithm = algorithm; this.claims = new HashMap<>(); this.defaultLeeway = 0; }
Source:
<code>static void setProxyFromEnv() { <START> String envHttpProxy = System.getenv("HTTP_PROXY"); <END> if (envHttpProxy != null && !envHttpProxy.isEmpty()) { try { URL httpProxyUrl = new URL(envHttpProxy); String httpProxyHost = System.getProperty("http.proxyHost"); if ((httpProxyHost == null || httpProxyHost.isEmpty())) { System.setProperty("http.proxyHost", httpProxyUrl.getHost()); System.setProperty("http.proxyPort", Integer.toString( httpProxyUrl.getPort() == -1 ? httpProxyUrl.getDefaultPort() : httpProxyUrl.getPort())); } } catch (MalformedURLException e) { System.err.println("invalid http proxy configuration: " + e.getMessage()); System.exit(1); } } String envHttpsProxy = System.getenv("HTTPS_PROXY"); if (envHttpsProxy != null && !envHttpsProxy.isEmpty()) { try { URL httpsProxyUrl = new URL(envHttpsProxy); String httpsProxyHost = System.getProperty("https.proxyHost"); if ((httpsProxyHost == null || httpsProxyHost.isEmpty())) { System.setProperty("https.proxyHost", httpsProxyUrl.getHost()); System.setProperty("https.proxyPort", Integer.toString( httpsProxyUrl.getPort() == -1 ? httpsProxyUrl.getDefaultPort() : httpsProxyUrl.getPort())); } } catch (MalformedURLException e) { System.err.println("invalid https proxy configuration: " + e.getMessage()); System.exit(1); } } }</code><technical_language>this refactorable.. I CLI guava (implicitly), default parsing in HostAndPort. Next, I is worth parameterizing 's' logic completely copy/paste. ex. java setProxyHostAndPort("http", System.getenv("HTTP_PROXY")); setProxyHostAndPort("https", System.getenv("HTTPS_PROXY"));</technical_language>

Target:
static void setProxyFromEnv() { setProtocolProxyFromEnv("http", System.getenv("HTTP_PROXY")); setProtocolProxyFromEnv("https", System.getenv("HTTPS_PROXY")); }
Source:
<code>public void testServiceTopologyInitialized() throws Exception { IgniteEx loc = startGrids(NODES_CNT); IgniteEx rmt = grid(NODES_CNT - 1); <START> <END> fullMsgUnblockedLatch.countDown(); deployServices(loc); fullMsgHandledLatch.await(getTestTimeout(), MILLISECONDS); assertThrowsWithCause( () -> rmt.services().serviceProxy(BROKEN_SRVC, Invoker.class, false).invoke(), IgniteException.class); assertTrue(rmt.services().serviceProxy(DECENT_SRVC, Invoker.class, false).invoke()); }</code><technical_language>assertEquals(1, fullMsgUnblockedLatch.getCount());</technical_language>

Target:
public void testServiceTopologyInitialized() throws Exception { IgniteEx loc = startGrids(NODES_CNT); IgniteEx rmt = grid(NODES_CNT - 1); assertEquals(1, fullMsgUnblockedLatch.getCount()); fullMsgUnblockedLatch.countDown(); assertEquals(1, fullMsgHandledLatch.getCount()); deployServices(loc); assertTrue(fullMsgHandledLatch.await(getTestTimeout(), MILLISECONDS)); assertThrowsWithCause( () -> rmt.services().serviceProxy(BROKEN_SRVC, Invoker.class, false).invoke(), IgniteException.class); assertTrue(rmt.services().serviceProxy(DECENT_SRVC, Invoker.class, false).invoke()); }
Source:
<code>public synchronized void close() { try { if (properties.isSchemaPolicyCreateDrop()) { for (Map.Entry<String, MappedEntity> me : entities.entrySet()) { try { final PreparedStatement insert = me.getValue().getInsert(); final PreparedStatement insertReturning = me.getValue().getInsertReturning(); try { insert.executeBatch(); if (insertReturning != null) { insertReturning.executeBatch(); } } catch (SQLException ex) { logger.debug(String.format("Failed to flush before dropping entity '%s'", me.getValue().getEntity().getName()), ex); } finally { try { me.getValue().close(); } catch (Exception e) { <START> logger.trace("Could not close insert statements.", e); <END> } } dropEntity(me.getValue().getEntity()); } catch (DatabaseEngineException ex) { logger.debug(String.format("Failed to drop entity '%s'", me.getValue().getEntity().getName()), ex); } } } for (PreparedStatementCapsule ps : stmts.values()) { ps.ps.close(); } stmts.clear(); conn.close(); logger.debug("Connection to database closed"); } catch (SQLException ex) { logger.warn("Unable to close connection"); } }</code><technical_language>This is erroneous situation, gracefully exit, WARN logging instead. Also, refer insert statements for a "MappedEntity" (i.e, "custom" prepared statements below)</technical_language>

Target:
public synchronized void close() { try { for (final PreparedStatementCapsule preparedStatement : stmts.values()) { try { preparedStatement.ps.close(); } catch (final SQLException e) { logger.warn("Could not close statement.", e); } } stmts.clear(); entities.forEach((key, mappedEntity) -> closeMappedEntity(mappedEntity)); if (properties.isSchemaPolicyCreateDrop()) { dropAllEntities(); } conn.close(); logger.debug("Connection to database closed"); } catch (final SQLException ex) { logger.warn("Unable to close connection", ex); } }
Source:
<code>public void addTOC() { clearContent(); appendContent(PageContent.articleWithTOCline01); <START> appendNewLine(PageContent.articleWithTOCline02); <END> appendNewLine(PageContent.articleWithTOCline03); appendNewLine(PageContent.articleWithTOCline04); appendNewLine(PageContent.articleWithTOCline05); appendNewLine(PageContent.articleWithTOCline06); appendNewLine(PageContent.articleWithTOCline07); appendNewLine(PageContent.articleWithTOCline08); }</code><technical_language>Similar note above: do method call</technical_language>

Target:
public void addTOC() { clearContent(); appendContent(PageContent.articleWithTOClines); }
Source:
<code>public LoadType loadType() { <START> return null; <END> }</code><technical_language>if enum a option instead</technical_language>

Target:
public LoadType loadType() { throw new UnsupportedOperationException(); }
Source:
<code>public Set<SchemaTableName> filterTables(ConnectorTransactionHandle transactionHandle, Identity identity, Set<SchemaTableName> tableNames) { <START> return tableNames.stream().filter(tableName -> checkTablePermission(transactionHandle, identity, tableName, SELECT)).collect(Collectors.toSet()); <END> }</code><technical_language>of permissions, SELECT -- INSERT privileges, for example</technical_language>

Target:
public Set<SchemaTableName> filterTables(ConnectorTransactionHandle transactionHandle, Identity identity, Set<SchemaTableName> tableNames) { return tableNames.stream().filter(tableName -> checkAnyTablePermission(transactionHandle, identity, tableName)).collect(Collectors.toSet()); }
Source:
<code>public void actionPerformed(ActionEvent e) { <START> if (hasInstance() && MapillaryProperties.DEVELOPER.get() <END> && !getData().getMultiSelectedImages().isEmpty()) MapillaryRecord.getInstance().addCommand( new CommandDelete(getData().getMultiSelectedImages())); }</code><technical_language>Is reason requiring developer settings enabled for this</technical_language>

Target:
public void actionPerformed(ActionEvent e) { if (hasInstance() && !getData().getMultiSelectedImages().isEmpty()) MapillaryRecord.getInstance().addCommand( new CommandDelete(getData().getMultiSelectedImages())); }
Source:
<code>private static Trade createTrade1() { return FraConvention.of(IborIndex.of("USD-LIBOR-3M")).toTrade( <START> TradeInfo.builder() <END> .id(StandardId.of("example", "1")) .addAttribute(TradeAttributeType.DESCRIPTION, "0x3 FRA") .counterparty(StandardId.of("example", "A")) .settlementDate(LocalDate.of(2014, 9, 14)) .build(), LocalDate.of(2014, 9, 12), LocalDate.of(2014, 12, 12), LocalDate.of(2014, 9, 12), BuySell.SELL, 10_000_000, 0.0125); }</code><technical_language>this code, FRA FxSwap cases clearer conventions ;-( Please revert</technical_language>

Target:
private static Trade createTrade1() { Fra fra = Fra.builder() .buySell(BuySell.SELL) .index(IborIndices.USD_LIBOR_3M) .startDate(LocalDate.of(2014, 9, 12)) .endDate(LocalDate.of(2014, 12, 12)) .fixedRate(0.0125) .notional(10_000_000) .build(); return FraTrade.builder() .product(fra) .info(TradeInfo.builder() .id(StandardId.of("example", "1")) .addAttribute(TradeAttributeType.DESCRIPTION, "0x3 FRA") .counterparty(StandardId.of("example", "A")) .settlementDate(LocalDate.of(2014, 9, 14)) .build()) .build(); }
Source:
<code>public void setup() { schema = "S_"+generateUniqueName(); tableName = "T_"+generateUniqueName(); viewName = "V_"+generateUniqueName(); <START> viewIndex = "VI_"+generateUniqueName(); <END> indexName = "I_"+generateUniqueName(); inputTable = Mockito.mock(PTable.class); }</code><technical_language>viewName viewIndex in tests - testGetSourceTableName_index() testGetSourceTableName_viewIndex() instead of tableName. If not, consider removing them</technical_language>

Target:
public void setup() { schema = "S_" + generateUniqueName(); tableName = "T_" + generateUniqueName(); indexName = "I_" + generateUniqueName(); inputTable = Mockito.mock(PTable.class); }
Source:
<code>protected Message createMessage(Object objectToConvert, MessageProperties messageProperties, @Nullable Type genericType) throws MessageConversionException { byte[] bytes; try { <START> if (getDefaultCharset().equals("UTF-8")) { <END> bytes = this.objectMapper.writeValueAsBytes(objectToConvert); } else { String jsonString = this.objectMapper .writeValueAsString(objectToConvert); bytes = jsonString.getBytes(getDefaultCharset()); } } catch (IOException e) { throw new MessageConversionException("Failed to convert Message content", e); } messageProperties.setContentType(this.supportedContentType.toString()); messageProperties.setContentEncoding(getDefaultCharset()); messageProperties.setContentLength(bytes.length); if (getClassMapper() == null) { getJavaTypeMapper().fromJavaType(this.objectMapper.constructType( genericType == null ? objectToConvert.getClass() : genericType), messageProperties); } else { getClassMapper().fromClass(objectToConvert.getClass(), messageProperties); } return new Message(bytes, messageProperties); }</code><technical_language>is StandardCharsets.UTF_8.UTF_8 consider instead. defaultCharset property a Charset instance instead fail early if provided string representation is supported</technical_language>

Target:
protected Message createMessage(Object objectToConvert, MessageProperties messageProperties, @Nullable Type genericType) throws MessageConversionException { byte[] bytes; try { if (this.standardCharset) { bytes = this.objectMapper.writeValueAsBytes(objectToConvert); } else { String jsonString = this.objectMapper .writeValueAsString(objectToConvert); bytes = jsonString.getBytes(getDefaultCharset()); } } catch (IOException e) { throw new MessageConversionException("Failed to convert Message content", e); } messageProperties.setContentType(this.supportedContentType.toString()); messageProperties.setContentEncoding(getDefaultCharset()); messageProperties.setContentLength(bytes.length); if (getClassMapper() == null) { getJavaTypeMapper().fromJavaType(this.objectMapper.constructType( genericType == null ? objectToConvert.getClass() : genericType), messageProperties); } else { getClassMapper().fromClass(objectToConvert.getClass(), messageProperties); } return new Message(bytes, messageProperties); }
Source:
<code>public void visitCompilationUnit(CompilationUnitTree tree) { exclusions.clear(); super.visitCompilationUnit(tree); for (Scope scope : context().symbolTable().getScopes()) { <START> if (scope.tree() instanceof FunctionTree) { <END> checkScope(scope); } } }</code><technical_language>@vilchik-elena preferable check kind</technical_language>

Target:
public void visitCompilationUnit(CompilationUnitTree tree) { exclusions.clear(); super.visitCompilationUnit(tree); for (Scope scope : context().symbolTable().getScopes()) { if (scope.tree().is(Kind.FUNCTION_EXPRESSION, Kind.FUNCTION_DECLARATION, Kind.METHOD_DECLARATION)) { checkScope(scope); } } }
Source:
<code>public boolean isSpatialJoin() { <START> return (type == INNER || type == LEFT) && criteria.isEmpty() && filter.isPresent() && isSpatialJoinFilter(left, right, filter.get()); <END> }</code><technical_language>I this idea move here. this method is invoked Rule's do is worth lazy-cache this expression result</technical_language>

Target:
public boolean isSpatialJoin() { if (spatialJoin.isPresent()) { return spatialJoin.get(); } spatialJoin = Optional.of((type == INNER || type == LEFT) && criteria.isEmpty() && filter.isPresent() && isSpatialJoinFilter(left, right, filter.get())); return spatialJoin.get(); }
Source:
<code>public void testMain() { try { <START> Assert.assertTrue( true ); <END> } catch ( final Exception e ) { Assert.fail( "Exception occured: " + e ); } }</code><technical_language>is this for? Feels some unintended checked in code</technical_language>

Target:
public void testMain() { try { StringUtil.main( null ); Assert.assertTrue( true ); } catch ( final Exception e ) { Assert.fail( "Exception occured: " + e ); } }
Source:
<code>public List<WebElement> findElements() { if (cachedElementList != null && shouldCache) { return cachedElementList; } List<WebElement> result; try { result = waitFor(() -> { List<WebElement> list = searchContext .findElements(getBy(by, searchContext)); <START> if (list.size() > 0) { <END> return list; } return null; }); } catch (TimeoutException | StaleElementReferenceException e) { result = new ArrayList<>(); } if (shouldCache) { cachedElementList = result; } return result; }</code><technical_language>return list.size() > 0 ? list : null</technical_language>

Target:
public List<WebElement> findElements() { if (cachedElementList != null && shouldCache) { return cachedElementList; } List<WebElement> result; try { result = waitFor(() -> { List<WebElement> list = searchContext .findElements(getBy(by, searchContext)); return list.size() > 0 ? list : null; }); } catch (TimeoutException | StaleElementReferenceException e) { result = new ArrayList<>(); } if (shouldCache) { cachedElementList = result; } return result; }
Source:
<code>public boolean canExecute(ITmfTrace trace) { <START> return (CtfTmfTraceStub.class.isAssignableFrom(trace.getClass())); <END> }</code><technical_language>In plugin.xml, TmfTraceStub check for CtfTmfTraceStub, is coherent (even I fail elegantly)</technical_language>

Target:
public boolean canExecute(ITmfTrace trace) { return (TmfTraceStub.class.isAssignableFrom(trace.getClass())); }
Source:
<code>public static void toJSON(OutputWriter outputWriter, StageInstanceModel stageInstanceModel) { if (stageInstanceModel.getResult() != null) { outputWriter.add("result", stageInstanceModel.getResult().toString()); } if (stageInstanceModel.getRerunOfCounter() == null) { <START> outputWriter.add("rerun_of_counter", "null"); <END> } else { outputWriter.add("rerun_of_counter", stageInstanceModel.getRerunOfCounter()); } outputWriter.add("id", stageInstanceModel.getId()) .add("name", stageInstanceModel.getName()) .add("counter", stageInstanceModel.getCounter()) .add("scheduled", stageInstanceModel.isScheduled()) .add("approval_type", stageInstanceModel.getApprovalType()) .add("approved_by", stageInstanceModel.getApprovedBy()) .add("operate_permission", stageInstanceModel.hasOperatePermission()) .add("can_run", stageInstanceModel.getCanRun()) .addChildList("jobs", jobsWriter -> stageInstanceModel.getBuildHistory() .forEach(jobHistoryItem -> jobsWriter.addChild(jobWriter -> JobHistoryItemRepresenter.toJSON(jobWriter, jobHistoryItem)))); }</code><technical_language>adding a string "null" render a string in JSON (not null value)</technical_language>

Target:
public static void toJSON(OutputWriter outputWriter, StageInstanceModel stageInstanceModel) { if (stageInstanceModel.getResult() != null) { outputWriter.add("result", stageInstanceModel.getResult().toString()); } if (stageInstanceModel.getRerunOfCounter() == null) { outputWriter.renderNull("rerun_of_counter"); } else { outputWriter.add("rerun_of_counter", stageInstanceModel.getRerunOfCounter()); } outputWriter.add("id", stageInstanceModel.getId()) .add("name", stageInstanceModel.getName()) .add("counter", stageInstanceModel.getCounter()) .add("scheduled", stageInstanceModel.isScheduled()) .add("approval_type", stageInstanceModel.getApprovalType()) .add("approved_by", stageInstanceModel.getApprovedBy()) .add("operate_permission", stageInstanceModel.hasOperatePermission()) .add("can_run", stageInstanceModel.getCanRun()) .addChildList("jobs", jobsWriter -> stageInstanceModel.getBuildHistory() .forEach(jobHistoryItem -> jobsWriter.addChild(jobWriter -> JobHistoryItemRepresenter.toJSON(jobWriter, jobHistoryItem)))); }
Source:
<code>public FetcherThread(Config conf, int num) { this.setDaemon(true); this.setName("FetcherThread #" + num); this.maxCrawlDelay = ConfUtils.getInt(conf, "fetcher.max.crawl.delay", 30) * 1000; <START> this.crawlDelay = (long) (ConfUtils.getFloat(conf, <END> "fetcher.server.delay", 1.0f) * 1000); this.threadNum = num; }</code><technical_language>need read this instead fiq.crawlDelay do in line 534</technical_language>

Target:
public FetcherThread(Config conf, int num) { this.setDaemon(true); this.setName("FetcherThread #" + num); this.maxCrawlDelay = ConfUtils.getInt(conf, "fetcher.max.crawl.delay", 30) * 1000; this.maxCrawlDelayForce = ConfUtils.getBoolean(conf, "fetcher.max.crawl.delay.force", false); this.crawlDelayForce = ConfUtils.getBoolean(conf, "fetcher.server.delay.force", false); this.threadNum = num; }
Source:
<code>private static String findPath(IAdaptable adaptable) { String result = null; final IResourceVariant variant = (IResourceVariant)adaptable.getAdapter(IResourceVariant.class); if (variant != null) { try { <START> IStorage storage = <END> variant.getStorage(new NullProgressMonitor()); final Object adapter = Platform.getAdapterManager().loadAdapter(storage, IStoragePathProvider.class.getName()); if (adapter instanceof IStoragePathProvider) { IPath computeFixedPath = ((IStoragePathProvider)adapter).computeFixedPath(storage); result = computeFixedPath.toString(); } else if (variant instanceof CachedResourceVariant) { result = ((CachedResourceVariant)variant).getDisplayPath().toString(); } else if (storage instanceof IFile) { result = storage.getFullPath().toString(); } } catch (TeamException e) { } } return result; }</code><technical_language>storage final checkstyle guidelines (which deactivated in this plug-in though). Anyways, I stick possible</technical_language>

Target:
private static String findPath(IAdaptable adaptable) { String result = null; final IResourceVariant variant = (IResourceVariant)adaptable.getAdapter(IResourceVariant.class); if (variant != null) { try { final IStorage storage = variant.getStorage(new NullProgressMonitor()); final Object adapter = Platform.getAdapterManager().loadAdapter(storage, IStoragePathProvider.class.getName()); if (adapter instanceof IStoragePathProvider) { final IPath fixedPath = ((IStoragePathProvider)adapter).computeFixedPath(storage); result = fixedPath.toString(); } else if (variant instanceof CachedResourceVariant) { result = ((CachedResourceVariant)variant).getDisplayPath().toString(); } else if (storage instanceof IFile) { result = storage.getFullPath().toString(); } } catch (TeamException e) { } } return result; }
Source:
<code>public List<Certificate> getEntitlementCertificates( @PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid, @QueryParam("serials") String serials) { log.debug("Getting client certificates for consumer: {}", consumerUuid); Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid); poolManager.regenerateDirtyEntitlements(consumer); Set<Long> serialSet = this.extractSerials(serials); List<Certificate> returnCerts = new LinkedList<Certificate>(); List<EntitlementCertificate> allCerts = entCertService .listForConsumer(consumer); for (EntitlementCertificate cert : allCerts) { if (serialSet.isEmpty() || serialSet.contains(cert.getSerial().getId())) { returnCerts.add(cert); } } if (consumer.getContentAccessCert() != null) { try { returnCerts.add(contentAccessCertService.getCertificate(consumer)); } catch (IOException ioe) { <START> throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate.")); <END> } catch (GeneralSecurityException gse) { throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate.")); } } return returnCerts; }</code><technical_language>If wrapping exception, please embed original exception</technical_language>

Target:
public List<Certificate> getEntitlementCertificates( @PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid, @QueryParam("serials") String serials) { log.debug("Getting client certificates for consumer: {}", consumerUuid); Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid); checkForGuestMigration(consumer); poolManager.regenerateDirtyEntitlements(consumer); Set<Long> serialSet = this.extractSerials(serials); List<Certificate> returnCerts = new LinkedList<Certificate>(); List<EntitlementCertificate> allCerts = entCertService .listForConsumer(consumer); for (EntitlementCertificate cert : allCerts) { if (serialSet.isEmpty() || serialSet.contains(cert.getSerial().getId())) { returnCerts.add(cert); } } if (!consumer.getOwner().contentAccessMode() .equals(ContentAccessCertServiceAdapter.DEFAULT_CONTENT_ACCESS_MODE)) { try { Certificate cert = contentAccessCertService.getCertificate(consumer); if (cert != null) { returnCerts.add(cert); } } catch (IOException ioe) { throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate"), ioe); } catch (GeneralSecurityException gse) { throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate"), gse); } } return returnCerts; }
Source:
<code>public void run() { String operationResult = null; Exception exception = null; try { String blobId = new BlobId(BlobId.DEFAULT_FLAG, ClusterMapUtils.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, getPartitionForPut()).getID(); if (blobs.containsKey(blobId)) { exception = new RouterException("Blob ID duplicate created.", RouterErrorCode.UnexpectedInternalError); } ByteBuffer blobData = readBlob(postData.getReadableStreamChannel()); InMemoryRouter.InMemoryBlob blob = new InMemoryRouter.InMemoryBlob(postData.getBlobProperties(), postData.getUsermetadata(), blobData); blobs.put(blobId, blob); if (notificationSystem != null) { notificationSystem.onBlobCreated(blobId, postData.getBlobProperties(), postData.getUsermetadata(), NotificationBlobType.Simple); } operationResult = blobId; <START> } catch (Exception e) { <END> if (e instanceof RouterException) { exception = e; } else { exception = new RouterException(e, RouterErrorCode.UnexpectedInternalError); } } finally { InMemoryRouter.completeOperation(postData.getFuture(), postData.getCallback(), operationResult, exception); } }</code><technical_language>} catch (RouterException e) { exception = e; } catch (Exception e) { exception = new RouterException(e, RouterErrorCode.UnexpectedInternalError); } I</technical_language>

Target:
public void run() { String operationResult = null; Exception exception = null; try { String blobId = new BlobId(BlobId.DEFAULT_FLAG, ClusterMapUtils.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, getPartitionForPut()).getID(); if (blobs.containsKey(blobId)) { exception = new RouterException("Blob ID duplicate created.", RouterErrorCode.UnexpectedInternalError); } ByteBuffer blobData = readBlob(postData.getReadableStreamChannel()); InMemoryRouter.InMemoryBlob blob = new InMemoryRouter.InMemoryBlob(postData.getBlobProperties(), postData.getUsermetadata(), blobData); blobs.put(blobId, blob); if (notificationSystem != null) { notificationSystem.onBlobCreated(blobId, postData.getBlobProperties(), postData.getUsermetadata(), NotificationBlobType.Simple); } operationResult = blobId; } catch (RouterException e) { exception = e; } catch (Exception e) { exception = new RouterException(e, RouterErrorCode.UnexpectedInternalError); } finally { InMemoryRouter.completeOperation(postData.getFuture(), postData.getCallback(), operationResult, exception); } }
Source:
<code>public void apply(OnlineCommandContext ctx) throws Exception { Operations ops = new Operations(ctx.client); Address address = Address.subsystem("resource-adapters").and("resource-adapter", resourceAdapterId) .and("connection-definitions", poolName); ops.add(address, Values.of("class-name", "org.jboss.resource.adapter.jms.JmsManagedConnectionFactory") .and("jndi-name", localJndiName)); if (security) { ops.writeAttribute(address, "security-application", true); } if (userName != null) { ops.writeAttribute(address, "recovery-username", userName); } if (password != null) { ops.writeAttribute(address, "recovery-password", password); } ops.writeAttribute(address, "tracking", tracking); if (properties.size() > 0) { Iterator it = properties.entrySet().iterator(); <START> while (it.hasNext()) { <END> Map.Entry pair = (Map.Entry) it.next(); Address configPropsAddress = Address.subsystem("resource-adapters") .and("resource-adapter", resourceAdapterId) .and("connection-definitions", poolName).and("config-properties", (String) pair.getKey()); ops.add(configPropsAddress, Values.of("value", (String) pair.getValue())); } } }</code><technical_language>foreach</technical_language>

Target:
public void apply(OnlineCommandContext ctx) throws Exception { Batch batch = new Batch(); Address address = Address.subsystem("resource-adapters").and("resource-adapter", resourceAdapterId) .and("connection-definitions", poolName); batch.add(address, Values.of("class-name", "org.jboss.resource.adapter.jms.JmsManagedConnectionFactory") .and("jndi-name", localJndiName)); if (security) { batch.writeAttribute(address, "security-application", true); } if (userName != null) { batch.writeAttribute(address, "recovery-username", userName); } if (password != null) { batch.writeAttribute(address, "recovery-password", password); } batch.writeAttribute(address, "tracking", tracking); for (Map.Entry<String, String> pair : properties.entrySet()) { Address configPropsAddress = Address.subsystem("resource-adapters") .and("resource-adapter", resourceAdapterId) .and("connection-definitions", poolName).and("config-properties", pair.getKey()); batch.add(configPropsAddress, Values.of("value", pair.getValue())); } new Operations(ctx.client).batch(batch); }
Source:
<code>private void migrateSections() { this.sections = new ConcurrentHashMap<>(); ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE); for(School school : this.schools) { Long sourceSystemSchoolId = Long.valueOf(school.getSourceSystemId()); sections.put(sourceSystemSchoolId, new ConcurrentHashMap<>()); SectionSyncRunnable sectionRunnable = new SectionSyncRunnable( powerSchool, edPanel, school, this.courses.get(sourceSystemSchoolId), this.terms.get(sourceSystemSchoolId), staffAssociator, studentAssociator, this.sections.get(sourceSystemSchoolId), unresolvablePowerStudents); executor.execute(sectionRunnable); } executor.shutdown(); try { executor.awaitTermination(TOTAL_TTL_MINUTES, TimeUnit.MINUTES); } catch(InterruptedException e) { <START> System.out.println("Max TTL for the migration process was exceeded and the migration terminated. " + <END> "Max TTL (minutes) is: " + TOTAL_TTL_MINUTES); } }</code><technical_language>this system out reference interrupted, exceeding TTL</technical_language>

Target:
private void migrateSections() { this.sections = new ConcurrentHashMap<>(); ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE); for(School school : this.schools) { Long sourceSystemSchoolId = Long.valueOf(school.getSourceSystemId()); sections.put(sourceSystemSchoolId, new ConcurrentHashMap<>()); SectionSyncRunnable sectionRunnable = new SectionSyncRunnable( powerSchool, edPanel, school, this.courses.get(sourceSystemSchoolId), this.terms.get(sourceSystemSchoolId), staffAssociator, studentAssociator, this.sections.get(sourceSystemSchoolId), unresolvablePowerStudents); executor.execute(sectionRunnable); } executor.shutdown(); try { executor.awaitTermination(TOTAL_TTL_MINUTES, TimeUnit.MINUTES); } catch(InterruptedException e) { System.out.println("Executor thread pool interrupted " + e.getMessage()); } }
Source:
<code>public void testStartSession() { <START> final String TEST_SESSION_NAME = "testStartSession"; final int TEST_THREAD_ID = 0; <END> assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); mTestSessionManager.mCurrentThreadId = () -> TEST_THREAD_ID; mTestSessionManager.startSession(TEST_SESSION_NAME, null); Session testSession = mTestSessionManager.mSessionMapper.get(TEST_THREAD_ID); assertEquals(TEST_SESSION_NAME, testSession.getShortMethodName()); assertFalse(testSession.isSessionCompleted()); assertFalse(testSession.isStartedFromActiveSession()); }</code><technical_language>move start of class static. a odd all-caps constants defined in a method</technical_language>

Target:
public void testStartSession() { assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID; mTestSessionManager.startSession(TEST_PARENT_NAME, null); Session testSession = mTestSessionManager.mSessionMapper.get(TEST_PARENT_THREAD_ID); assertEquals(TEST_PARENT_NAME, testSession.getShortMethodName()); assertFalse(testSession.isSessionCompleted()); assertFalse(testSession.isStartedFromActiveSession()); }
Source:
<code>public void tickCubeServer(BooleanSupplier tryToTickFaster, Random rand) { <START> if (!isFullyPopulated || this.storage == null) { <END> return; } tickCubeCommon(tryToTickFaster); Iterator<NextTickListEntry> pti = pendingTickListEntriesTreeSet.iterator(); while (pti.hasNext()) { NextTickListEntry ntle = pti.next(); if (ntle.scheduledTime > world.getTotalWorldTime()) return; BlockPos pos = ntle.position; IBlockState iblockstate = this.storage.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15); if (iblockstate.getMaterial() != Material.AIR && iblockstate.getBlock() == ntle.getBlock()) { iblockstate.getBlock().updateTick((WorldServer) world, ntle.position, iblockstate, rand); } pti.remove(); } int tickLimit = 256; pti = pendingTickListEntriesHashSet.iterator(); while (pti.hasNext() && --tickLimit != 0) { NextTickListEntry ntle = pti.next(); pendingTickListEntriesTreeSet.add(ntle); pti.remove(); } }</code><technical_language>If storage is null light need updates</technical_language>

Target:
public void tickCubeServer(BooleanSupplier tryToTickFaster, Random rand) { if (!isFullyPopulated) { return; } tickCubeCommon(tryToTickFaster); Iterator<NextTickListEntry> pti = pendingTickListEntriesTreeSet.iterator(); while (pti.hasNext()) { NextTickListEntry ntle = pti.next(); if (ntle.scheduledTime > world.getTotalWorldTime()) return; BlockPos pos = ntle.position; IBlockState iblockstate = this.storage.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15); if (iblockstate.getMaterial() != Material.AIR && iblockstate.getBlock() == ntle.getBlock()) { iblockstate.getBlock().updateTick((WorldServer) world, ntle.position, iblockstate, rand); } pti.remove(); } int tickLimit = 256; pti = pendingTickListEntriesHashSet.iterator(); while (pti.hasNext() && --tickLimit != 0) { NextTickListEntry ntle = pti.next(); pendingTickListEntriesTreeSet.add(ntle); pti.remove(); } }
Source:
<code>public final void consume(final Span span) { if (numInflights.incrementAndGet() <= maxInflights) { ListenableFuture<Span> future = executorService.submit(() -> { doConsume(span); return span; }); Futures.addCallback(future, new FutureCallback<Span>() { @Override public void onSuccess(Span result) { numInflights.decrementAndGet(); } @Override public void onFailure(Throwable error) { log.trace("Failed to notify observer", error); numInflights.decrementAndGet(); } }); } else { log.trace("Failed to notify span observer since the maximum number of allowed concurrent observations was " <START> + "exceeded: {}", SafeArg.of("maxInflights", maxInflights)); <END> numInflights.decrementAndGet(); } }</code><technical_language>Log message get cleaned remove braces</technical_language>

Target:
public final void consume(final Span span) { if (numInflights.incrementAndGet() <= maxInflights) { ListenableFuture<Span> future = executorService.submit(() -> { doConsume(span); return span; }); Futures.addCallback(future, new FutureCallback<Span>() { @Override public void onSuccess(Span result) { numInflights.decrementAndGet(); } @Override public void onFailure(Throwable error) { log.trace("Failed to notify observer", error); numInflights.decrementAndGet(); } }); } else { log.trace("Failed to notify span observer since the maximum number of allowed concurrent observations was " + "exceeded", SafeArg.of("maxInflights", maxInflights)); numInflights.decrementAndGet(); } }
Source:
<code>public FileBasedConfig openUserConfig(Config parent, FS fs) { final File home = fs.userHome(); File userConfig = new File(home, ".gitconfig"); try { userConfig.canRead(); } catch (AccessControlException e) { <START> return new FileBasedConfig(parent, null, fs) { <END> public void load() { } public boolean isOutdated() { return false; } }; } return new FileBasedConfig(parent, userConfig, fs); }</code><technical_language>log a warning users wrong permissions ~/.gitconfig mistake a chance detect problem</technical_language>

Target:
public FileBasedConfig openUserConfig(Config parent, FS fs) { final File home = fs.userHome(); File userConfig = new File(home, ".gitconfig"); try { userConfig.canRead(); } catch (AccessControlException e) { LOG.warn(MessageFormat.format(JGitText.get().unableToAccessUserConfig, userConfig.getAbsolutePath())); return new FileBasedConfig(parent, null, fs) { public void load() { } public boolean isOutdated() { return false; } }; } return new FileBasedConfig(parent, userConfig, fs); }