auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Qualifier convertMilestoneAliasQualifier(List<TurboMilestone> allMilestones, int currentIndex) { if (!content.isPresent()) { return Qualifier.EMPTY; } String contents = content.get(); String alias = contents; Pattern aliasPattern = Pattern.compile("(curr(?:ent)?)(?:(\\+|-)(\\d+))?$"); Matcher aliasMatcher = aliasPattern.matcher(alias); int offset = 0; if (!aliasMatcher.find()) { return this; } if (aliasMatcher.group(2) != null && aliasMatcher.group(3) != null) { offset = Integer.parseInt(aliasMatcher.group(3)); if (aliasMatcher.group(2).equals("+")) { currentIndex += offset; } else { currentIndex -= offset; } } if (currentIndex >= allMilestones.size() || currentIndex < 0) { <START> return this; <END> } contents = allMilestones.get(currentIndex).getTitle().toLowerCase(); return new Qualifier(name, contents); }</code><technical_language>get input milestone:curr+99. In case search for milestone "curr+99"</technical_language>

Target:
private Qualifier convertMilestoneAliasQualifier(List<TurboMilestone> allMilestones, int currentIndex) { if (!content.isPresent()) { return Qualifier.EMPTY; } String contents = content.get(); String alias = contents; Pattern aliasPattern = Pattern.compile("(curr(?:ent)?)(?:(\\+|-)(\\d+))?$"); Matcher aliasMatcher = aliasPattern.matcher(alias); int offset = 0; if (!aliasMatcher.find()) { return this; } if (aliasMatcher.group(2) != null && aliasMatcher.group(3) != null) { offset = Integer.parseInt(aliasMatcher.group(3)); if (aliasMatcher.group(2).equals("+")) { currentIndex += offset; } else { currentIndex -= offset; } } if (currentIndex >= allMilestones.size() || currentIndex < 0) { return Qualifier.FALSE; } contents = allMilestones.get(currentIndex).getTitle().toLowerCase(); return new Qualifier(name, contents); }
Source:
<code>protected boolean canDoAction() { if (getNic() == null) { return failCanDoAction(VdcBllMessages.HOST_NETWORK_INTERFACE_NOT_EXIST); } if (NetworkUtils.isLabeled(getNic()) && getNic().getLabels().contains(getLabel())) { return failCanDoAction(VdcBllMessages.INTERFACE_ALREADY_LABELED); } if (!ValidationUtils.validateInputs(getValidationGroups(), getNic()).isEmpty()) { <START> return failCanDoAction(VdcBllMessages.IMPROPER_BOND_IS_LABELED); <END> } if (Boolean.TRUE.equals(getNic().getBonded())) { int slavesCount = 0; for (VdsNetworkInterface nic : getHostInterfaces()) { if (StringUtils.equals(getNic().getName(), nic.getBondName())) { slavesCount++; if (slavesCount == 2) { break; } } } if (slavesCount < 2) { return failCanDoAction(VdcBllMessages.IMPROPER_INTERFACE_IS_LABELED); } } for (VdsNetworkInterface nic : getHostInterfaces()) { if (!StringUtils.equals(nic.getName(), getNicName()) && NetworkUtils.isLabeled(nic) && nic.getLabels().contains(getLabel())) { return failCanDoAction(VdcBllMessages.OTHER_INTERFACE_ALREADY_LABELED, "$LabeledNic " + nic.getName()); } } List<String> assignedNetworks = validateNetworksNotAssignedToIncorrectNics(); if (!assignedNetworks.isEmpty()) { return failCanDoAction(VdcBllMessages.LABELED_NETWORK_ATTACHED_TO_WRONG_INTERFACE, "$AssignedNetworks " + StringUtils.join(assignedNetworks, ", ")); } return true; }</code><technical_language>change key line 84</technical_language>

Target:
protected boolean canDoAction() { if (getNic() == null) { return failCanDoAction(VdcBllMessages.HOST_NETWORK_INTERFACE_NOT_EXIST); } if (NetworkUtils.isLabeled(getNic()) && getNic().getLabels().contains(getLabel())) { return failCanDoAction(VdcBllMessages.INTERFACE_ALREADY_LABELED); } if (!ValidationUtils.validateInputs(getValidationGroups(), getNic()).isEmpty()) { return failCanDoAction(VdcBllMessages.IMPROPER_INTERFACE_IS_LABELED); } if (Boolean.TRUE.equals(getNic().getBonded())) { int slavesCount = 0; for (VdsNetworkInterface nic : getHostInterfaces()) { if (StringUtils.equals(getNic().getName(), nic.getBondName())) { slavesCount++; if (slavesCount == 2) { break; } } } if (slavesCount < 2) { return failCanDoAction(VdcBllMessages.IMPROPER_BOND_IS_LABELED); } } for (VdsNetworkInterface nic : getHostInterfaces()) { if (!StringUtils.equals(nic.getName(), getNicName()) && NetworkUtils.isLabeled(nic) && nic.getLabels().contains(getLabel())) { return failCanDoAction(VdcBllMessages.OTHER_INTERFACE_ALREADY_LABELED, "$LabeledNic " + nic.getName()); } } List<String> assignedNetworks = validateNetworksNotAssignedToIncorrectNics(); if (!assignedNetworks.isEmpty()) { return failCanDoAction(VdcBllMessages.LABELED_NETWORK_ATTACHED_TO_WRONG_INTERFACE, "$AssignedNetworks " + StringUtils.join(assignedNetworks, ", ")); } return true; }
Source:
<code>private PartitionMetadata findLeader(List<String> a_seedBrokers, int a_port, String a_topic, int a_partition) { PartitionMetadata returnMetaData = null; for (String seed : a_seedBrokers) { SimpleConsumer consumer = null; try { <START> consumer = new SimpleConsumer(seed, a_port, 100000, 64 * 1024, "leaderLookup"); END> List<String> topics = new ArrayList<String>(); topics.add(a_topic); TopicMetadataRequest req = new TopicMetadataRequest(topics); kafka.javaapi.TopicMetadataResponse resp = consumer.send(req); List<TopicMetadata> metaData = resp.topicsMetadata(); for (TopicMetadata item : metaData) { for (PartitionMetadata part : item.partitionsMetadata()) { if (part.partitionId() == a_partition) { returnMetaData = part; break; } } } } catch (Exception e) { System.out.println("Error communicating with Broker [" + seed + "] to find Leader for [" + a_topic + ", " + a_partition + "] Reason: " + e); } finally { if (consumer != null) consumer.close(); } } if (returnMetaData != null) { m_replicaBrokers.clear(); for (kafka.cluster.Broker replica : returnMetaData.replicas()) { m_replicaBrokers.add(replica.host()); } } return returnMetaData; }</code><technical_language>I fully aware of Kafka internals, I APIs for consumers. this new API</technical_language>

