auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void loadOMClientConfigs(Configuration config, String omSvcId) throws IOException { this.omProxies = new HashMap<>(); this.omProxyInfos = new HashMap<>(); this.omNodeIDList = new ArrayList<>(); Collection<String> omServiceIds; <START> if (omSvcId == null) { <END> omServiceIds = new ArrayList<>(); } else { omServiceIds = Collections.singletonList(omSvcId); } if (omServiceIds.size() > 1) { throw new IllegalArgumentException("Multi-OM Services is not supported." + " Please configure only one OM Service ID in " + OZONE_OM_SERVICE_IDS_KEY); } for (String serviceId : OmUtils.emptyAsSingletonNull(omServiceIds)) { Collection<String> omNodeIds = OmUtils.getOMNodeIds(config, serviceId); for (String nodeId : OmUtils.emptyAsSingletonNull(omNodeIds)) { String rpcAddrKey = OmUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY, serviceId, nodeId); String rpcAddrStr = OmUtils.getOmRpcAddress(config, rpcAddrKey); if (rpcAddrStr == null) { continue; } OMProxyInfo omProxyInfo = new OMProxyInfo(nodeId, rpcAddrStr); if (omProxyInfo.getAddress() != null) { ProxyInfo<OzoneManagerProtocolPB> proxyInfo = new ProxyInfo(null, omProxyInfo.toString()); if (nodeId == null) { nodeId = OzoneConsts.OM_NODE_ID_DUMMY; } omProxies.put(nodeId, proxyInfo); omProxyInfos.put(nodeId, omProxyInfo); omNodeIDList.add(nodeId); } else { LOG.error("Failed to create OM proxy for at address {}", nodeId, rpcAddrStr); } } } if (omProxies.isEmpty()) { throw new IllegalArgumentException("Could not find any configured " + "addresses for OM. Please configure the system with " + OZONE_OM_ADDRESS_KEY); } }</code><technical_language>Thinking more, refactor this loop, need all. this refactor in a new jira also. for (String serviceId : OmUtils.emptyAsSingletonNull(omServiceIds)) {</technical_language>

Target:
private void loadOMClientConfigs(Configuration config, String omSvcId) throws IOException { this.omProxies = new HashMap<>(); this.omProxyInfos = new HashMap<>(); this.omNodeIDList = new ArrayList<>(); Collection<String> omServiceIds = Collections.singletonList(omSvcId); for (String serviceId : OmUtils.emptyAsSingletonNull(omServiceIds)) { Collection<String> omNodeIds = OmUtils.getOMNodeIds(config, serviceId); for (String nodeId : OmUtils.emptyAsSingletonNull(omNodeIds)) { String rpcAddrKey = OmUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY, serviceId, nodeId); String rpcAddrStr = OmUtils.getOmRpcAddress(config, rpcAddrKey); if (rpcAddrStr == null) { continue; } OMProxyInfo omProxyInfo = new OMProxyInfo(nodeId, rpcAddrStr); if (omProxyInfo.getAddress() != null) { ProxyInfo<OzoneManagerProtocolPB> proxyInfo = new ProxyInfo(null, omProxyInfo.toString()); if (nodeId == null) { nodeId = OzoneConsts.OM_NODE_ID_DUMMY; } omProxies.put(nodeId, proxyInfo); omProxyInfos.put(nodeId, omProxyInfo); omNodeIDList.add(nodeId); } else { LOG.error("Failed to create OM proxy for at address {}", nodeId, rpcAddrStr); } } } if (omProxies.isEmpty()) { throw new IllegalArgumentException("Could not find any configured " + "addresses for OM. Please configure the system with " + OZONE_OM_ADDRESS_KEY); } }
Source:
<code>public ResponseEntity<String> remove(@PathVariable("name") String documentName) { try { if (doesBucketContainObject(this.bucketName, documentName)) { DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(this.bucketName, documentName); s3Client.deleteObject(deleteObjectRequest); log.info("Delete " + documentName + " from S3 bucket " + this.bucketName + ": done"); } <START> return new ResponseEntity<String>(HttpStatus.OK); <END> } catch (Exception e) { log.error(e.getMessage(), e); return new ResponseEntity<String>(HttpStatus.NOT_FOUND); } }</code><technical_language>"not found" in face of exception</technical_language>

Target:
public ResponseEntity<String> remove(@PathVariable("name") String documentName) throws SdkClientException, AmazonServiceException { if (s3Client.doesObjectExist(this.bucketName, documentName)) { DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(this.bucketName, documentName); s3Client.deleteObject(deleteObjectRequest); log.info("Delete " + documentName + " from S3 bucket " + this.bucketName + ": done"); return new ResponseEntity<String>(HttpStatus.NO_CONTENT); } else { return new ResponseEntity<String>(HttpStatus.NOT_FOUND); } }
Source:
<code>public BookieNode selectFromNetworkLocation( String networkLoc, Set<Node> excludeBookies, Predicate<BookieNode> predicate, Ensemble<BookieNode> ensemble) throws BKNotEnoughBookiesException { try { return selectRandomFromRack(networkLoc, excludeBookies, predicate, ensemble); } catch (BKNotEnoughBookiesException e) { LOG.warn("Failed to choose a bookie from : " + "excluded {}, fallback to choose bookie randomly from the cluster.", networkLoc, excludeBookies); <START> LOG.warn("Predicate Ensemble {}", predicate, ensemble); <END> return selectRandom(1, excludeBookies, predicate, ensemble).get(0); } }</code><technical_language>This line give useful information for debugging, it</technical_language>

