auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private SmsChannel sendSMS(List<String> mobileList, SmsTemplate template, List<String> paramList) throws SmsSendingException { logger.info(String.format("ready to send sms, mobileList: %s, template: %s, params: %s", String.join(",", mobileList), template.name(), String.join(",", paramList))); SmsChannel successChannel = null; SmsChannel channel = template.getChannel(); try { if (channel == SmsChannel.Primary || channel == SmsChannel.TryBoth) { smsProviderPrimary.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Primary; } if (channel == SmsChannel.Backup) { smsProviderBackup.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Backup; } } catch (SmsSendingException e) { if (channel == SmsChannel.TryBoth) { logger.warn("send sms via primary channel failed, try backup channel.", e); try { smsProviderBackup.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Backup; } catch (SmsSendingException e1) { <START> logger.error("send sms via primary and backup channel all failed.", e); <END> throw e1; } } else { logger.error(String.format("send sms via %s channel failed.", channel), e); throw e; } } logger.info(String.format("send sms success, mobileList: %s, template: %s, params: %s", String.join(",", mobileList), template.name(), String.join(",", paramList))); return successChannel; }</code><technical_language>log print e1 exception</technical_language>

Target:
private SmsChannel sendSMS(List<String> mobileList, SmsTemplate template, List<String> paramList) throws SmsSendingException { logger.info(String.format("ready to send sms, mobileList: %s, template: %s, params: %s", String.join(",", mobileList), template.name(), String.join(",", paramList))); SmsChannel successChannel = null; SmsChannel channel = template.getChannel(); try { if (channel == SmsChannel.Primary || channel == SmsChannel.TryBoth) { smsProviderPrimary.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Primary; } if (channel == SmsChannel.Backup) { smsProviderBackup.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Backup; } } catch (SmsSendingException e) { if (channel == SmsChannel.TryBoth) { logger.warn("send sms via primary channel failed, try backup channel.", e); try { smsProviderBackup.sendSMS(mobileList, template, paramList); successChannel = SmsChannel.Backup; } catch (SmsSendingException e1) { logger.error("send sms via primary and backup channel all failed.", e1); throw e1; } } else { logger.error(String.format("send sms via %s channel failed.", channel), e); throw e; } } logger.info(String.format("send sms success, mobileList: %s, template: %s, params: %s, channel: %s", String.join(",", mobileList), template.name(), String.join(",", paramList), successChannel)); return successChannel; }
Source:
<code>default List<ConsentSignature> getConsentSignatureHistory(SubpopulationGuid subpopGuid) { List<ConsentSignature> signatures = Lists.newArrayList(); <START> for (Map.Entry<HibernateAccountConsentKey, HibernateAccountConsent> entry : getConsents().entrySet()) { <END> HibernateAccountConsentKey key = entry.getKey(); HibernateAccountConsent consent = entry.getValue(); if (key.getSubpopulationGuid().equals(subpopGuid.getGuid())) { ConsentSignature signature = new ConsentSignature.Builder() .withName(consent.getName()) .withBirthdate(consent.getBirthdate()) .withImageData(consent.getSignatureImageData()) .withImageMimeType(consent.getSignatureImageMimeType()) .withConsentCreatedOn(consent.getConsentCreatedOn()) .withSignedOn(key.getSignedOn()) .withWithdrewOn(consent.getWithdrewOn()).build(); signatures.add(signature); } } signatures.sort(Comparator.comparing(ConsentSignature::getSignedOn)); return ImmutableList.copyOf(signatures); }</code><technical_language>Similarly, unit tests for get/setConsentSignatureHistory() moved DAO AccountTest. Similarly for getAllConsentSignatureHistories()</technical_language>

Target:
default List<ConsentSignature> getConsentSignatureHistory(SubpopulationGuid subpopGuid) { List<ConsentSignature> signatures = Lists.newArrayList(); for (Map.Entry<HibernateAccountConsentKey, HibernateAccountConsent> entry : getConsents().entrySet()) { HibernateAccountConsentKey key = entry.getKey(); HibernateAccountConsent consent = entry.getValue(); if (key.getSubpopulationGuid().equals(subpopGuid.getGuid())) { ConsentSignature signature = new ConsentSignature.Builder() .withName(consent.getName()) .withBirthdate(consent.getBirthdate()) .withImageData(consent.getSignatureImageData()) .withImageMimeType(consent.getSignatureImageMimeType()) .withConsentCreatedOn(consent.getConsentCreatedOn()) .withSignedOn(key.getSignedOn()) .withWithdrewOn(consent.getWithdrewOn()).build(); signatures.add(signature); } } signatures.sort(comparing(ConsentSignature::getSignedOn)); return ImmutableList.copyOf(signatures); }
Source:
<code>public void testQuery() throws IOException { IDatabases dbs = new DatabasesImpl(DATABASE_CONNECTION1); dbs.getDatabase1().deleteAll(); IUserPersistence users = dbs.getDatabase1().users(); User userA = users.createDefaultInstance().setHandle("A").setBio("Rapper").setNumPosts(1); User userB = users.createDefaultInstance().setHandle("B").setBio("Rapper").setNumPosts(2); <START> User userC = users.createDefaultInstance().setHandle("C").setBio("Drug dealer").setNumPosts(2); <END> User userD = users.createDefaultInstance().setHandle("D").setBio("Cool dentist").setNumPosts(3); userA.save(); userB.save(); userC.save(); userD.save(); Set<User> result; result = users.query().find(); assertTrue(result.isEmpty()); result = users.query().bio("Cool dentist").find(); assertEquals(1, result.size()); assertTrue(result.contains(userD)); result = users.query().handle("A").bio("Rapper").num_posts(1).find(); assertEquals(1, result.size()); assertTrue(result.contains(userA)); result = users.query().bio("Rapper").num_posts(2).find(); assertEquals(1, result.size()); assertTrue(result.contains(userB)); result = users.query().num_posts(3).bio("Rapper").find(); assertTrue(result.isEmpty()); }</code><technical_language>This sounds dumb, this is open source project I;d more comfortable if of bios respectable occupations</technical_language>