Target:
private PartitionMetadata findLeader(List<String> a_seedBrokers, int a_port, String a_topic, int a_partition) { PartitionMetadata returnMetaData = null; for (String seed : a_seedBrokers) { SimpleConsumer consumer = null; try { consumer = new SimpleConsumer(seed, a_port, kafkaConnectionTimeOut, kafkaBufferSize, leaderClientID); List<String> topics = new ArrayList<String>(); topics.add(a_topic); TopicMetadataRequest req = new TopicMetadataRequest(topics); kafka.javaapi.TopicMetadataResponse resp = consumer.send(req); List<TopicMetadata> metaData = resp.topicsMetadata(); for (TopicMetadata item : metaData) { for (PartitionMetadata part : item.partitionsMetadata()) { if (part.partitionId() == a_partition) { returnMetaData = part; break; } } } } catch (Exception e) { logger.error("Error communicating with Broker [" + seed + "] to find Leader for [" + a_topic + ", " + a_partition + "] Reason: " + e); } finally { if (consumer != null) consumer.close(); } } if (returnMetaData != null) { m_replicaBrokers.clear(); for (kafka.cluster.Broker replica : returnMetaData.replicas()) { m_replicaBrokers.add(replica.host()); } } return returnMetaData; }
Source:
<code><START> public void testReferenceCounting() throws Exception <END> { loadQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); assertQueryable( QueryGranularity.DAY, "test", new Interval("2011-04-04/2011-04-06"), ImmutableList.<Pair<String, Interval>>of( new Pair<String, Interval>("3", new Interval("2011-04-04/2011-04-05")) ) ); Assert.assertFalse(closed); dropQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); Assert.assertTrue(closed); }</code><technical_language>This test verifies closed. verify get closed while in process of running. Is setup a test verifies closing behavior in case is queued up</technical_language>

Target:
public void testReferenceCounting() throws Exception { loadQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); Future future = assertQueryable( QueryGranularity.DAY, "test", new Interval("2011-04-04/2011-04-06"), ImmutableList.<Pair<String, Interval>>of( new Pair<String, Interval>("3", new Interval("2011-04-04/2011-04-05")) ) ); queryNotifyLatch.await(); Assert.assertTrue(factory.getAdapters().size() == 1); for (SegmentForTesting segmentForTesting : factory.getAdapters()) { Assert.assertFalse(segmentForTesting.isClosed()); } queryWaitLatch.countDown(); future.get(); dropQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); for (SegmentForTesting segmentForTesting : factory.getAdapters()) { Assert.assertTrue(segmentForTesting.isClosed()); } }
Source:
<code>public Object execute(ExecutionEvent aEvent) throws ExecutionException { GerritTask item = null; GerritTableView reviewTableView = GerritTableView .getActiveView(); <START> TableViewer viewer = reviewTableView.getTableViewer(); <END> ISelection tableSelection = viewer.getSelection(); if (tableSelection.isEmpty()) { GerritUi.Ftracer.traceInfo("Selected table selection is EMPTY " ); } else { if (tableSelection instanceof IStructuredSelection ) { Object obj = ((IStructuredSelection) tableSelection).getFirstElement(); if (obj instanceof GerritTask) { item = (GerritTask) obj; item.toggleStarred(GerritTask.IS_STARRED, Boolean.toString(!Boolean.valueOf(item.getAttribute(GerritTask.IS_STARRED)))); try { reviewTableView.setStarred(item.getTaskId(), item.getStarred(), new NullProgressMonitor() {}); } catch (CoreException e) { UIUtils.showErrorDialog(e.getMessage(), e.getStatus().getException().getMessage()); item.toggleStarred(GerritTask.IS_STARRED, Boolean.toString(!Boolean.valueOf(item.getAttribute(GerritTask.IS_STARRED)))); } viewer.update(item, null); } } } return item; }</code><technical_language>if view is open? this null</technical_language>

Target:
public Object execute(ExecutionEvent aEvent) throws ExecutionException { GerritTask item = null; GerritTableView reviewTableView = GerritTableView .getActiveView(); TableViewer viewer = reviewTableView.getTableViewer(); ISelection tableSelection = viewer.getSelection(); if (tableSelection.isEmpty()) { GerritUi.Ftracer.traceInfo("Selected table selection is EMPTY " ); } else { if (tableSelection instanceof IStructuredSelection ) { Object obj = ((IStructuredSelection) tableSelection).getFirstElement(); if (obj instanceof GerritTask) { item = (GerritTask) obj; try { reviewTableView.setStarred(item.getTaskId(), !item.getStarred(), new NullProgressMonitor() {}); item.toggleStarred(GerritTask.IS_STARRED, Boolean.toString(!Boolean.valueOf(item.getAttribute(GerritTask.IS_STARRED)))); } catch (CoreException e) { UIUtils.showErrorDialog(e.getMessage(), e.getStatus().getException().getMessage()); } viewer.update(item, null); } } } return item; }
Source:
<code>protected void checkRyaInstanceExists(final Map<String, String> taskConfig) throws IllegalStateException { requireNonNull(taskConfig); final MongoRyaSinkConfig config = new MongoRyaSinkConfig(taskConfig); @Nullable final String username = Strings.isNullOrEmpty(config.getUsername()) ? null : config.getUsername(); @Nullable final char[] password = Strings.isNullOrEmpty(config.getPassword()) ? null : config.getPassword().toCharArray(); final ServerAddress serverAddr = new ServerAddress(config.getHostname(), config.getPort()); final boolean hasCredentials = username != null && password != null; try(MongoClient mongoClient = hasCredentials ? new MongoClient(serverAddr, Arrays.asList(MongoCredential.createCredential(username, config.getRyaInstanceName(), password))) : new MongoClient(serverAddr)) { final MongoConnectionDetails connectionDetails = new MongoConnectionDetails( config.getHostname(), config.getPort(), Optional.ofNullable(username), Optional.ofNullable(password)); final RyaClient client = MongoRyaClientFactory.build(connectionDetails, mongoClient); if(!client.getInstanceExists().exists( config.getRyaInstanceName() )) { throw new ConnectException("The Rya Instance named " + <START> config.getRyaInstanceName() + " has not been installed."); <END> } } catch(final RyaClientException e) { throw new ConnectException("Unable to determine if the Rya Instance named " + config.getRyaInstanceName() + " has been installed.", e); } }</code><technical_language>LogUtils.clean(config.getRyaInstanceName())</technical_language>