Target:
public BookieNode selectFromNetworkLocation( String networkLoc, Set<Node> excludeBookies, Predicate<BookieNode> predicate, Ensemble<BookieNode> ensemble) throws BKNotEnoughBookiesException { try { return selectRandomFromRack(networkLoc, excludeBookies, predicate, ensemble); } catch (BKNotEnoughBookiesException e) { LOG.warn("Failed to choose a bookie from : " + "excluded {}, fallback to choose bookie randomly from the cluster.", networkLoc, excludeBookies); return selectRandom(1, excludeBookies, predicate, ensemble).get(0); } }
Source:
<code>public static void sendNotification(Context c, String text, Drawable icon) { NotificationManager notificationManager = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager == null) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) <START> notificationManager.createNotificationChannel(new NotificationChannel(TEST_RUN, c.getString(R.string.Settings_Notifications_OnTestCompletion), NotificationManager.IMPORTANCE_DEFAULT)); <END> NotificationCompat.Builder b = new NotificationCompat.Builder(c, TEST_RUN); b.setAutoCancel(true); b.setDefaults(Notification.DEFAULT_ALL); Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.draw(canvas); b.setLargeIcon(bitmap); b.setSmallIcon(R.drawable.notification_icon); b.setContentTitle(c.getString(R.string.General_AppName)); b.setContentText(text); b.setContentIntent(PendingIntent.getActivity(c, 0, MainActivity.newIntent(c, R.id.testResults), PendingIntent.FLAG_UPDATE_CURRENT)); notificationManager.notify(1, b.build()); }</code><technical_language>I wrap this line, long. wrap, please { } delimit if body begins ends</technical_language>

Target:
public static void sendNotification(Context c, String text, Drawable icon) { NotificationManager notificationManager = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager == null) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { notificationManager.createNotificationChannel( new NotificationChannel(TEST_RUN, c.getString(R.string.Settings_Notifications_OnTestCompletion), NotificationManager.IMPORTANCE_DEFAULT) ); } NotificationCompat.Builder b = new NotificationCompat.Builder(c, TEST_RUN); b.setAutoCancel(true); b.setDefaults(Notification.DEFAULT_ALL); Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.draw(canvas); b.setLargeIcon(bitmap); b.setSmallIcon(R.drawable.notification_icon); b.setContentTitle(c.getString(R.string.General_AppName)); b.setContentText(text); b.setContentIntent(PendingIntent.getActivity(c, 0, MainActivity.newIntent(c, R.id.testResults), PendingIntent.FLAG_UPDATE_CURRENT)); notificationManager.notify(1, b.build()); }
Source:
<code>public void onCreate() { super.onCreate(); ACRA.init(this); if (BuildConfig.APPLICATION_ID.contains("beta")) { releaseType = RELEASE_BETA; } else if (BuildConfig.APPLICATION_ID.contains("alpha")) { releaseType = RELEASE_ALPHA; } bus = new Bus(); final Resources resources = getResources(); ViewAnimations.init(resources); screenDensity = resources.getDisplayMetrics().density; this.prefs = PreferenceManager.getDefaultSharedPreferences(this); PrefKeys.initPreferenceKeys(resources); sessionFunnel = new SessionFunnel(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } Api.setConnectionFactory(new OkHttpConnectionFactory(this)); <START> appVersionString = BuildConfig.VERSION_NAME; <END> zeroHandler = new WikipediaZeroHandler(this); pageCache = new PageCache(); new PerformMigrationsTask().execute(); }</code><technical_language>get rid of "appVersionString" altogether</technical_language>

Target:
public void onCreate() { super.onCreate(); ACRA.init(this); if (BuildConfig.APPLICATION_ID.contains("beta")) { releaseType = RELEASE_BETA; } else if (BuildConfig.APPLICATION_ID.contains("alpha")) { releaseType = RELEASE_ALPHA; } bus = new Bus(); final Resources resources = getResources(); ViewAnimations.init(resources); screenDensity = resources.getDisplayMetrics().density; this.prefs = PreferenceManager.getDefaultSharedPreferences(this); PrefKeys.initPreferenceKeys(resources); sessionFunnel = new SessionFunnel(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } Api.setConnectionFactory(new OkHttpConnectionFactory(this)); zeroHandler = new WikipediaZeroHandler(this); pageCache = new PageCache(); new PerformMigrationsTask().execute(); }
Source:
<code>public void setCustomProperties(final Map<String, Object> customProperties) { <START> this.customProperties = customProperties; <END> }</code><technical_language>check customProperties is null</technical_language>

Target:
public void setCustomProperties(final Map<String, Object> customProperties) { CommonHelper.assertNotNull("customProperties", customProperties); this.customProperties = customProperties; }
Source:
<code>public Collection<Consumer> findByUuids(Collection<String> uuids) { Set<Consumer> consumers = new HashSet<>(); <START> for (List<String> block : this.partition(uuids)) { <END> Criteria criteria = this.createSecureCriteria() .add(Restrictions.in("uuid", uuids)); consumers.addAll(criteria.list()); } return consumers; }</code><technical_language>is block unused? iteration</technical_language>

Target:
public Collection<Consumer> findByUuids(Collection<String> uuids) { Set<Consumer> consumers = new HashSet<>(); for (List<String> block : this.partition(uuids)) { Criteria criteria = this.createSecureCriteria() .add(Restrictions.in("uuid", block)); consumers.addAll(criteria.list()); } return consumers; }
Source:
<code>public static <T> T setClassField( Class<T> type, final T obj, final String fieldName, Object fieldObject) throws Exception { <START> java.lang.reflect.Field <END> field = type.getDeclaredField(fieldName); field.setAccessible(true); java.lang.reflect.Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~java.lang.reflect.Modifier.FINAL); field.set(obj, fieldObject); return obj; }</code><technical_language>package prefix avoided</technical_language>