Target:
public void testQuery() throws IOException { IDatabases dbs = new DatabasesImpl(DATABASE_CONNECTION1); dbs.getDatabase1().deleteAll(); IUserPersistence users = dbs.getDatabase1().users(); User userA = users.createDefaultInstance().setHandle("A").setBio("Trader").setNumPosts(1); User userB = users.createDefaultInstance().setHandle("B").setBio("Trader").setNumPosts(2); User userC = users.createDefaultInstance().setHandle("C").setBio("CEO").setNumPosts(2); User userD = users.createDefaultInstance().setHandle("D").setBio("Janitor").setNumPosts(3); userA.save(); userB.save(); userC.save(); userD.save(); Set<User> result; result = users.query().find(); assertTrue(result.isEmpty()); result = users.query().bio("Janitor").find(); assertEquals(1, result.size()); assertTrue(result.contains(userD)); result = users.query().handle("A").bio("Trader").numPosts(1).find(); assertEquals(1, result.size()); assertTrue(result.contains(userA)); result = users.query().bio("Trader").numPosts(2).find(); assertEquals(1, result.size()); assertTrue(result.contains(userB)); result = users.query().numPosts(3).bio("CEO").find(); assertTrue(result.isEmpty()); }
Source:
<code>void setBluetoothTethering(boolean value, final String pkgName) { if (DBG) { Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn); } enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.isTetheringSupported()) { UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); <START> if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING) && value) { throw new SecurityException("DISALLOW_CONFIG_TETHERING is enabled for this user."); } <END> if (mTetherOn != value) { mTetherOn = value; List<BluetoothDevice> devList = getConnectedDevices(); for (BluetoothDevice dev : devList) { disconnect(dev); } } } else { throw new SecurityException( "Bluetooth does not have tethering permission, or tethering is disabled."); } }</code><technical_language>need check DISALLOW_CONFIG_TETHERING here, isTetheringSupported function examine it. <LINK_0>;l=4112?ss=android&q=isTetheringSupported</technical_language>

Target:
void setBluetoothTethering(boolean value, final String pkgName) { if (DBG) { Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn); } enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.isTetheringSupported()) { if (mTetherOn != value) { mTetherOn = value; List<BluetoothDevice> devList = getConnectedDevices(); for (BluetoothDevice dev : devList) { disconnect(dev); } } } else { throw new SecurityException( "Bluetooth does not have tethering permission, or tethering is disabled."); } }
Source:
<code><START> ListKeysOperation(Builder builder) <END> { super(RiakMessageCodes.MSG_TsListKeysReq, RiakMessageCodes.MSG_TsListKeysResp, builder.reqBuilder, RiakTsPB.TsListKeysResp.PARSER); this.builder = builder; }</code><technical_language>Suspicious package visibility, do need it</technical_language>

Target:
private ListKeysOperation(Builder builder) { super(RiakMessageCodes.MSG_TsListKeysReq, RiakMessageCodes.MSG_TsListKeysResp, builder.reqBuilder, RiakTsPB.TsListKeysResp.PARSER); this.builder = builder; }
Source:
<code>public NetworkProfileListModel() { setTitle(ConstantsManager.getInstance().getConstants().vnicProfilesTitle()); setHelpTag(HelpTag.profiles); setHashName("profiles"); <START> setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly)); <END> setComparator(new Linq.VnicProfileViewComparator()); setNewCommand(new UICommand("New", this)); setEditCommand(new UICommand("Edit", this)); setRemoveCommand(new UICommand("Remove", this)); updateActionAvailability(); }</code><technical_language>do setAvailableInModes(ApplicationMode.VirtOnly); Refer VmListModel.java</technical_language>

Target:
public NetworkProfileListModel() { setTitle(ConstantsManager.getInstance().getConstants().vnicProfilesTitle()); setHelpTag(HelpTag.profiles); setHashName("profiles"); setAvailableInModes(ApplicationMode.VirtOnly); setComparator(new Linq.VnicProfileViewComparator()); setNewCommand(new UICommand("New", this)); setEditCommand(new UICommand("Edit", this)); setRemoveCommand(new UICommand("Remove", this)); updateActionAvailability(); }
Source:
<code>private <T extends Metric, V> T doRegisterMetric(String simpleName, String key, String metricName, Class<T> metricClass, Supplier<V> supplier) { validateArguments(simpleName, metricName); Validate.notNull(metricClass, "metric class argument is null."); String fullMetricName = MetricRegistry.name(simpleName, key, metricName); Metric metric = null; if (!checkCache(simpleName, fullMetricName).isPresent()) { try { metric = createMetric(fullMetricName, metricClass); _metricRegistry.register(fullMetricName, metric); } catch (IllegalArgumentException e) { } updateCache(simpleName, fullMetricName, metric); } else { metric = _metricRegistry.getMetrics().get(fullMetricName); <START> } <END> if (metric != null && metric instanceof ResettableGauge) { Validate.notNull(supplier, "null supplier to Gauge"); ((ResettableGauge) metric).setSupplier(supplier); } return (T) metric; }</code><technical_language>Is this register call needed new API create register metrics registry</technical_language>