Target:
protected void checkRyaInstanceExists(final Map<String, String> taskConfig) throws IllegalStateException { requireNonNull(taskConfig); final MongoRyaSinkConfig config = new MongoRyaSinkConfig(taskConfig); @Nullable final String username = Strings.isNullOrEmpty(config.getUsername()) ? null : config.getUsername(); @Nullable final char[] password = Strings.isNullOrEmpty(config.getPassword()) ? null : config.getPassword().toCharArray(); final ServerAddress serverAddr = new ServerAddress(config.getHostname(), config.getPort()); final boolean hasCredentials = username != null && password != null; try(MongoClient mongoClient = hasCredentials ? new MongoClient(serverAddr, Arrays.asList(MongoCredential.createCredential(username, config.getRyaInstanceName(), password))) : new MongoClient(serverAddr)) { final MongoConnectionDetails connectionDetails = new MongoConnectionDetails( config.getHostname(), config.getPort(), Optional.ofNullable(username), Optional.ofNullable(password)); final RyaClient client = MongoRyaClientFactory.build(connectionDetails, mongoClient); if(!client.getInstanceExists().exists( config.getRyaInstanceName() )) { throw new ConnectException("The Rya Instance named " + LogUtils.clean(config.getRyaInstanceName()) + " has not been installed."); } } catch(final RyaClientException e) { throw new ConnectException("Unable to determine if the Rya Instance named " + LogUtils.clean(config.getRyaInstanceName()) + " has been installed.", e); } }
Source:
<code><START> public <REQ extends BasicMessage, RESP extends BasicMessage> Command<REQ> getCommand(Class<REQ> requestClass) <END> throws NoCommandForMessageException { if (ResourcePathDestination.class.isAssignableFrom(requestClass)) { return (Command<REQ>) resourcePathDestinationWsCommand; } else if (UiSessionDestination.class.isAssignableFrom(requestClass)) { return (Command<REQ>) uiSessionDestinationWsCommand; } else if (EchoRequest.class.isAssignableFrom(requestClass)) { return (Command<REQ>) echoCommand; } throw new NoCommandForMessageException("No command found for requestClass [" + requestClass.getName() + "]"); }</code><technical_language>I I this returning object references requires command impementations thread-safe. I prefer return "new .ABC()" command time. objects large bad if instantiate time... is a reason for request sharing command implememntation? Typically, sharing implementations this requests scare requires very, careful concurrency issues. I need open risk - I safer return new objects for "getCommand" call</technical_language>

Target:
public <REQ extends BasicMessage> WsCommand<REQ> getCommand(Class<REQ> requestClass) throws NoCommandForMessageException { if (ResourcePathDestination.class.isAssignableFrom(requestClass)) { return (WsCommand<REQ>) resourcePathDestinationWsCommand; } else if (UiSessionDestination.class.isAssignableFrom(requestClass)) { return (WsCommand<REQ>) uiSessionDestinationWsCommand; } else if (EchoRequest.class.isAssignableFrom(requestClass)) { return (WsCommand<REQ>) echoCommand; } throw new NoCommandForMessageException("No command found for requestClass [" + requestClass.getName() + "]"); }
Source:
<code>private void enableAutoGenerationOfSwaggerSpecification() { final io.swagger.jaxrs.config.BeanConfig beanConfig = new BeanConfig(); beanConfig.setResourcePackage("com.clicktravel.services,com.clicktravel.services.*"); beanConfig.setSchemes(new String[] { "https" }); beanConfig.setBasePath("/"); final Info info = new Info(); info.setVersion("1.0.0"); beanConfig.setInfo(info); beanConfig.setTitle("Swagger Specification"); beanConfig.setVersion("1.0.0"); final Swagger swaggerConfiguration = beanConfig.getSwagger(); final OAuth2Definition oauth2ImplicitDefinition = new OAuth2Definition(); final String applicationGatewayEndpiont = "<LINK_0>"; final String authorizationUrl = String.format("%s/authorize", applicationGatewayEndpiont); oauth2ImplicitDefinition.implicit(authorizationUrl); <START> oauth2ImplicitDefinition.addScope("Default", "The default scope for Oauth authentication"); <END> swaggerConfiguration.addSecurityDefinition("implicit", oauth2ImplicitDefinition); beanConfig.configure(swaggerConfiguration); beanConfig.setScan(true); }</code><technical_language>OAuth</technical_language>

Target:
private void enableAutoGenerationOfSwaggerSpecification() { final BeanConfig beanConfig = new BeanConfig(); beanConfig.setResourcePackage("com.clicktravel.services,com.clicktravel.services.*"); beanConfig.setSchemes(new String[] { "https" }); beanConfig.setBasePath("/"); final Info info = new Info(); info.setVersion("2.0.0"); beanConfig.setInfo(info); beanConfig.setTitle("Swagger Specification"); beanConfig.setVersion("0.0.0"); beanConfig.setScan(true); }
Source:
<code>public AxisAlignedBB getMinecartCollisionBox(EntityMinecart cart) { <START> return cart.getEntityBoundingBox().expand(MinecartHooks.COLLISION_EXPANSION, 0, MinecartHooks.COLLISION_EXPANSION); <END> }</code><technical_language>this break Tunnel Bore collision? Hmm....not I do this</technical_language>