Target:
public static <T> T setClassField( Class<T> type, final T obj, final String fieldName, Object fieldObject) throws Exception { Field field = type.getDeclaredField(fieldName); field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(obj, fieldObject); return obj; }
Source:
<code>private void updateEntryToStoreInDb(Externalizable extObj, boolean objectInDb, String filename, ByteArrayOutputStream bos, SQLiteDatabase db, int id) { ContentValues updatedContentValues = helper.getContentValuesWithCustomData(extObj, bos.toByteArray()); if (!objectInDb) { updatedContentValues.put(DatabaseHelper.FILE_COL, (String)null); updatedContentValues.put(DatabaseHelper.AES_COL, (byte[])null); File dataFile = new File(filename); <START> dataFile.delete(); <END> } db.update(table, updatedContentValues, DatabaseHelper.ID_COL + "=?", new String[]{String.valueOf(id)}); }</code><technical_language>If this occurs transaction fails record is invalid. I add this a queue manages files delete end in a state record corrupted</technical_language>

Target:
private void updateEntryToStoreInDb(Externalizable extObj, boolean objectInDb, String filename, ByteArrayOutputStream bos, SQLiteDatabase db, int id) { ContentValues updatedContentValues = helper.getContentValuesWithCustomData(extObj, bos.toByteArray()); if (!objectInDb) { updatedContentValues.put(DatabaseHelper.FILE_COL, (String)null); updatedContentValues.put(DatabaseHelper.AES_COL, (byte[])null); HybridFileBackedSqlHelpers.setFileAsOrphan(db, filename); } db.update(table, updatedContentValues, DatabaseHelper.ID_COL + "=?", new String[]{String.valueOf(id)}); }
Source:
<code>@Override public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) { if (planner == null) { ready(); } SqlParser parser = SqlParser.create(queryString, parserConfig); SqlNode sqlNode; try { sqlNode = parser.parseQuery(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } final SqlConformance conformance = conformance(); final CalciteCatalogReader catalogReader = createCatalogReader().withSchemaPath(schemaPath); final SqlOperatorTable opTab = <START> ChainedSqlOperatorTable.of(operatorTable, catalogReader); <END> final SqlValidator validator = new CalciteSqlValidator(opTab, catalogReader, typeFactory, conformance); validator.setIdentifierExpansion(true); final RexBuilder rexBuilder = createRexBuilder(); final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder); final SqlToRelConverter.Config config = SqlToRelConverter .configBuilder() .withConfig(sqlToRelConverterConfig) .withTrimUnusedFields(false) .withConvertTableAccess(false) .build(); final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(this, validator, catalogReader, cluster, convertletTable, config); final RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false); final RelRoot root2 = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true)); final RelBuilder relBuilder = config.getRelBuilderFactory().create(cluster, null); return root2.withRel( RelDecorrelator.decorrelateQuery(root.rel, relBuilder)); }</code><technical_language>more effort define a method createSqlValidator validate expandView</technical_language>

Target:
@Override public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) { if (planner == null) { ready(); } SqlParser parser = SqlParser.create(queryString, parserConfig); SqlNode sqlNode; try { sqlNode = parser.parseQuery(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } final CalciteCatalogReader catalogReader = createCatalogReader().withSchemaPath(schemaPath); final SqlValidator validator = createSqlValidator(catalogReader); final RexBuilder rexBuilder = createRexBuilder(); final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder); final SqlToRelConverter.Config config = SqlToRelConverter .configBuilder() .withConfig(sqlToRelConverterConfig) .withTrimUnusedFields(false) .withConvertTableAccess(false) .build(); final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(this, validator, catalogReader, cluster, convertletTable, config); final RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false); final RelRoot root2 = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true)); final RelBuilder relBuilder = config.getRelBuilderFactory().create(cluster, null); return root2.withRel( RelDecorrelator.decorrelateQuery(root.rel, relBuilder)); }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mediaListItem = (MediaListItem) getArguments().getSerializable(ARG_GALLERY_ITEM); pageTitle = getArguments().getParcelable(ARG_PAGETITLE); imageTitle = new PageTitle(Namespace.FILE.toLegacyString(), <START> StringUtil.removeNamespace(mediaListItem.getTitle()), <END> pageTitle.getWikiSite()); }</code><technical_language>Gallery crash if open "picture of day" explore feed</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mediaListItem = (MediaListItem) getArguments().getSerializable(ARG_GALLERY_ITEM); pageTitle = getArguments().getParcelable(ARG_PAGETITLE); if (pageTitle == null) { pageTitle = new PageTitle(mediaListItem.getTitle(), new WikiSite(Service.COMMONS_URL)); } imageTitle = new PageTitle(Namespace.FILE.toLegacyString(), StringUtil.removeNamespace(mediaListItem.getTitle()), pageTitle.getWikiSite()); }
Source:
<code>public static Properties defaultProperties(Properties properties) { properties = properties == null ? new Properties() : properties; properties.put("oauth.identity", "foo"); properties.put("oauth.credential", "password"); properties.put("oauth.endpoint", "<LINK_0>"); properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString()); <START> properties.put(PROPERTY_ZONES, "northeurope,eastus"); <END> return properties; }</code><technical_language>do locations in Azure? more Regions? I mean, zones in providers in form: northeurope-1, northeurope2, etc</technical_language>