Target:
private <T extends Metric, V> T doRegisterMetric(String simpleName, String key, String metricName, Class<T> metricClass, Supplier<V> supplier) { validateArguments(simpleName, metricName); Validate.notNull(metricClass, "metric class argument is null."); String fullMetricName = MetricRegistry.name(simpleName, key, metricName); Metric metric = getMetric(fullMetricName, metricClass); if (metric != null && metric instanceof ResettableGauge) { Validate.notNull(supplier, "null supplier to Gauge"); ((ResettableGauge) metric).setSupplier(supplier); try { _metricRegistry.register(fullMetricName, metric); } catch (IllegalArgumentException e) { } } return (T) metric; }
Source:
<code>public StandardDrive apply(Map<String, String> from) { <START> if (from.size() == 0) <END> return null; StandardDrive.Builder builder = new StandardDrive.Builder(); builder.name(from.get("name")); builder.media(MediaType.fromValue(from.get("media"))); if (from.containsKey("tags")) builder.tags(Splitter.on(' ').split(from.get("tags"))); builder.uuid(from.get("drive")); if (from.containsKey("claim:type")) builder.claimType(ClaimType.fromValue(from.get("claim:type"))); if (from.containsKey("readers")) builder.readers(Splitter.on(' ').split(from.get("readers"))); if (from.containsKey("size")) builder.size(Long.valueOf(from.get("size"))); if (from.containsKey("rawsize")) builder.rawSize(Long.valueOf(from.get("rawsize"))); if (from.containsKey("format")) builder.format(ImageConversionType.fromValue(from.get("format"))); Map<String, String> metadata = Maps.newLinkedHashMap(); for (Entry<String, String> entry : from.entrySet()) { if (entry.getKey().startsWith("user:")) metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); } builder.userMetadata(metadata); try { return builder.build(); } catch (NullPointerException e) { logger.trace("entry missing data: %s; %s", e.getMessage(), from); return null; } }</code><technical_language>from.isEmpty()</technical_language>

Target:
public StandardDrive apply(Map<String, String> from) { if (from.isEmpty()) return null; StandardDrive.Builder builder = new StandardDrive.Builder(); builder.name(from.get("name")); builder.media(MediaType.fromValue(from.get("media"))); if (from.containsKey("tags")) builder.tags(Splitter.on(' ').split(from.get("tags"))); builder.uuid(from.get("drive")); if (from.containsKey("claim:type")) builder.claimType(ClaimType.fromValue(from.get("claim:type"))); if (from.containsKey("readers")) builder.readers(Splitter.on(' ').split(from.get("readers"))); if (from.containsKey("size")) builder.size(Long.valueOf(from.get("size"))); if (from.containsKey("rawsize")) builder.rawSize(Long.valueOf(from.get("rawsize"))); if (from.containsKey("format")) builder.format(ImageConversionType.fromValue(from.get("format"))); Map<String, String> metadata = Maps.newLinkedHashMap(); for (Entry<String, String> entry : from.entrySet()) { String key = entry.getKey(); if (key.startsWith("user:")) metadata.put(key.substring(key.indexOf(':') + 1), entry.getValue()); } builder.userMetadata(metadata); try { return builder.build(); } catch (NullPointerException e) { logger.warn("entry missing data: %s; %s", e.getMessage(), from); return null; } }
Source:
<code>public void handleChildChange(String parentPath, List<String> currentChilds) { <START> logger.info("Data change callback: child changed, path: " + parentPath + ", current child count: " <END> + currentChilds.size()); try { updateNotificationTime(System.nanoTime()); if (parentPath != null && parentPath.startsWith(_path)) { if (currentChilds == null && parentPath.equals(_path)) { _manager.removeListener(_propertyKey, _listener); } else { NotificationContext changeContext = new NotificationContext(_manager); changeContext.setType(NotificationContext.Type.CALLBACK); changeContext.setPathChanged(parentPath); changeContext.setChangeType(_changeType); enqueueTask(changeContext); } } } catch (Exception e) { String msg = "exception in handling child-change. instance: " + _manager.getInstanceName() + ", parentPath: " + parentPath + ", listener: " + _listener; ZKExceptionHandler.getInstance().handle(msg, e); } }</code><technical_language>lets avoid constructing strings reduce GC pressure. Also, this pollute logs. get out of log messages</technical_language>

Target:
public void handleChildChange(String parentPath, List<String> currentChilds) { if (logger.isDebugEnabled()) { logger.debug( "Data change callback: child changed, path: " + parentPath + ", current child count: " + currentChilds.size()); } try { updateNotificationTime(System.nanoTime()); if (parentPath != null && parentPath.startsWith(_path)) { if (currentChilds == null && parentPath.equals(_path)) { _manager.removeListener(_propertyKey, _listener); } else { NotificationContext changeContext = new NotificationContext(_manager); changeContext.setType(NotificationContext.Type.CALLBACK); changeContext.setPathChanged(parentPath); changeContext.setChangeType(_changeType); enqueueTask(changeContext); } } } catch (Exception e) { String msg = "exception in handling child-change. instance: " + _manager.getInstanceName() + ", parentPath: " + parentPath + ", listener: " + _listener; ZKExceptionHandler.getInstance().handle(msg, e); } }
Source:
<code>public TransactionSnapshot(long timestamp, long readPointer, long writePointer, Collection<Long> invalid, NavigableMap<Long, TransactionManager.InProgressTx> inProgress) { this.timestamp = timestamp; this.readPointer = readPointer; this.writePointer = writePointer; this.invalid = invalid; this.inProgress = inProgress; this.committingChangeSets = new HashMap<>(); <START> this.committedChangeSets = new HashMap<>(); <END> }</code><technical_language>Collections.emptyMap() in places, right</technical_language>

Target:
public TransactionSnapshot(long timestamp, long readPointer, long writePointer, Collection<Long> invalid, NavigableMap<Long, TransactionManager.InProgressTx> inProgress) { this.timestamp = timestamp; this.readPointer = readPointer; this.writePointer = writePointer; this.invalid = invalid; this.inProgress = inProgress; this.committingChangeSets = Collections.emptyMap(); this.committedChangeSets = Collections.emptyMap(); }
Source:
<code><START> public boolean resetAfterCatalogChange() { <END> if (m_procName.startsWith("org.voltdb.sysprocs.UpdateApplicationCatalog")) { return false; } return true; }</code><technical_language>If this is for UAC, changing function name isUAC() similar name helps understanding</technical_language>