Target:
public AxisAlignedBB getMinecartCollisionBox(EntityMinecart cart) { double yaw = Math.toRadians(cart.rotationYaw); double diff = ((CART_LENGTH - CART_WIDTH) / 2.0) + MinecartHooks.COLLISION_EXPANSION; double x = diff * Math.abs(Math.cos(yaw)); double z = diff * Math.abs(Math.sin(yaw)); return cart.getEntityBoundingBox().expand(x, MinecartHooks.COLLISION_EXPANSION, z); }
Source:
<code>private SourceDocument parseRecord(String record) { StringBuilder builder = new StringBuilder(); ObjectMapper mapper = new ObjectMapper(); WashingtonPostObject recordObj = null; try { recordObj = mapper .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .registerModule(new Jdk8Module()) .readValue(record, WashingtonPostObject.class); } catch (IOException e) { LOG.warn("No unique ID or published date for this record, ignored..."); return null; } id = recordObj.id(); published_date = recordObj.published_date(); <START> if (recordObj.contents != null && recordObj.contents.isPresent()) { <END> for (WashingtonPostObject.Content contentObj : recordObj.contents.get()) { if (contentObj.type() != null && contentObj.type().isPresent() && contentObj.content() != null && contentObj.content().isPresent()) { if (CONTENT_TYPE_TAG.contains(contentObj.type().get())) { builder.append(removeTags(contentObj.content().get().trim())).append("\n"); } } else { LOG.warn("No type or content tag defined in Article " + id + ", ignored this file."); } } } content = builder.toString(); return this; }</code><technical_language>This block verbose, simpler</technical_language>

Target:
private SourceDocument parseRecord(String record) { StringBuilder builder = new StringBuilder(); ObjectMapper mapper = new ObjectMapper(); WashingtonPostObject wapoObj = null; try { wapoObj = mapper .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .registerModule(new Jdk8Module()) .readValue(record, WashingtonPostObject.class); } catch (IOException e) { LOG.warn("No unique ID or published date for this record, ignored..."); return null; } id = wapoObj.id(); published_date = wapoObj.published_date(); if (JsonParser.isFieldAvailable(wapoObj.contents())) { for (WashingtonPostObject.Content contentObj : wapoObj.contents().get()) { if (JsonParser.isFieldAvailable(contentObj.type()) && JsonParser.isFieldAvailable(contentObj.content())) { if (CONTENT_TYPE_TAG.contains(contentObj.type().get())) { builder.append(removeTags(contentObj.content().get().trim())).append("\n"); } } else { LOG.warn("No type or content tag defined in Article " + id + ", ignored this file."); } } } content = builder.toString(); return this; }
Source:
<code>private void logBrokerVersion() { final String currentActiveBrokerPackageName = mBrokerProxy.getCurrentActiveBrokerPackageName(); <START> if (!StringExtensions.IsNullOrBlank(currentActiveBrokerPackageName)) { <END> String brokerRelatedInfoLogging = "The active broker is: " + currentActiveBrokerPackageName; if (mBrokerProxy.isBrokerWithPRTSupport(currentActiveBrokerPackageName)) { brokerRelatedInfoLogging += ". The active broker version is: " + AuthenticationConstants.Broker.BROKER_PROTOCOL_VERSION + ". It contains PRT support."; } else { brokerRelatedInfoLogging += " The active broker version is: v1. It doesn't " + "contain PRT support"; } Logger.v(TAG, brokerRelatedInfoLogging); } }</code><technical_language>nit: consider flipping condition</technical_language>

Target:
private void logBrokerVersion() { final String currentActiveBrokerPackageName = mBrokerProxy.getCurrentActiveBrokerPackageName(); if (StringExtensions.IsNullOrBlank(currentActiveBrokerPackageName)) { Logger.i(TAG, "Broker app package name is empty.", ""); return; } String brokerAppVersion; try { brokerAppVersion = mBrokerProxy.getBrokerAppVersion(currentActiveBrokerPackageName); } catch (final PackageManager.NameNotFoundException e) { brokerAppVersion = "N/A"; } final String brokerLogging = "Broker app is: " + currentActiveBrokerPackageName + ";Broker app version: " + brokerAppVersion; Logger.i(TAG, brokerLogging, ""); }
Source:
<code>public List<String> getScopes() { <START> return Arrays.asList("openid", "email", "profile", groupsNameParameter, alfioGroupsNameParameter); <END> }</code><technical_language>List.of</technical_language>

Target:
public List<String> getScopes() { return List.of("openid", "email", "profile", groupsNameParameter, alfioGroupsNameParameter); }
Source:
<code>private static void checkLxmlXsltCall(SubscriptionContext ctx) { CallExpression callExpression = (CallExpression) ctx.syntaxNode(); if (checkCallExpressionFqn(callExpression, LXML_XSLT)) { RegularArgument argument = TreeUtils.argumentByKeyword("access_control", callExpression.arguments()); if (argument != null) { CallExpression xsltAclCall = getArgValueAsCallExpression(argument); if (xsltAclCall != null && checkCallExpressionFqn(xsltAclCall, LXML_ACCESS_CONTROL)) { RegularArgument readNetwork = TreeUtils.argumentByKeyword("read_network", xsltAclCall.arguments()); if (readNetwork == null || !Expressions.isFalsy(readNetwork.expression())) { <START> ctx.addIssue(xsltAclCall, MESSAGE).secondary(callExpression, MESSAGE); <END> } } } else { ctx.addIssue(callExpression, MESSAGE); } } }</code><technical_language>here, need message for secondary</technical_language>