Target:
public static Properties defaultProperties(Properties properties) { properties = properties == null ? new Properties() : properties; properties.put("oauth.identity", "foo"); properties.put("oauth.credential", "password"); properties.put("oauth.endpoint", "<LINK_0>"); properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString()); properties.put(PROPERTY_REGIONS, "northeurope"); return properties; }
Source:
<code><START> private void createNodeAndExecStopEffector(Effector<?> eff) throws Exception { <END> BrooklynNode brooklynNode = app.createAndManageChild(EntitySpec.create(BrooklynNode.class) .configure(BrooklynNode.NO_WEB_CONSOLE_AUTHENTICATION, Boolean.TRUE)); app.start(locs); log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod()); EntityTestUtils.assertAttributeEqualsEventually(brooklynNode, BrooklynNode.SERVICE_UP, true); final String id = brooklynNode.invoke(BrooklynNode.DEPLOY_BLUEPRINT, ConfigBag.newInstance() .configure(DeployBlueprintEffector.BLUEPRINT_TYPE, BasicApplication.class.getName()) .getAllConfig()).get(); String baseUrl = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI).toString(); String entityUrl = baseUrl + "v1/applications/" + id + "/entities/" + id; Entity mirror = brooklynNode.addChild(EntitySpec.create(BrooklynEntityMirror.class) .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, entityUrl) .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, id)); Entities.manage(mirror); assertEquals(brooklynNode.getChildren().size(), 1); try { brooklynNode.stop(); fail("stop must throw when the node has running apps"); } catch (Exception e) { } brooklynNode.invoke(BrooklynNode.STOP_NODE_AND_KILL_APPS, Collections.<String, Object>emptyMap()).getUnchecked(); EntityTestUtils.assertAttributeEquals(brooklynNode, BrooklynNode.SERVICE_UP, false); }</code><technical_language>eff parameter is ignored; testing testing</technical_language>

Target:
private void createNodeAndExecStopEffector(Effector<?> eff) throws Exception { BrooklynNode brooklynNode = setUpBrooklynNodeWithApp(); brooklynNode.invoke(eff, Collections.<String, Object>emptyMap()).getUnchecked(); EntityTestUtils.assertAttributeEquals(brooklynNode, BrooklynNode.SERVICE_UP, false); assertFalse(getDriver(brooklynNode).isRunning(), "Service process still running"); }
Source:
<code>public CharSequence toXML(XmlEnvironment xmlEnvironment) { XmlStringBuilder xml = new XmlStringBuilder(this).rightAngleBracket(); <START> for (AffixElement affix : affixElements) { <END> xml.append(affix); } xml.append(payload); return xml.closeElement(this); }</code><technical_language>I simply xml.append(affixElements). If I mistaken, is a matching method in XmlStringBuilder</technical_language>

Target:
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) { XmlStringBuilder xml = new XmlStringBuilder(this).rightAngleBracket(); xml.append(affixElements); xml.append(payload); return xml.closeElement(this); }
Source:
<code>Map<String, Map<String, Long>> getContainerStorageUsage() throws Exception; <START> interface Callback { void onNewContainerStorageUsage(Map<String, Map<String, Long>> containerStorageUsage); } <END></code><technical_language>Based used, more a listener callback</technical_language>

Target:
Map<String, Map<String, Long>> getContainerStorageUsage() throws Exception; interface Listener { void onNewContainerStorageUsage(Map<String, Map<String, Long>> containerStorageUsage); }
Source:
<code>public void onCreate(SQLiteDatabase db) { String CREATE_TABLE_SORT = "CREATE TABLE " + TABLE_SORT + "(" + COLUMN_SORT_ID + " INTEGER PRIMARY KEY," <START> + COLUMN_SORT_PATH + " TEXT," + COLUMN_SORT_TYPE + " TEXT" + ")"; <END> db.execSQL(CREATE_TABLE_SORT); }</code><technical_language>is COLUMN_SORT_TYPE text? integer</technical_language>

Target:
public void onCreate(SQLiteDatabase db) { String CREATE_TABLE_SORT = "CREATE TABLE " + TABLE_SORT + "(" + COLUMN_SORT_PATH + " TEXT PRIMARY KEY," + COLUMN_SORT_TYPE + " INTEGER" + ")"; db.execSQL(CREATE_TABLE_SORT); }
Source:
<code><START> public static <END> synchronized IBinder makeConnector(Context context) { if (sConnector == null) { sConnector = new TetheringConnector(context); } return sConnector; }</code><technical_language>I this public (NetworkStack version is public for legacy reasons)</technical_language>

Target:
private static synchronized IBinder makeConnector(Context context) { if (sConnector == null) { sConnector = new TetheringConnector(context); } return sConnector; }
Source:
<code>public Optional<InputStream> tryCreateInputStream() { try { <START> if (inputStreamSupplier == null) { <END> return Optional.empty(); } return Optional.ofNullable(inputStreamSupplier.apply(this)); } catch (Exception e) { throw handleErrorInCallback(e, "inputStreamSupplier"); } }</code><technical_language>I inverting this if check improve readability/flow consistent other methods in this class</technical_language>