Target:
public boolean resetAfterCatalogChange() { if (isProcedureUAC()) { return false; } return true; }
Source:
<code>private String buildContainerName(String pluginName, String cheContainerName) { String preliminaryName = (pluginName + "-" + cheContainerName).toLowerCase(); if (preliminaryName.length() <= maxContainerNameLength) { return preliminaryName; } <START> return ("plugin-" + cheContainerName).substring(0, maxContainerNameLength - 1).toLowerCase(); <END> }</code><technical_language>I sense limit Che container name 50 characters if preliminaryName is long get 12 characters Che Plugin Name concatenate Che container name '-' separator. @garagatyi Please pay attention this. suggest a way</technical_language>

Target:
private String buildContainerName(String pluginName, String cheContainerName) { if (pluginName == null) { return cheContainerName.substring( 0, min(cheContainerName.length(), MAX_CONTAINER_NAME_LENGTH)); } String preliminaryName = (pluginName + "-" + cheContainerName).toLowerCase(); if (preliminaryName.length() <= MAX_CONTAINER_NAME_LENGTH) { return preliminaryName; } final String limitedContainerName = cheContainerName.substring(0, min(cheContainerName.length(), 49)); return (pluginName.substring( 0, min( pluginName.length(), MAX_CONTAINER_NAME_LENGTH - limitedContainerName.length() - 1)) + "-" + limitedContainerName) .toLowerCase(); }
Source:
<code>public void submit() { final Dialog dialog = getDialog(); PrefManager.UserPrefManager userPrefs = new PrefManager.UserPrefManager(MainApplication.application); userPrefs.setAppRating(binding.ratingBar.getRating()); userPrefs.setLastRatedVersion(BuildConfig.VERSION_NAME); <START> if (binding.ratingBar.getRating() <=3 ) { <END> showFeedbackDialog(getActivity()); } else { showRateTheAppDialog(); } dialog.dismiss(); }</code><technical_language>APP_NEGATIVE_RATING_THRESHOLD</technical_language>

Target:
public void submit() { final Dialog dialog = getDialog(); PrefManager.UserPrefManager userPrefs = new PrefManager.UserPrefManager(MainApplication.application); userPrefs.setAppRating(binding.ratingBar.getRating()); userPrefs.setLastRatedVersion(BuildConfig.VERSION_NAME); if (binding.ratingBar.getRating() <= AppConstants.APP_NEGATIVE_RATING_THRESHOLD) { showFeedbackDialog(getActivity()); } else { showRateTheAppDialog(); } dialog.dismiss(); }
Source:
<code>public void getFillStartPoints() { final Point[] cellSelection = createCellSelection( 2, 2, 1, 1, 1, 2, 2, 1, 3, 1, 3, 2); final Point[] fillStartPoints = GridPasteKeyListener.getFillStartPoints(cellSelection); assertEquals(2, fillStartPoints.length); final Set<Point> expectedStartPoints = new LinkedHashSet<Point>(Arrays.asList(createCellSelection( 1, 1, 1, 2))); <START> for (final Point actualStartPoint : fillStartPoints) { <END> final Iterator<Point> iterator = expectedStartPoints.iterator(); while (iterator.hasNext()) { final Point check = iterator.next(); if (actualStartPoint.equals(check)) { iterator.remove(); break; } } } assertTrue(expectedStartPoints.isEmpty()); }</code><technical_language>shortened removeAll</technical_language>

Target:
public void getFillStartPoints() { final Point[] cellSelection = createCellSelection( 2, 2, 1, 1, 1, 2, 2, 1, 3, 1, 3, 2); final Point[] fillStartPoints = GridPasteKeyListener.getFillStartPoints(cellSelection); assertEquals(2, fillStartPoints.length); final Set<Point> expectedStartPoints = new LinkedHashSet<Point>(Arrays.asList(createCellSelection( 1, 1, 1, 2))); expectedStartPoints.removeAll(Arrays.asList(fillStartPoints)); assertTrue(expectedStartPoints.isEmpty()); }
Source:
<code>public void testSignalIntermediateThrow() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventSignal.bpmn2"); ksession = createKnowledgeSession(kbase); Map<String, Object> params = new HashMap<String, Object>(); params.put("x", "MyValue"); ProcessInstance processInstance = ksession.startProcess( "SignalIntermediateEvent", params); <START> Assertions.assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED); <END> }</code><technical_language>I in this class is possible</technical_language>