Target:
private static void checkLxmlXsltCall(SubscriptionContext ctx) { CallExpression callExpression = (CallExpression) ctx.syntaxNode(); if (checkCallExpressionFqn(callExpression, LXML_XSLT)) { RegularArgument argument = TreeUtils.argumentByKeyword("access_control", callExpression.arguments()); if (argument != null) { CallExpression xsltAclCall = getArgValueAsCallExpression(argument); if (xsltAclCall != null && checkCallExpressionFqn(xsltAclCall, LXML_ACCESS_CONTROL)) { RegularArgument readNetwork = TreeUtils.argumentByKeyword("read_network", xsltAclCall.arguments()); if (readNetwork == null || !Expressions.isFalsy(readNetwork.expression())) { ctx.addIssue(xsltAclCall, MESSAGE).secondary(callExpression, null); } } } else { ctx.addIssue(callExpression, MESSAGE); } } }
Source:
<code>public IndexSelector(String prefix, IndexStrategy strategy) { this.prefix = prefix; this.strategy = strategy; this.unit = UNIT_MAP.get(strategy); if (unit == null) { <START> throw new UnsupportedOperationException("This is a programming mistake, please check your code!"); <END> } }</code><technical_language>include name of strategy in message here</technical_language>

Target:
public IndexSelector(String prefix, IndexStrategy strategy) { this.prefix = prefix; this.strategy = strategy; this.unit = UNIT_MAP.get(strategy); if (unit == null) { throw new UnsupportedOperationException("This is a programming mistake, please check the mapping for strategy=" + strategy.name()); } }
Source:
<code><START> public static String getFileName(final Path rootDir, final Path filePath) throws IOException{ <END> return rootDir.relativize(filePath).toString().replace("\\", "/"); }</code><technical_language>throws IOException required? If this worked before, include it</technical_language>

Target:
public static String getFileName(final Path rootDir, final Path filePath) { return rootDir.relativize(filePath).toString().replace("\\", "/"); }
Source:
<code>public void init() { inEventCount = 0; removeEventCount = 0; eventArrived = false; innerAssertionsPassed = false; eventTimeStamp = 0; count.set(0); <START> averageValue = Double.valueOf(0); <END> totalValue = Double.valueOf(0); }</code><technical_language>do need Double.valueOf here</technical_language>

Target:
public void init() { inEventCount = 0; removeEventCount = 0; eventArrived = false; innerAssertionsPassed = false; eventTimeStamp = 0; count.set(0); averageValue = 0.0; totalValue = 0.0; }
Source:
<code>public void testEmptyTable() throws Exception { String tableName = "empty_table"; <START> session.execute(format("CREATE TABLE %s.%s (key text PRIMARY KEY)", KEYSPACE, tableName)); <END> EmbeddedCassandra.refreshSizeEstimates(KEYSPACE, tableName); List<TokenSplit> splits = splitManager.getSplits(KEYSPACE, tableName); assertEquals(splits.size(), 1); }</code><technical_language>test eventually drop table? (here below)</technical_language>

Target:
public void testEmptyTable() throws Exception { String tableName = "empty_table"; session.execute(format("CREATE TABLE %s.%s (key text PRIMARY KEY)", KEYSPACE, tableName)); EmbeddedCassandra.refreshSizeEstimates(KEYSPACE, tableName); List<TokenSplit> splits = splitManager.getSplits(KEYSPACE, tableName); assertEquals(splits.size(), 1); session.execute(format("DROP TABLE %s.%s", KEYSPACE, tableName)); }
Source:
<code>public void onPause() { <START> super.onPause(); <END> SubscriptionManager.from(getActivity()).removeOnSubscriptionsChangedListener( mOnSubscriptionsChangeListener); }</code><technical_language>Call this end of method</technical_language>

Target:
public void onPause() { SubscriptionManager.from(getActivity()).removeOnSubscriptionsChangedListener( mOnSubscriptionsChangeListener); super.onPause(); }
Source:
<code>private static void addNetworkInterfaceProperties(XmlRpcStruct struct, VmNetworkInterface vmInterface, VmDevice vmDevice, String nicModel, Version clusterVersion) { struct.add(VdsProperties.Type, vmDevice.getType()); <START> struct.add(VdsProperties.Device, vmDevice.getDevice()); <END> if (vmInterface.getNetworkName() != null) { struct.add(VdsProperties.network, vmInterface.getNetworkName()); } struct.add(VdsProperties.linkState, vmInterface.isLinked() ? "up" : "down"); addAddress(vmDevice, struct); struct.add(VdsProperties.mac_addr, vmInterface.getMacAddress()); addBootOrder(vmDevice, struct); struct.add(VdsProperties.SpecParams, vmDevice.getSpecParams()); struct.add(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId())); struct.add(VdsProperties.nic_type, nicModel); if (vmInterface.isPortMirroring()) { List<String> networks = new ArrayList<String>(); networks.add(vmInterface.getNetworkName()); struct.add(VdsProperties.portMirroring, networks); } addNetworkFiltersToNic(struct, clusterVersion); }</code><technical_language>this change executed for 3.2 clusters ? linkState property part of VDSM api earlier 3.2</technical_language>

Target:
private static void addNetworkInterfaceProperties(XmlRpcStruct struct, VmNetworkInterface vmInterface, VmDevice vmDevice, String nicModel, Version clusterVersion) { struct.add(VdsProperties.Type, vmDevice.getType()); struct.add(VdsProperties.Device, vmDevice.getDevice()); if (vmInterface.getNetworkName() != null) { struct.add(VdsProperties.network, vmInterface.getNetworkName()); } boolean linkingSupported = Config.<Boolean> GetValue(ConfigValues.NetworkLinkingSupported, clusterVersion.getValue()); if (linkingSupported) { struct.add(VdsProperties.linkActive, String.valueOf(vmInterface.isLinked())); } addAddress(vmDevice, struct); struct.add(VdsProperties.mac_addr, vmInterface.getMacAddress()); addBootOrder(vmDevice, struct); struct.add(VdsProperties.SpecParams, vmDevice.getSpecParams()); struct.add(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId())); struct.add(VdsProperties.nic_type, nicModel); if (vmInterface.isPortMirroring()) { List<String> networks = new ArrayList<String>(); networks.add(vmInterface.getNetworkName()); struct.add(VdsProperties.portMirroring, networks); } addNetworkFiltersToNic(struct, clusterVersion); }
Source:
<code>private void parseTestTools(PendingCertifiedProductEntity product, PendingCertificationResultEntity cert, int toolColumnBegin) { for(CSVRecord row : getRecord()) { String testToolName = row.get(toolColumnBegin).trim(); String testToolVersion = row.get(toolColumnBegin+1).trim(); if(!StringUtils.isEmpty(testToolName)) { PendingCertificationResultTestToolEntity ttEntity = new PendingCertificationResultTestToolEntity(); ttEntity.setTestToolName(testToolName); ttEntity.setTestToolVersion(testToolVersion); TestToolDTO testTool = testToolDao.getByName(testToolName); if(testTool != null) { <START> if(testTool.isRetired() && product.getIcs() == false) { <END> product.getErrorMessages().add("Test tool '" + testToolName + "' has been retired for a product with ICS=false. Please remove it from the upload file and add a different test tool if necessary."); } ttEntity.setTestToolId(testTool.getId()); } cert.getTestTools().add(ttEntity); } } }</code><technical_language>In parent class this I a method "asBoolean". this of you? Users enter boolean values 0, 1, true, false, tRuE, FALSE, I handle variety</technical_language>