Target:
public Optional<InputStream> tryCreateInputStream() { try { if (!canCreateInputStream()) { return Optional.empty(); } return Optional.ofNullable(inputStreamSupplier.apply(this)); } catch (Exception e) { throw handleErrorInCallback(e, "inputStreamSupplier"); } }
Source:
<code>public static <T> List<List<T>> partitionList(List<T> inputList, int batchSize) { Objects.requireNonNull(inputList, "Input list cannot be null"); if (batchSize < 1) { throw new IllegalArgumentException("Invalid batchSize: " + batchSize); } List<List<T>> partitionedLists = new ArrayList<>(); <START> for (int j = 0; j < inputList.size() / batchSize + 1; j++) { <END> int start = j * batchSize; if (start >= inputList.size()) { break; } int end = Math.min((j + 1) * batchSize, inputList.size()); partitionedLists.add(inputList.subList(start, end)); } return partitionedLists; }</code><technical_language>this loop simplified to: for (int start = 0; start < inputList.size(); start += batchSize) { int end = Math.min(start + batchSize, inputList.size()); partitionedLists.add(inputList.subList(start, end)); } I missing edge case</technical_language>

Target:
public static <T> List<List<T>> partitionList(List<T> inputList, int batchSize) { Objects.requireNonNull(inputList, "Input list cannot be null"); if (batchSize < 1) { throw new IllegalArgumentException("Invalid batchSize: " + batchSize); } List<List<T>> partitionedLists = new ArrayList<>(); for (int start = 0; start < inputList.size(); start += batchSize) { int end = Math.min(start + batchSize, inputList.size()); partitionedLists.add(inputList.subList(start, end)); } return partitionedLists; }
Source:
<code>public JiraChangeLogAnnotator() { super(); if(LOGGER.isLoggable(Level.FINE)) { <START> LOGGER.info("JiraChangeLogAnnotator registered"); <END> } }</code><technical_language>LOGGER.log(Level.FINE, "JiraChangeLogAnnotator registered") BTW guaranteed annotator is registered. check Jenkins' extension lists</technical_language>

Target:
public JiraChangeLogAnnotator() { super(); LOGGER.fine("JiraChangeLogAnnotator created"); }
Source:
<code><START> final public Aggregator factorize(ColumnSelectorFactory metricFactory) <END> { Pair<Aggregator, BaseNullableColumnValueSelector> pair = factorize2( metricFactory); return NullHandling.useDefaultValuesForNull() ? pair.lhs : new NullableAggregator(pair.lhs, pair.rhs); }</code><technical_language>public is final,</technical_language>

Target:
public final Aggregator factorize(ColumnSelectorFactory metricFactory) { Pair<Aggregator, BaseNullableColumnValueSelector> pair = factorize2( metricFactory); return NullHandling.useDefaultValuesForNull() ? pair.lhs : new NullableAggregator(pair.lhs, pair.rhs); }
Source:
<code>JSONArray getLastChannelObjectsReceivedByNewId(String id) { JSONArray lastChannelObjectReceived; try { lastChannelObjectReceived = getLastChannelObjects(); } catch (JSONException exception) { logger.log(OneSignal.LOG_LEVEL.ERROR, "Generating IAM tracker getLastChannelObjects JSONObject ", exception); return new JSONArray(); } <START> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { <END> for (int i = 0; i < lastChannelObjectReceived.length(); i++) { try { String objectId = lastChannelObjectReceived.getJSONObject(i).getString(getIdTag()); if (id.equals(objectId)) { lastChannelObjectReceived.remove(i); break; } } catch (JSONException exception) { logger.log(OneSignal.LOG_LEVEL.ERROR, "Generating tracker lastChannelObjectReceived get JSONObject ", exception); } } } else { try { JSONArray auxLastChannelObjectReceived = new JSONArray(); for (int i = 0; i < lastChannelObjectReceived.length(); i++) { String objectId = lastChannelObjectReceived.getJSONObject(i).getString(getIdTag()); if (!id.equals(objectId)) { auxLastChannelObjectReceived.put(lastChannelObjectReceived.getJSONObject(i)); } } lastChannelObjectReceived = auxLastChannelObjectReceived; } catch (JSONException exception) { logger.log(OneSignal.LOG_LEVEL.ERROR, "Before KITKAT API, Generating tracker lastChannelObjectReceived get JSONObject ", exception); } } return lastChannelObjectReceived; }</code><technical_language>Remove this Build.VERSION_CODES.KITKAT implementation in favor of implementation for versions of Android. performance benefits negotiable, prefer a simpler implementation</technical_language>

Target:
JSONArray getLastChannelObjectsReceivedByNewId(String id) { JSONArray lastChannelObjectReceived; try { lastChannelObjectReceived = getLastChannelObjects(); } catch (JSONException exception) { logger.error("Generating IAM tracker getLastChannelObjects JSONObject ", exception); return new JSONArray(); } try { JSONArray auxLastChannelObjectReceived = new JSONArray(); for (int i = 0; i < lastChannelObjectReceived.length(); i++) { String objectId = lastChannelObjectReceived.getJSONObject(i).getString(getIdTag()); if (!id.equals(objectId)) { auxLastChannelObjectReceived.put(lastChannelObjectReceived.getJSONObject(i)); } } lastChannelObjectReceived = auxLastChannelObjectReceived; } catch (JSONException exception) { logger.error("Before KITKAT API, Generating tracker lastChannelObjectReceived get JSONObject ", exception); } return lastChannelObjectReceived; }
Source:
<code>public RequestDispatcher getRequestDispatcher(String uriInContext) { if (uriInContext == null) return null; if (!uriInContext.startsWith("/")) return null; try { String contextPath = getContextPath(); HttpURI uri; String pathInfo; if (StringUtil.isEmpty(contextPath)) { uri = HttpURI.from(uriInContext); pathInfo = URIUtil.canonicalPath(uri.getDecodedPath()); if (StringUtil.isEmpty(pathInfo)) return null; } else { HttpURI.Mutable builder = HttpURI.build(uriInContext); if (StringUtil.isEmpty(URIUtil.canonicalPath(builder.getDecodedPath()))) return null; builder.path(URIUtil.addPaths(contextPath,builder.getPath())); uri = builder.asImmutable(); pathInfo = uri.getDecodedPath().substring(contextPath.length()); <START> } <END> return new Dispatcher(ContextHandler.this, uri, pathInfo); } catch (Exception e) { LOG.trace("IGNORED", e); } return null; }</code><technical_language>if branch is equal initial part of else branch, remove duplication</technical_language>