Target:
public void testSignalIntermediateThrow() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventSignal.bpmn2"); ksession = createKnowledgeSession(kbase); Map<String, Object> params = new HashMap<String, Object>(); params.put("x", "MyValue"); ProcessInstance processInstance = ksession.startProcess( "SignalIntermediateEvent", params); assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED); }
Source:
<code>public int execute() { try { if (work.tableDataCopyIteratorsInitialized()) { initiateDataCopyTasks(); } else { Path dumpRoot = getEncodedDumpRootPath(); Path previousValidHiveDumpPath = getPreviousValidDumpMetadataPath(dumpRoot); boolean isBootstrap = (previousValidHiveDumpPath == null); if (shouldDump(previousValidHiveDumpPath)) { Path currentDumpPath = getCurrentDumpPath(dumpRoot, isBootstrap); Path hiveDumpRoot = new Path(currentDumpPath, ReplUtils.REPL_HIVE_BASE_DIR); work.setCurrentDumpPath(currentDumpPath); if (shouldDumpAuthorizationMetadata()) { LOG.info("Dumping authorization data"); <START> initiateAuthorizationDumpTask(currentDumpPath); <END> } DumpMetaData dmd = new DumpMetaData(hiveDumpRoot, conf); ReplChangeManager.getInstance(conf); Path cmRoot = new Path(conf.getVar(HiveConf.ConfVars.REPLCMDIR)); Long lastReplId; if (isBootstrap) { lastReplId = bootStrapDump(hiveDumpRoot, dmd, cmRoot, getHive()); } else { work.setEventFrom(getEventFromPreviousDumpMetadata(previousValidHiveDumpPath)); lastReplId = incrementalDump(hiveDumpRoot, dmd, cmRoot, getHive()); } work.setResultValues(Arrays.asList(currentDumpPath.toUri().toString(), String.valueOf(lastReplId))); initiateDataCopyTasks(); } else { LOG.info("Previous Dump is not yet loaded"); } } } catch (Exception e) { LOG.error("failed", e); setException(e); return ErrorMsg.getErrorMsg(e.getMessage()).getErrorCode(); } return 0; }</code><technical_language>If return here, this run current repl dump execution? is order of execution in current case</technical_language>

Target:
public int execute() { try { if (work.tableDataCopyIteratorsInitialized()) { initiateDataCopyTasks(); } else { Path dumpRoot = getEncodedDumpRootPath(); Path previousValidHiveDumpPath = getPreviousValidDumpMetadataPath(dumpRoot); boolean isBootstrap = (previousValidHiveDumpPath == null); if (shouldDump(previousValidHiveDumpPath)) { Path currentDumpPath = getCurrentDumpPath(dumpRoot, isBootstrap); Path hiveDumpRoot = new Path(currentDumpPath, ReplUtils.REPL_HIVE_BASE_DIR); work.setCurrentDumpPath(currentDumpPath); if (shouldDumpAuthorizationMetadata()) { initiateAuthorizationDumpTask(); } DumpMetaData dmd = new DumpMetaData(hiveDumpRoot, conf); ReplChangeManager.getInstance(conf); Path cmRoot = new Path(conf.getVar(HiveConf.ConfVars.REPLCMDIR)); Long lastReplId; if (isBootstrap) { lastReplId = bootStrapDump(hiveDumpRoot, dmd, cmRoot, getHive()); } else { work.setEventFrom(getEventFromPreviousDumpMetadata(previousValidHiveDumpPath)); lastReplId = incrementalDump(hiveDumpRoot, dmd, cmRoot, getHive()); } work.setResultValues(Arrays.asList(currentDumpPath.toUri().toString(), String.valueOf(lastReplId))); initiateDataCopyTasks(); } else { LOG.info("Previous Dump is not yet loaded"); } } } catch (Exception e) { LOG.error("failed", e); setException(e); return ErrorMsg.getErrorMsg(e.getMessage()).getErrorCode(); } return 0; }
Source:
<code>protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException { super.updateModel(context, operation); PathAddress address = context.getCurrentAddress(); for (Capability capability : this.descriptor.getCapabilities()) { context.registerCapability(capability.getRuntimeCapability(address), null); <START> } <END> }</code><technical_language>core version process capabilities, I of a reason shouldn't. A JIRA filed enable it. process attributes too</technical_language>

Target:
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException { super.updateModel(context, operation); PathAddress address = context.getCurrentAddress(); for (Capability capability : this.descriptor.getCapabilities()) { context.registerCapability(capability.getRuntimeCapability(address), null); } ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); for (AttributeDefinition attribute : this.descriptor.getAttributes()) { if (model.hasDefined(attribute.getName()) || attribute.hasCapabilityRequirements()) { attribute.addCapabilityRequirements(context, model.get(attribute.getName())); } } }
Source:
<code>@Override public void onRemoval(RemovalNotification<String, JedisPool> notification) { <START> jedisPoolCache.invalidateAll(); <END> }</code><technical_language>This is called 1 element is removed, wanna clear cache? I need close JedisPool, right</technical_language>

Target:
@Override public void onRemoval(RemovalNotification<String, JedisPool> notification) { assert notification.getValue() != null; try { notification.getValue().destroy(); } catch (Exception e) { LOGGER.warn("While destroying JedisPool {}", notification.getKey()); } }
Source:
<code>public TopologyDescriptor(TopologyConfigurationMsg topologyMessage) { this.topologyConfigId = topologyMessage.getTopologyConfigID(); this.certs = topologyMessage.getCerts(); standbyClusters = new HashMap<>(); for (ClusterConfigurationMsg clusterConfig : topologyMessage.getClustersList()) { ClusterDescriptor siteInfo = new ClusterDescriptor(clusterConfig); <START> if (clusterConfig.getRole() == ClusterRole.ACTIVE) { activeCluster = siteInfo; <END> } else if (clusterConfig.getRole() == ClusterRole.STANDBY) { addStandbySite(siteInfo); } } }</code><technical_language>Do assume topologyMessage cluster manager is valid? I active cluster. If not, throw exception some debug logs</technical_language>

Target:
public TopologyDescriptor(TopologyConfigurationMsg topologyMessage) { this.topologyConfigId = topologyMessage.getTopologyConfigID(); this.standbyClusters = new HashMap<>(); for (ClusterConfigurationMsg clusterConfig : topologyMessage.getClustersList()) { ClusterDescriptor cluster = new ClusterDescriptor(clusterConfig); if (clusterConfig.getRole() == ClusterRole.ACTIVE) { activeCluster = cluster; } else if (clusterConfig.getRole() == ClusterRole.STANDBY) { addStandbySite(cluster); } } }
Source:
<code>public void onRollback(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node, @Nonnull Throwable t) { <START> ; END> }</code><technical_language>remove redundant ; static analysis complain</technical_language>