Target:
private void parseTestTools(PendingCertifiedProductEntity product, PendingCertificationResultEntity cert, int toolColumnBegin) { for(CSVRecord row : getRecord()) { String testToolName = row.get(toolColumnBegin).trim(); String testToolVersion = row.get(toolColumnBegin+1).trim(); if(!StringUtils.isEmpty(testToolName)) { PendingCertificationResultTestToolEntity ttEntity = new PendingCertificationResultTestToolEntity(); ttEntity.setTestToolName(testToolName); ttEntity.setTestToolVersion(testToolVersion); TestToolDTO testTool = testToolDao.getByName(testToolName); if(testTool != null) { ttEntity.setTestToolId(testTool.getId()); } cert.getTestTools().add(ttEntity); } } }
Source:
<code>private MetadataCache handleMetadataResponse(MetadataResponse metadataResponse, <START> Predicate<MetadataResponse.TopicMetadata> topicsToRetain) { <END> Set<String> internalTopics = new HashSet<>(); List<MetadataResponse.PartitionMetadata> partitions = new ArrayList<>(); for (MetadataResponse.TopicMetadata metadata : metadataResponse.topicMetadata()) { if (!topicsToRetain.test(metadata)) continue; if (metadata.error() == Errors.NONE) { if (metadata.isInternal()) internalTopics.add(metadata.topic()); for (MetadataResponse.PartitionMetadata partitionMetadata : metadata.partitionMetadata()) { updatePartitionInfo(metadata.topic(), partitionMetadata, metadataResponse.hasReliableLeaderEpochs(), partitions::add); if (partitionMetadata.error.exception() instanceof InvalidMetadataException) { log.debug("Requesting metadata update for partition due to error {}", partitionMetadata.topicPartition, partitionMetadata.error); requestUpdate(); } } } else if (metadata.error().exception() instanceof InvalidMetadataException) { log.debug("Requesting metadata update for topic due to error {}", metadata.topic(), metadata.error()); requestUpdate(); } } return new MetadataCache(metadataResponse.clusterId(), metadataResponse.brokersById(), partitions, metadataResponse.topicsByError(Errors.TOPIC_AUTHORIZATION_FAILED), metadataResponse.topicsByError(Errors.INVALID_TOPIC_EXCEPTION), internalTopics, metadataResponse.controller()); }</code><technical_language>Do logic for <LINK_0> somewhere</technical_language>

Target:
private MetadataCache handleMetadataResponse(MetadataResponse metadataResponse, Predicate<MetadataResponse.TopicMetadata> topicsToRetain) { Set<String> internalTopics = new HashSet<>(); List<MetadataResponse.PartitionMetadata> partitions = new ArrayList<>(); for (MetadataResponse.TopicMetadata metadata : metadataResponse.topicMetadata()) { if (!topicsToRetain.test(metadata)) continue; if (metadata.error() == Errors.NONE) { if (metadata.isInternal()) internalTopics.add(metadata.topic()); for (MetadataResponse.PartitionMetadata partitionMetadata : metadata.partitionMetadata()) { updateLatestMetadata(partitionMetadata, metadataResponse.hasReliableLeaderEpochs()) .ifPresent(partitions::add); if (partitionMetadata.error.exception() instanceof InvalidMetadataException) { log.debug("Requesting metadata update for partition due to error {}", partitionMetadata.topicPartition, partitionMetadata.error); requestUpdate(); } } } else if (metadata.error().exception() instanceof InvalidMetadataException) { log.debug("Requesting metadata update for topic due to error {}", metadata.topic(), metadata.error()); requestUpdate(); } } return new MetadataCache(metadataResponse.clusterId(), metadataResponse.brokersById(), partitions, metadataResponse.topicsByError(Errors.TOPIC_AUTHORIZATION_FAILED), metadataResponse.topicsByError(Errors.INVALID_TOPIC_EXCEPTION), internalTopics, metadataResponse.controller()); }
Source:
<code>private boolean canAttackerRetreatPartialAmphib() { <START> if (Properties.getPartialAmphibiousRetreat(battleState.getGameData())) { <END> final List<Unit> landUnits = CollectionUtils.getMatches( battleState.getUnits(BattleState.Side.OFFENSE), Matches.unitIsLand()); for (final Unit unit : landUnits) { if (!unit.getWasAmphibious()) { return true; } } } return false; }</code><technical_language>consider pushing this conditional callers? I in cases calling code easier understand, avoids jump class file understand locations. Furthermore, this if statement method body a simple stream & match statement. matters much, a small performance boost need compute full set of land units halt match</technical_language>

Target:
private boolean canAttackerRetreatPartialAmphib() { if (!Properties.getPartialAmphibiousRetreat(battleState.getGameData())) { return false; } return battleState.getUnits(BattleState.Side.OFFENSE).stream() .filter(Matches.unitIsLand()) .anyMatch(Predicate.not(Unit::getWasAmphibious)); }
Source:
<code>protected void update(float percent) { if (nfcNdefMessage == null) { return; } NdefMessage message = null; try { message = NfcHandler.createMessage(nfcNdefMessage.interpretString(sprite), spinnerSelection); } catch (InterpretationException e) { Log.d(getClass().getSimpleName(), "Couldn't create message", e); } <START> StageActivity.addNfcTagMessageToDeque(message); <END> }</code><technical_language>Please explain this line in try-block</technical_language>