Target:
public RequestDispatcher getRequestDispatcher(String uriInContext) { if (uriInContext == null) return null; if (!uriInContext.startsWith("/")) return null; try { String contextPath = getContextPath(); String pathInfo; HttpURI.Mutable uri = HttpURI.build(uriInContext); pathInfo = URIUtil.canonicalPath(uri.getDecodedPath()); if (StringUtil.isEmpty(pathInfo)) return null; if (!StringUtil.isEmpty(contextPath)) { uri.path(URIUtil.addPaths(contextPath,uri.getPath())); pathInfo = uri.getDecodedPath().substring(contextPath.length()); } return new Dispatcher(ContextHandler.this, uri, pathInfo); } catch (Exception e) { LOG.trace("IGNORED", e); } return null; }
Source:
<code>public Set<EObject> findByFeatureValue(Object value_, EStructuralFeature _feature) { <START> Preconditions.checkArgument(IndexingLevel.FULL == getIndexingLevel(_feature), "%s is not on full index", _feature); <END> Object value = toCanonicalValueRepresentation(value_); Object feature = toKey(_feature); Set<EObject> retSet = new HashSet<EObject>(); Map<Object, Collection<EObject>> valMap = instanceStore.getValueToFeatureToHolderMap().row(value); final Collection<EObject> holders = valMap.get(feature); if (holders != null) { retSet.addAll(EMFBaseIndexInstanceStore.holderCollectionToUniqueSet(holders)); } return retSet; }</code><technical_language>Warning! This precondition check breaks compatibility! I it, I fear surprises</technical_language>

Target:
public Set<EObject> findByFeatureValue(Object value_, EStructuralFeature _feature) { Object value = toCanonicalValueRepresentation(value_); Object feature = toKey(_feature); Set<EObject> retSet = new HashSet<EObject>(); Map<Object, Collection<EObject>> valMap = instanceStore.getValueToFeatureToHolderMap().row(value); final Collection<EObject> holders = valMap.get(feature); if (holders != null) { retSet.addAll(EMFBaseIndexInstanceStore.holderCollectionToUniqueSet(holders)); } return retSet; }
Source:
<code>public void skipsOnStream() throws IOException { final long skip = 25L; final InputStream stream = Mockito.mock(InputStream.class); final CapInputStream wrapper = new CapInputStream( stream, <START> 50L <END> ); wrapper.skip(skip); Mockito.verify(stream, Mockito.times(1)).skip(skip); }</code><technical_language>@original-brownbear join lines</technical_language>

Target:
public void skipsOnStream() throws Exception { final long skip = 25L; final InputStream stream = Mockito.mock(InputStream.class); final CapInputStream wrapper = new CapInputStream(stream, 50L); wrapper.skip(skip); Mockito.verify(stream, Mockito.times(1)).skip(skip); }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent routeIntent = getIntent(); Bundle extras = routeIntent.getExtras(); if (null == routeIntent) { <START> MPLog.i(LOGTAG, "Notification route activity given null intent."); <END> return; } trackAction(routeIntent); Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(routeIntent.getExtras().getCharSequence("uri").toString())); if (!extras.getBoolean("sticky")) { cancelNotification(extras); } startActivity(notificationIntent); }</code><technical_language>info is correct log level. Is this expect happen? If not, warning level, debug level</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent routeIntent = getIntent(); Bundle extras = routeIntent.getExtras(); if (null == routeIntent) { MPLog.d(LOGTAG, "Notification route activity given null intent."); return; } trackAction(routeIntent); final Intent notificationIntent = handleRouteIntent(routeIntent); if (!extras.getBoolean("sticky")) { MixpanelFCMMessagingService fcmMessagingService = new MixpanelFCMMessagingService(); NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(getApplicationContext().NOTIFICATION_SERVICE); fcmMessagingService.cancelNotification(extras, notificationManager); } startActivity(notificationIntent); }
Source:
<code>public HttpClient get() { final DruidHttpClientConfig config = getConfigProvider().get().get(); final HttpClient httpClient; if (getSslContextBinding() != null) { final SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setSslContext(getSslContextBinding().getProvider().get()); httpClient = new HttpClient(sslContextFactory); } else { httpClient = new HttpClient(); } httpClient.setIdleTimeout(config.getReadTimeout().getMillis()); httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); <START> httpClient.setConnectTimeout(500); <END> final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads()); pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode()); httpClient.setExecutor(pool); final Lifecycle lifecycle = getLifecycleProvider().get(); try { lifecycle.addMaybeStartHandler( new Lifecycle.Handler() { @Override public void start() throws Exception { } @Override public void stop() { try { httpClient.stop(); } catch (Exception e) { throw Throwables.propagate(e); } } } ); } catch (Exception e) { throw Throwables.propagate(e); } return httpClient; }</code><technical_language>CANCELLATION_TIMEOUT_MILLIS instead of 500</technical_language>