Target:
public void onRollback(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node, @Nonnull Throwable t) { }
Source:
<code>public boolean isValid(Duration value, ConstraintValidatorContext context) { if ( value == null ) { return true; } <START> return duration.compareTo( value ) > -1; <END> }</code><technical_language>consistent 0 a reference. (But mentioned earlier, I vote for removing ones)</technical_language>

Target:
public boolean isValid(Duration value, ConstraintValidatorContext context) { if ( value == null ) { return true; } int comparisonResult = maxDuration.compareTo( value ); return inclusive ? comparisonResult >= 0 : comparisonResult > 0; }
Source:
<code><START> public Matrix rotate(Factory factory) { <END> double[][] rotatedMatrix = new double[this.columns()][this.rows()]; for (int i = 0; i < this.rows(); i++) { for (int j = 0; j < this.columns(); j++) { rotatedMatrix[j][this.rows()-1-i] = this.get(i, j); } } return factory.createMatrix(rotatedMatrix); }</code><technical_language>same. need implmentations of thing. brokes DRY principle. call rotate method in matrix</technical_language>

Target:
public Matrix rotate(Factory factory) { return self.rotate(factory); }
Source:
<code>public void setMaxRow(final int maxRow) { this.maxRow = maxRow; <START> Preconditions.checkArgument(maxRow > 0); <END> Preconditions.checkState(minRow < maxRow, "minRow >= maxRow. (minRow=%s, ,maxRow=%s)", minRow, maxRow); }</code><technical_language>a message good here</technical_language>

Target:
public void setMaxRow(final int maxRow) { this.maxRow = maxRow; Preconditions.checkArgument(maxRow > 0, "maxRow: %s", maxRow); Preconditions.checkState(minRow < maxRow, "minRow >= maxRow. (minRow=%s, ,maxRow=%s)", minRow, maxRow); }
Source:
<code>public static int decrementAndGetInt(long ptr) { <START> while (true) { <END> int old = getInt(ptr); int updated = old - 1; if (compareAndSwapInt(null, ptr, old, updated)) return updated; } }</code><technical_language>Method body replaced Unsafe.getAndAddInt(null, ptr, -1) - 1</technical_language>

Target:
public static int decrementAndGetInt(long ptr) { return UNSAFE.getAndAddInt(null, ptr, -1) - 1; }
Source:
<code>public Stream<BooleanResult> nodeManualIndexAdd( @Name( "indexName" ) String legacyIndexName, @Name( "node" ) Node node, @Name( "key" ) String key, @Name( "value" ) Object value ) { graphDatabaseAPI.index().forNodes( legacyIndexName ).add( node, key, value ); List<BooleanResult> results = new ArrayList<>( 1 ); results.add( new BooleanResult( true ) ); <START> return results.stream(); <END> }</code><technical_language>Stream.of</technical_language>

Target:
public Stream<BooleanResult> nodeManualIndexAdd( @Name( "indexName" ) String legacyIndexName, @Name( "node" ) Node node, @Name( "key" ) String key, @Name( "value" ) Object value ) { graphDatabaseAPI.index().forNodes( legacyIndexName ).add( node, key, value ); return Stream.of( new BooleanResult( true ) ); }
Source:
<code>public int compareTo(DataAccessRule other) { <START> int compareWs = compareCatalogItems(root, other.root); <END> if (compareWs != 0) return compareWs; int compareLayer = compareCatalogItems(layer, other.layer); if (compareLayer != 0) return compareLayer; if (accessMode.equals(other.accessMode)) return 0; else return accessMode.equals(AccessMode.READ) ? -1 : 1; }</code><technical_language>rename compareWS compareRoot</technical_language>

Target:
public int compareTo(DataAccessRule other) { int compareRoot = compareCatalogItems(root, other.root); if (compareRoot != 0) return compareRoot; int compareLayer = compareCatalogItems(layer, other.layer); if (compareLayer != 0) return compareLayer; if (accessMode.equals(other.accessMode)) return 0; else return accessMode.equals(AccessMode.READ) ? -1 : 1; }
Source:
<code>public String remove(String key) { Assert.notNull(key, "'key' must not be null."); Query query = new Query(Criteria.where("key").is(key)); Datastore result = template.findAndRemove(query, Datastore.class,collectionName); <START> return result==null?null:result.value; <END> }</code><technical_language>is for include("value") Map result</technical_language>

Target:
public String remove(String key) { Assert.notNull(key, "'key' must not be null."); Query query = new Query(Criteria.where(ID_FIELD).is(key)); query.fields().exclude(ID_FIELD); @SuppressWarnings("unchecked") Map<String, String> result = template.findAndRemove(query, Map.class, collectionName); return result == null ? null : result.get(VALUE); }
Source:
<code>private static void write(String filename, String content) throws IOException { <START> BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); <END> writer.write(content); writer.close(); }</code><technical_language>Please try-with-resources</technical_language>

Target:
private static void write(String filename, String content) throws IOException { try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))) { writer.write(content); } }
Source:
<code>public boolean isValidInput() { mErrorView.setVisibility(View.GONE); if (mField.isRequired() && !hasValue()) { String errorMessage = mField.getErrorMessage().getRequired(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_enter_field, mField.getLabel()); } if(errorMessage!=null){ handleError(errorMessage); <START> } <END> return false; } int inputLength = getCurrentValue().getAsString().length(); if (inputLength < mField.getRestriction().getMinLength()) { String errorMessage = mField.getErrorMessage().getMinLength(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_min_length, mField.getLabel(), mField.getRestriction().getMinLength()); } if(errorMessage!=null){ handleError(errorMessage); } return false; } if (mField.getRestriction().getMaxLength() > 0 && inputLength > mField.getRestriction().getMaxLength()) { String errorMessage = mField.getErrorMessage().getMaxLength(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_max_length, mField.getLabel(), mField.getRestriction().getMaxLength()); } if(errorMessage!=null){ handleError(errorMessage); } handleError(mField.getErrorMessage().getMaxLength()); return false; } return true; }</code><technical_language>Null check required, <code>handleError(String)</code> checks for null empty text</technical_language>