Target:
protected void update(float percent) { if (nfcNdefMessage == null) { return; } try { NdefMessage message = NfcHandler.createMessage(nfcNdefMessage.interpretString(sprite), nfcTagNdefSpinnerSelection); StageActivity.addNfcTagMessageToDeque(message); } catch (Exception e) { Log.d(TAG, "No new message was added to the Deque", e); } }
Source:
<code>void initFrontend() { Frontend.initEventsHandler(frontendEventsHandler); Frontend.getFrontendFailureEvent().addListener(frontendFailureEventListener); Frontend.getFrontendNotLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { user.logout(); <START> frontendFailureEventListener.hide(); <END> } }); Frontend.setFilterQueries(filterFrontendQueries()); }</code><technical_language>need call 'frontendFailureEventListener.hide()' here, 'CurrentUser.logout()' invoke 'BaseApplicationInit.onLogout()' default</technical_language>

Target:
void initFrontend() { Frontend.initEventsHandler(frontendEventsHandler); Frontend.getFrontendFailureEvent().addListener(frontendFailureEventListener); Frontend.getFrontendNotLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { user.logout(); } }); Frontend.setFilterQueries(filterFrontendQueries()); }
Source:
<code>private static void test(final String isodate) { System.out.println("----------------------------------"); try { Date date = DateParser.parse(isodate); System.out.println(">> " + isodate); System.out.println(">> " + date.toString() + " [" + date.getTime() + "]"); final String isodateRoundTrip = DateParser.getIsoDate(date); System.out.println(">> " + isodateRoundTrip); final Date orig = DateParser.parse(isodate); final Date roundTrip = DateParser.parse(isodateRoundTrip); assertDatesAreClose(orig, roundTrip); <START> } catch (DateParser.InvalidDateException ex) { <END> System.err.println(isodate + " is invalid"); System.err.println(ex.getMessage()); } System.out.println("----------------------------------"); }</code><technical_language>I need remove catch clauses hide fact of dates parse</technical_language>

Target:
private static void test(final String isodate) { Date date = DateParser.parse(isodate); final String isodateRoundTrip = DateParser.getIsoDate(date); final Date orig = DateParser.parse(isodate); final Date roundTrip = DateParser.parse(isodateRoundTrip); assertDatesAreClose(orig, roundTrip); }
Source:
<code>public void cleanUpSchemaMutationLockTablesState() throws Exception { Set<TableReference> tables = lockTables.getAllLockTables(); java.util.Optional<TableReference> tableToKeep = tables.stream().findFirst(); if (!tableToKeep.isPresent()) { log.info("No lock tables to clean up."); return; } tables.remove(tableToKeep.get()); if (tables.size() > 0) { dropTablesInternal(tables); <START> log.info("Dropped tables [{}]", UnsafeArg.of("table names", tables.toString())); <END> } schemaMutationLock.cleanLockState(); log.info("Reset the schema mutation lock in table [{}]", UnsafeArg.of("table name", tableToKeep.get().toString())); }</code><technical_language>Do need wrap unsafe args? a non-zero allocation & GC cost wrapping for logging in tight loops hot code paths (though this specific case is one). realize this this before, calling toString() log args kind of defeats point of lazy evaluation if logging log level</technical_language>

Target:
public void cleanUpSchemaMutationLockTablesState() throws Exception { Set<TableReference> tables = lockTables.getAllLockTables(); java.util.Optional<TableReference> tableToKeep = tables.stream().findFirst(); if (!tableToKeep.isPresent()) { log.info("No lock tables to clean up."); return; } tables.remove(tableToKeep.get()); if (tables.size() > 0) { dropTablesInternal(tables); log.info("Dropped tables [{}]", UnsafeArg.of("table names", tables)); } schemaMutationLock.cleanLockState(); log.info("Reset the schema mutation lock in table [{}]", UnsafeArg.of("table name", tableToKeep.get().toString())); }
Source:
<code>public static FormatterBuilder createFormatterBuilder(Properties formatterProperties) throws Exception { FormatterBuilder builder; AbstractFormatterFactory factory; if (formatterProperties.size() > 0) { String formatterClass = formatterProperties.getProperty("formatter"); String format = formatterProperties.getProperty("format", "csv"); Class<?> classz = Class.forName(formatterClass); Class<?>[] ctorParmTypes = new Class[]{ String.class, Properties.class }; Constructor<?> ctor = classz.getDeclaredConstructor(ctorParmTypes); Object[] ctorParms = new Object[]{ format, formatterProperties }; factory = new AbstractFormatterFactory() { @Override public Formatter create(String formatName, Properties props) { try { return (Formatter) ctor.newInstance(ctorParms); } catch (Exception e) { <START> e.printStackTrace(); <END> return null; } } }; builder = new FormatterBuilder(format, formatterProperties); } else { factory = new VoltCSVFormatterFactory(); Properties props = new Properties(); factory.create("csv", props); builder = new FormatterBuilder("csv", props); } builder.setFormatterFactory(factory); return builder; }</code><technical_language>This a crash</technical_language>

Target:
public static FormatterBuilder createFormatterBuilder(Properties formatterProperties) throws Exception { FormatterBuilder builder; AbstractFormatterFactory factory; if (formatterProperties.size() > 0) { String formatterClass = formatterProperties.getProperty("formatter"); String format = formatterProperties.getProperty("format", "csv"); Class<?> classz = Class.forName(formatterClass); Class<?>[] ctorParmTypes = new Class[]{ String.class, Properties.class }; Constructor<?> ctor = classz.getDeclaredConstructor(ctorParmTypes); Object[] ctorParms = new Object[]{ format, formatterProperties }; factory = new AbstractFormatterFactory() { @Override public Formatter create(String formatName, Properties props) { try { return (Formatter) ctor.newInstance(ctorParms); } catch (Exception e) { VoltDB.crashLocalVoltDB("Failed to create formatter " + formatName); return null; } } }; builder = new FormatterBuilder(format, formatterProperties); } else { factory = new VoltCSVFormatterFactory(); Properties props = new Properties(); factory.create("csv", props); builder = new FormatterBuilder("csv", props); } builder.setFormatterFactory(factory); return builder; }
Source:
<code>public void normal() { <START> final TestObserver<Integer> ts = new TestObserver<Integer>(); <END> Observable.range(1, 5).mergeWith( Completable.fromAction(new Action() { @Override public void run() throws Exception { ts.onNext(100); } }) ) .subscribe(ts); ts.assertResult(1, 2, 3, 4, 5, 100); }</code><technical_language>nit: ts</technical_language>