Target:
public HttpClient get() { final DruidHttpClientConfig config = getConfigProvider().get().get(); final HttpClient httpClient; if (getSslContextBinding() != null) { final SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setSslContext(getSslContextBinding().getProvider().get()); httpClient = new HttpClient(sslContextFactory); } else { httpClient = new HttpClient(); } httpClient.setIdleTimeout(config.getReadTimeout().getMillis()); httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT); final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads()); pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode()); httpClient.setExecutor(pool); final Lifecycle lifecycle = getLifecycleProvider().get(); try { lifecycle.addMaybeStartHandler( new Lifecycle.Handler() { @Override public void start() throws Exception { } @Override public void stop() { try { httpClient.stop(); } catch (Exception e) { throw Throwables.propagate(e); } } } ); } catch (Exception e) { throw Throwables.propagate(e); } return httpClient; }
Source:
<code>public ConfigBuilder appendTo(URI uri) { <START> setOverwrite(); <END> return writeTo(uri); }</code><technical_language>setAppend()</technical_language>

Target:
public ConfigBuilder appendTo(URI uri) { setAppend(); return writeTo(uri); }
Source:
<code>public Matrix feedForward(final Matrix input) { if (output == null || output.getColumns() != input.getColumns()) { <START> output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); <END> } for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; }</code><technical_language>Free</technical_language>

Target:
public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; }
Source:
<code>public void setEnvironment(Cache<K, V> cache, Set<K> inputKeys) { cacheManager = cache.getCacheManager(); cacheNotifier = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheNotifier.class); cacheManagerNotifier = cache.getCacheManager().getGlobalComponentRegistry().getComponent( CacheManagerNotifier.class); <START> distExecutor = new DefaultExecutorService(cache); <END> ourAddress = cache.getCacheManager().getAddress(); }</code><technical_language>a WithinThreadExecutor here? This constructor creates a new single-threaded executor, thread is allocated for cluster listenre</technical_language>

Target:
public void setEnvironment(Cache<K, V> cache, Set<K> inputKeys) { cacheManager = cache.getCacheManager(); cacheNotifier = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheNotifier.class); cacheManagerNotifier = cache.getCacheManager().getGlobalComponentRegistry().getComponent( CacheManagerNotifier.class); distExecutor = new DefaultExecutorService(cache, new WithinThreadExecutor()); ourAddress = cache.getCacheManager().getAddress(); }
Source:
<code>public DataTransactionResult removePassenger(Entity entity) { checkNotNull(entity); <START> if (!entity.getPassengers().contains(this)) { <END> throw new IllegalArgumentException(String.format("Cannot remove entity %s as a passenger of %s, because the former is not a passenger " + "of the latter ", entity, this)); } final DataTransactionResult.Builder builder = DataTransactionResult.builder(); this.removePassenger((net.minecraft.entity.Entity) entity); final ImmutableList.Builder<EntitySnapshot> passengerSnapshotsBuilder = ImmutableList.builder(); passengerSnapshotsBuilder.addAll(getPassengers().stream().map(Entity::createSnapshot).collect(Collectors.toList())); return builder.result(DataTransactionResult.Type.SUCCESS).success(new ImmutableSpongeListValue<>(Keys.PASSENGERS, passengerSnapshotsBuilder .build())).build(); }</code><technical_language>This backwards</technical_language>

Target:
public void removePassenger(Entity entity) { checkNotNull(entity); if (!entity.getPassengers().contains(this)) { throw new IllegalArgumentException(String.format("Cannot remove entity %s, because it is not a passenger of %s ", entity, this)); } ((net.minecraft.entity.Entity) entity).dismountRidingEntity(); }
Source:
<code>private static AbstractPollingScheduler createDisabledPollingScheduler() { return new AbstractPollingScheduler() { @Override protected void schedule(Runnable pollingRunnable) { <START> LOGGER.info("Periodical polling of a configuration source is turned off!"); <END> } @Override public void stop() { } }; }</code><technical_language>Is this logged x period? if change log level debug</technical_language>

Target:
private static AbstractPollingScheduler createDisabledPollingScheduler() { return new AbstractPollingScheduler() { @Override protected void schedule(Runnable pollingRunnable) { logger.info("Periodical polling of a configuration source is turned off!"); } @Override public void stop() { } }; }
Source:
<code>static public void reportPhysicalMemory() { com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean(); long physicalMemorySize = os.getTotalPhysicalMemorySize(); System.out.println("************ SYSTEM Physical Memory:" + physicalMemorySize); <START> int MB = 1024 * 1024; <END> Runtime runtime = Runtime.getRuntime(); long free = runtime.freeMemory()/MB; long total = runtime.totalMemory()/MB; System.out.println("************ total memory:" + total + " free memory:" + free); }</code><technical_language>minor: int -> long</technical_language>

Target:
static public void reportPhysicalMemory() { com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean(); long physicalMemorySize = os.getTotalPhysicalMemorySize(); System.out.println("************ SYSTEM Physical Memory:" + physicalMemorySize); long MB = 1024 * 1024; Runtime runtime = Runtime.getRuntime(); long free = runtime.freeMemory()/MB; long total = runtime.totalMemory()/MB; System.out.println("************ total memory:" + total + " free memory:" + free); }
Source:
<code><START> FunctionExpr(Function function, String name, List<Expr> args) <END> { this.function = function; this.name = name; this.args = args; }</code><technical_language>nit: if, in Druid, generally try do access control package level... I private/public/protected needed</technical_language>