Target:
public boolean isValidInput() { mErrorView.setVisibility(View.GONE); if (mField.isRequired() && !hasValue()) { String errorMessage = mField.getErrorMessage().getRequired(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_enter_field, mField.getLabel()); } handleError(errorMessage); return false; } int inputLength = getCurrentValue().getAsString().length(); if (inputLength < mField.getRestriction().getMinLength()) { String errorMessage = mField.getErrorMessage().getMinLength(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_min_length, mField.getLabel(), mField.getRestriction().getMinLength()); } handleError(errorMessage); return false; } if (mField.getRestriction().getMaxLength() > 0 && inputLength > mField.getRestriction().getMaxLength()) { String errorMessage = mField.getErrorMessage().getMaxLength(); if(errorMessage==null || errorMessage.isEmpty()){ errorMessage = getView().getResources().getString(R.string.error_max_length, mField.getLabel(), mField.getRestriction().getMaxLength()); } handleError(errorMessage); return false; } return true; }
Source:
<code><START> private synchronized void monitorCommits(ReplicationModule.IndexCommitNotice commitNotice) { <END> long peerId = commitNotice.replicatorInstance.getId(); long index = commitNotice.committedIndex; long prevCommitIndex = lastCommit.getOrDefault(peerId, 0L); assert index >= prevCommitIndex; lastCommit.put(peerId, index); simStatusChanges.publish(0L); }</code><technical_language>i dont synchronized is necessary - talk this is necessary? Ditto for next method - i dont methods share data structures, isnt of sync in this method, accessors sync well</technical_language>

Target:
private void monitorCommits(ReplicationModule.IndexCommitNotice commitNotice) { long peerId = commitNotice.replicatorInstance.getId(); long index = commitNotice.committedIndex; long prevCommitIndex = lastCommit.getOrDefault(peerId, 0L); assert index >= prevCommitIndex; lastCommit.put(peerId, index); simStatusChanges.publish(0L); }
Source:
<code>public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); if (savedInstanceState != null) mainContent = getSupportFragmentManager().getFragment(savedInstanceState, "mainContent"); if (mainContent == null) mainContent = new PlaylistFragment(); setContentView(R.layout.content_frame); getSupportFragmentManager() <START> .beginTransaction() <END> .replace(R.id.content_frame, mainContent) .commit(); setBehindContentView(R.layout.menu_frame); MenuFragment mFragment = new MenuFragment(); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame, mFragment) .commit(); getSlidingMenu().setBehindOffset(60); setSlidingActionBarEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle("Music"); }</code><technical_language>This is a stylistic nit, I prefer lines this (which continuations of previous line) indented. way, easy a glance applies previous line. This applies other lines in this file well</technical_language>

Target:
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); if (savedInstanceState != null){ mainContent = getSupportFragmentManager().getFragment(savedInstanceState, "mainContent"); } if (mainContent == null){ mainContent = new PlaylistFragment(); } setContentView(R.layout.content_frame); switchContent(mainContent); setBehindContentView(R.layout.menu_frame); MenuFragment menuFragment = new MenuFragment(); switchFragment(menuFragment, false); getSlidingMenu().setBehindOffset(60); setSlidingActionBarEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Source:
<code>public double getFractionTransferred() { if (transferableBytes == 0) { <START> return (transferredBytes == 0) ? 1.0D : 0.0D; <END> } else { double percentage = (double) transferredBytes / (double) transferableBytes; return percentage > 1.0D ? 1.0D : percentage; } }</code><technical_language>How's this possible? byte transfer (transferableBytes == 0) transferredBytes > 0</technical_language>

Target:
public double getFractionTransferred() { if (transferableBytes == 0) { return 1.0D; } else { double percentage = (double) transferredBytes / (double) transferableBytes; return percentage > 1.0D ? 1.0D : percentage; } }
Source:
<code>private ConsumerRecords<K, V> poll(final Timer timer, final boolean includeMetadataInTimeout) { acquireAndEnsureOpen(); try { this.kafkaConsumerMetrics.recordPollStart(timer.currentTimeMs()); if (this.subscriptions.hasNoSubscriptionOrUserAssignment()) { throw new IllegalStateException("Consumer is not subscribed to any topics or assigned any partitions"); } do { client.maybeTriggerWakeup(); if (includeMetadataInTimeout) { if (!updateAssignmentMetadataIfNeeded(timer)) { return ConsumerRecords.empty(); } } else { while (!updateAssignmentMetadataIfNeeded(time.timer(Long.MAX_VALUE))) { log.warn("Still waiting for metadata"); } } final Map<TopicPartition, List<ConsumerRecord<K, V>>> records = pollForFetches(timer); if (!records.isEmpty()) { <START> if (fetcher.sendFetches() > 0 || client.hasPendingRequests()) { <END> client.pollNoThrow(); } return this.interceptors.onConsume(new ConsumerRecords<>(records)); } } while (timer.notExpired()); return ConsumerRecords.empty(); } finally { release(); this.kafkaConsumerMetrics.recordPollEnd(timer.currentTimeMs()); } }</code><technical_language>more robust wrap if statement in a try/catch? understanding is want throw exception updated positions in pollForFetches(). > If exception is thrown callers decide capture continue, records returned again, causing data loss. For edification, else caller do lose data in this scenario</technical_language>