Target:
public void normal() { final TestObserver<Integer> to = new TestObserver<Integer>(); Observable.range(1, 5).mergeWith( Completable.fromAction(new Action() { @Override public void run() throws Exception { to.onNext(100); } }) ) .subscribe(to); to.assertResult(1, 2, 3, 4, 5, 100); }
Source:
<code><START> private final int defaultPort = fromEnvironment(BROKER_PORT, null) == null ? BrokerTestUtils.getPort() <END> : Integer.valueOf(fromEnvironment(BROKER_PORT, null)); private int port; private String hostName = fromEnvironment(BROKER_HOSTNAME, "localhost"); private String adminUri = fromEnvironment(BROKER_ADMIN_URI, null); private ConnectionFactory connectionFactory; private String user = fromEnvironment(BROKER_USER, GUEST); private String password = fromEnvironment(BROKER_PW, GUEST); private String adminUser = fromEnvironment(BROKER_ADMIN_USER, GUEST); private String adminPassword = fromEnvironment(BROKER_ADMIN_PW, GUEST); private boolean purgeAfterEach; private String fromEnvironment(String key, String defaultValue) { String environmentValue = environmentOverrides.get(key); if (!StringUtils.hasText(environmentValue)) { environmentValue = System.getenv(key); } if (StringUtils.hasText(environmentValue)) { return environmentValue; } else { return defaultValue; } }</code><technical_language>static, fromEnvironment() method. IDEA parseInt() instead of valueOf()</technical_language>

Target:
public int getPort() { return this.port; }
Source:
<code>public void testMerge() throws Throwable { String tableName = testName.getMethodName(); <START> String tableNameMM = testName.getMethodName() + "_MM"; <END> String tableNameMerge = testName.getMethodName() + "_Merge"; String tableNameMergeMM = testName.getMethodName() + "_MergeMM"; WarehouseInstance.Tuple incrementalDump; WarehouseInstance.Tuple bootStrapDump = primary.dump(primaryDbName, null); replica.load(replicatedDbName, bootStrapDump.dumpLocation) .run("REPL STATUS " + replicatedDbName) .verifyResult(bootStrapDump.lastReplicationId); insertForMerge(tableName, tableNameMerge, false); incrementalDump = verifyIncrementalLoad(Lists.newArrayList("select last_update_user from " + tableName, "select key from " + tableNameMerge, "select ID from " + tableNameMerge), Lists.newArrayList(new String[] {"creation", "creation", "creation", "creation", "creation", "creation", "creation", "merge_update", "merge_insert", "merge_insert"}, new String[] {"1", "2", "3", "4", "5", "6"}, new String[] {"1", "4", "7", "8", "8", "11"}), bootStrapDump.lastReplicationId); }</code><technical_language>MM tables unused here</technical_language>

Target:
public void testMerge() throws Throwable { String tableName = testName.getMethodName(); String tableNameMerge = testName.getMethodName() + "_Merge"; WarehouseInstance.Tuple incrementalDump; WarehouseInstance.Tuple bootStrapDump = primary.dump(primaryDbName, null); replica.load(replicatedDbName, bootStrapDump.dumpLocation) .run("REPL STATUS " + replicatedDbName) .verifyResult(bootStrapDump.lastReplicationId); insertForMerge(tableName, tableNameMerge, false); incrementalDump = verifyIncrementalLoad(Lists.newArrayList("select last_update_user from " + tableName + " order by last_update_user", "select ID from " + tableNameMerge + " order by ID"), Lists.newArrayList(new String[] {"creation", "creation", "creation", "creation", "creation", "creation", "creation", "merge_update", "merge_insert", "merge_insert"}, new String[] {"1", "4", "7", "8", "8", "11"}), bootStrapDump.lastReplicationId); }
Source:
<code>private CommandContext createCommandContext(GlusterVolumeEntity volume, GlusterVolumeOptionEntity option) { Step setOptionStep = addSubStep(StepEnum.EXECUTING, StepEnum.SETTING_GLUSTER_OPTION, getOptionValues(volume, option)); ExecutionContext setOptionCtx = new ExecutionContext(); setOptionCtx.setMonitored(true); setOptionCtx.setStep(setOptionStep); <START> return dupContext().setExecutionContext(setOptionCtx); <END> }</code><technical_language>reset lock</technical_language>

Target:
private CommandContext createCommandContext(GlusterVolumeEntity volume, GlusterVolumeOptionEntity option) { Step setOptionStep = addSubStep(StepEnum.EXECUTING, StepEnum.SETTING_GLUSTER_OPTION, getOptionValues(volume, option)); ExecutionContext setOptionCtx = new ExecutionContext(); setOptionCtx.setMonitored(true); setOptionCtx.setStep(setOptionStep); return dupContext().withExecutionContext(setOptionCtx); }
Source:
<code>public static boolean isValid(Date expirationDate) { <START> DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.getDefault()); <END> Date currentDate = new Date(); String formattedDate = dateFormat.format(currentDate); SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.getDefault()); try { currentDate = format.parse(formattedDate); } catch (ParseException e) { Log.d(TAG, "Date parsing failed." + e); } boolean isExpired = currentDate.after(expirationDate); boolean isEqual = currentDate.equals(expirationDate); if (isExpired == true || isEqual == true) { return true; } return false; }</code><technical_language>Please declare dateFormat critical path of method invocation. In other words, declared a public static final variable top of class, initialized class loading time. Please fix instances exist in code</technical_language>

Target:
public static boolean isValid(Date expirationDate) { Date currentDate = new Date(); String formattedDate = dateFormat.format(currentDate); currentDate = convertDate(formattedDate); boolean isExpired = currentDate.after(expirationDate); boolean isEqual = currentDate.equals(expirationDate); if (isExpired == true || isEqual == true) { return true; } return false; }