Target:
FunctionExpr(Function function, String name, List<Expr> args) { this.function = function; this.name = name; this.args = ImmutableList.copyOf(args); function.validateArguments(args); }
Source:
<code>private String getReason(MergeFailureReason mergeFailureReason) { switch (mergeFailureReason) { case COULD_NOT_DELETE: return UIText.CherryPickHandler_CouldNotDeleteFile; case DIRTY_INDEX: return UIText.CherryPickHandler_IndexDirty; case DIRTY_WORKTREE: return UIText.CherryPickHandler_WorktreeDirty; } <START> return "unknown"; END> }</code><technical_language>this text translatable is construct error message displayed user</technical_language>

Target:
private String getReason(MergeFailureReason mergeFailureReason) { switch (mergeFailureReason) { case COULD_NOT_DELETE: return UIText.CherryPickHandler_CouldNotDeleteFile; case DIRTY_INDEX: return UIText.CherryPickHandler_IndexDirty; case DIRTY_WORKTREE: return UIText.CherryPickHandler_WorktreeDirty; } return UIText.CherryPickHandler_unknown; }
Source:
<code>protected LockProperties applyLockProperties(LockProperties lockProperties) { <START> return lockProperties.withScope(Scope.Command); <END> }</code><technical_language>Scope.Execution ? child commands involved here</technical_language>

Target:
protected LockProperties applyLockProperties(LockProperties lockProperties) { return lockProperties.withScope(Scope.Execution); }
Source:
<code>public void cleanup() { synchronizer.globalBarrier(); final long sleepMillis = 100; int numRetries = 20; <START> while (numRetries > 0) { <END> numRetries--; try { if (validate()) { return; } } catch (final IntegerValidationException e) { if (numRetries > 0) { try { Thread.sleep(sleepMillis); } catch (final InterruptedException e1) { LOG.log(Level.WARNING, "Interrupted while sleeping to compare the result with expected value", e); } } else { throw new RuntimeException(e); } } } }</code><technical_language>This combination of while if-elses hard parse. simplify logic a bit</technical_language>

Target:
public void cleanup() { synchronizer.globalBarrier(); int numRetries = NUM_VALIDATE_RETRIES; while (numRetries-- > 0) { if (validate()) { return; } try { Thread.sleep(VALIDATE_SLEEP_MS); } catch (final InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while sleeping to compare the result with expected value", e); } } LOG.log(Level.WARNING, "Validation test is failed"); throw new RuntimeException(); }
Source:
<code>protected static void writeException(JsonGenerator jg, Throwable t, MediaType mediaType, int statusCode) throws IOException { jg.writeStartObject(); jg.writeStringField("entity-type", "exception"); jg.writeNumberField("status", statusCode); jg.writeStringField("message", t.getMessage()); if (jsonFactoryManager.isStackDisplay() <START> || MediaType.valueOf(MediaType.APPLICATION_JSON + "+nxentity").equals(mediaType) || true) { <END> jg.writeStringField("stacktrace", getStackTraceString(t)); jg.writeObjectField("exception", t); } jg.writeEndObject(); jg.flush(); }</code><technical_language>|| true wanted? this test code</technical_language>

Target:
protected static void writeException(JsonGenerator jg, Throwable t, MediaType mediaType, int statusCode) throws IOException { jg.writeStartObject(); jg.writeStringField("entity-type", "exception"); jg.writeNumberField("status", statusCode); jg.writeStringField("message", t.getMessage()); if (jsonFactoryManager.isStackDisplay() || MediaType.valueOf(MediaType.APPLICATION_JSON + "+nxentity").equals(mediaType)) { jg.writeStringField("stacktrace", getStackTraceString(t)); jg.writeObjectField("exception", t); } jg.writeEndObject(); jg.flush(); }
Source:
<code>public void testClearState() throws Exception { final HiddenFieldCheck check = new HiddenFieldCheck(); final Optional<DetailAST> classDef = TestUtil.findTokenInAstByPredicate( JavaParser.parseFile( new File(getPath("InputHiddenField.java")), JavaParser.Options.WITHOUT_COMMENTS), <START> ast -> ast.getType() == TokenTypes.CLASS_DEF); <END> assertTrue("Ast should contain CLASS_DEF", classDef.isPresent()); assertTrue("State is not cleared on beginTree", TestUtil.isStatefulFieldClearedDuringBeginTree( check, classDef.get(), "frame", frame -> { boolean result = frame != null; if (result) { final Class<?> frameClass = frame.getClass(); try { if (TestUtil.getClassDeclaredField(frameClass, "parent").get( frame) != null || !((Boolean) TestUtil.getClassDeclaredField(frameClass, "staticType").get(frame)) || TestUtil.getClassDeclaredField(frameClass, "frameName").get(frame) != null) { result = false; } } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) { throw new IllegalStateException(ex); } } return result; })); }</code><technical_language>please move JavaParser.parseFile out some local variable. is hard read this code</technical_language>

Target:
public void testClearState() throws Exception { final HiddenFieldCheck check = new HiddenFieldCheck(); final DetailAST root = JavaParser.parseFile(new File(getPath("InputHiddenField.java")), JavaParser.Options.WITHOUT_COMMENTS); final Optional<DetailAST> classDef = TestUtil.findTokenInAstByPredicate(root, ast -> ast.getType() == TokenTypes.CLASS_DEF); assertTrue("Ast should contain CLASS_DEF", classDef.isPresent()); assertTrue("State is not cleared on beginTree", TestUtil.isStatefulFieldClearedDuringBeginTree(check, classDef.get(), "frame", new CheckIfStatefulFieldCleared())); }