Target:
private ConsumerRecords<K, V> poll(final Timer timer, final boolean includeMetadataInTimeout) { acquireAndEnsureOpen(); try { this.kafkaConsumerMetrics.recordPollStart(timer.currentTimeMs()); if (this.subscriptions.hasNoSubscriptionOrUserAssignment()) { throw new IllegalStateException("Consumer is not subscribed to any topics or assigned any partitions"); } do { client.maybeTriggerWakeup(); if (includeMetadataInTimeout) { if (!updateAssignmentMetadataIfNeeded(timer)) { return ConsumerRecords.empty(); } } else { while (!updateAssignmentMetadataIfNeeded(time.timer(Long.MAX_VALUE))) { log.warn("Still waiting for metadata"); } } final Map<TopicPartition, List<ConsumerRecord<K, V>>> records = pollForFetches(timer); if (!records.isEmpty()) { if (fetcher.sendFetches() > 0 || client.hasPendingRequests()) { client.transmitSends(); } return this.interceptors.onConsume(new ConsumerRecords<>(records)); } } while (timer.notExpired()); return ConsumerRecords.empty(); } finally { release(); this.kafkaConsumerMetrics.recordPollEnd(timer.currentTimeMs()); } }
Source:
<code>public static void makeUserRequest(GraphRequest.Callback callback) { final Bundle params = new Bundle(); <START> params.putString("fields", "picture,name,id,email,permissions"); <END> final GraphRequest request = new GraphRequest( AccessToken.getCurrentAccessToken(), ME_ENDPOINT, params, HttpMethod.GET, callback ); request.executeAsync(); }</code><technical_language>Previously had: params.putString("fields", "email,id,name"); added picture permissions param</technical_language>

Target:
public static void makeUserRequest(GraphRequest.Callback callback) { final Bundle params = new Bundle(); params.putString("fields", "name,id,email"); final GraphRequest request = new GraphRequest( AccessToken.getCurrentAccessToken(), ME_ENDPOINT, params, HttpMethod.GET, callback ); request.executeAsync(); }
Source:
<code>public static ProxyData[] getProxyData(String provider) { ProxyManager manager = (ProxyManager) ProxyManager.getProxyManager(); switch (provider) { case DIRECT_PROVIDER: return new ProxyData[0]; case ECLIPSE_PROVIDER: return castArray(manager.getProxyData()); case NATIVE_PROVIDER: return castArray(manager.getNativeProxyData()); default: break; } <START> throw new IllegalArgumentException("Provider not supported"); END> }</code><technical_language>decide other? move throw default case</technical_language>

Target:
public static ProxyData[] getProxyData(String provider) { ProxyManager manager = (ProxyManager) ProxyManager.getProxyManager(); switch (provider) { case DIRECT_PROVIDER: return new ProxyData[0]; case ECLIPSE_PROVIDER: return castArray(manager.getProxyData()); case NATIVE_PROVIDER: return castArray(manager.getNativeProxyData()); default: throw new IllegalArgumentException("Provider not supported"); } }
Source:
<code>private AccountAttributes createAccountAttributesToSanitize() { AccountAttributes unsanitizedAttributes = AccountAttributes.builder().build(); unsanitizedAttributes.googleId = " google'Id@gmail.com\t"; unsanitizedAttributes.name = "'name'\n\n"; unsanitizedAttributes.institute = "\\\t\n/"; <START> unsanitizedAttributes.email = "&<email>&\n"; <END> unsanitizedAttributes.isInstructor = true; return unsanitizedAttributes; }</code><technical_language>I change this a valid email address</technical_language>

Target:
private AccountAttributes createAccountAttributesToSanitize() { AccountAttributes unsanitizedAttributes = AccountAttributes.builder().build(); unsanitizedAttributes.googleId = " google'Id@gmail.com\t"; unsanitizedAttributes.name = "'n \t\t a me'\n\n"; unsanitizedAttributes.institute = "Some\t \\ institute \n/"; unsanitizedAttributes.email = " <my&email>@gmail.com\n"; unsanitizedAttributes.isInstructor = true; return unsanitizedAttributes; }
Source:
<code>public ResponseEntity<Resources<Resource>> getReleasesForUser(@RequestParam(value = "sha1", required = false) String sha1, OAuth2Authentication oAuth2Authentication) { User sw360User = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication); List<Release> releases = new ArrayList<>(); <START> if ((sha1 != null) && (!sha1.isEmpty())) { <END> releases.add(searchReleaseBySha1(sha1, sw360User)); } else { releases.addAll(releaseService.getReleasesForUser(sw360User)); } List<Resource> releaseResources = new ArrayList<>(); for (Release release : releases) { release.setComponentId(null); release.setType(null); release.setAttachments(null); release.setReleaseDate(null); release.setVendor(null); release.setMainLicenseIds(null); Resource<Release> releaseResource = new Resource<>(release); releaseResources.add(releaseResource); } Resources<Resource> resources = new Resources<>(releaseResources); return new ResponseEntity<>(resources, HttpStatus.OK); }</code><technical_language>Brackets necessary</technical_language>

Target:
public ResponseEntity<Resources<Resource>> getReleasesForUser(@RequestParam(value = "sha1", required = false) String sha1, OAuth2Authentication oAuth2Authentication) { User sw360User = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication); List<Release> releases = new ArrayList<>(); if (sha1 != null && !sha1.isEmpty()) { releases.add(searchReleaseBySha1(sha1, sw360User)); } else { releases.addAll(releaseService.getReleasesForUser(sw360User)); } List<Resource> releaseResources = new ArrayList<>(); for (Release release : releases) { release.setComponentId(null); release.setType(null); release.setAttachments(null); release.setReleaseDate(null); release.setVendor(null); release.setMainLicenseIds(null); Resource<Release> releaseResource = new Resource<>(release); releaseResources.add(releaseResource); } Resources<Resource> resources = new Resources<>(releaseResources); return new ResponseEntity<>(resources, HttpStatus.OK); }