auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private TableSourceTable applyLimit( long limit, FlinkPreparingTableBase relOptTable) { TableSourceTable oldTableSourceTable = relOptTable.unwrap(TableSourceTable.class); DynamicTableSource newTableSource = oldTableSourceTable.tableSource().copy(); ((SupportsLimitPushDown) newTableSource).applyLimit(limit); FlinkStatistic statistic = relOptTable.getStatistic(); long newRowCount = 0; if (statistic.getRowCount() != null) { newRowCount = Math.min(limit, statistic.getRowCount().longValue()); } else { newRowCount = limit; } TableStats newTableStats = new TableStats(newRowCount); FlinkStatistic newStatistic = FlinkStatistic.builder() .statistic(statistic) .tableStats(newTableStats) .build(); String[] newExtraDigests = new String[0]; <START> if (limit > 0) { <END> String extraDigest = "limit=[" + limit + "]"; newExtraDigests = new String[]{extraDigest}; } return oldTableSourceTable.copy( newTableSource, newStatistic, newExtraDigests ); }</code><technical_language>update digest anyway, rule applied endless loop if limit is 0</technical_language>

Target:
private TableSourceTable applyLimit( long limit, FlinkPreparingTableBase relOptTable) { TableSourceTable oldTableSourceTable = relOptTable.unwrap(TableSourceTable.class); DynamicTableSource newTableSource = oldTableSourceTable.tableSource().copy(); ((SupportsLimitPushDown) newTableSource).applyLimit(limit); FlinkStatistic statistic = relOptTable.getStatistic(); long newRowCount = 0; if (statistic.getRowCount() != null) { newRowCount = Math.min(limit, statistic.getRowCount().longValue()); } else { newRowCount = limit; } TableStats newTableStats = new TableStats(newRowCount); FlinkStatistic newStatistic = FlinkStatistic.builder() .statistic(statistic) .tableStats(newTableStats) .build(); String[] newExtraDigests = new String[]{"limit=[" + limit + "]"}; return oldTableSourceTable.copy( newTableSource, newStatistic, newExtraDigests ); }
Source:
<code>public void onCreate(Bundle savedInstanceState) <START> { <END> super.onCreate(savedInstanceState); setContentView(R.layout.video_selector); mSelectList = (ListView) findViewById(R.id.select_list); final Button playButton = (Button) findViewById(R.id.play_button); mUrlText = (EditText) findViewById(R.id.video_selection_input); mSelectItems = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { setUpInitialItemList(); } else { requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE); } } else { setUpInitialItemList(); } playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent launch = createLaunchIntent( VideoSelector.this, mUrlText.getText().toString()); startActivity(launch); } }); mLoopingCheckbox = findViewById(R.id.looping_checkbox); mLoopingCheckbox.setChecked(false); mTextureViewCheckbox = findViewById(R.id.use_textureview_checkbox); mTextureViewCheckbox.setChecked(false); mAdvertisementCheckBox = findViewById(R.id.media_type_advertisement); mAdvertisementCheckBox.setChecked(false); }</code><technical_language>In opinion, turn StrictMode (not in VideoViewTest activity) VideoSelector activity is main entry point. move code StrictMode.setThreadPolicy... VideoViewTest activity VideoSelector activity</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyDeath() .build()); setContentView(R.layout.video_selector); mSelectList = (ListView) findViewById(R.id.select_list); final Button playButton = (Button) findViewById(R.id.play_button); mUrlText = (EditText) findViewById(R.id.video_selection_input); mSelectItems = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { setUpInitialItemList(); } else { requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE); } } else { setUpInitialItemList(); } playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent launch = createLaunchIntent( VideoSelector.this, mUrlText.getText().toString()); startActivity(launch); } }); mLoopingCheckbox = findViewById(R.id.looping_checkbox); mLoopingCheckbox.setChecked(false); mTextureViewCheckbox = findViewById(R.id.use_textureview_checkbox); mTextureViewCheckbox.setChecked(false); mAdvertisementCheckBox = findViewById(R.id.media_type_advertisement); mAdvertisementCheckBox.setChecked(false); }
Source:
<code>public List<Device> getDevicesOfUser(String username, String deviceType, boolean requireDeviceInfo) throws DeviceManagementException { <START> if (username != null && deviceType != null) { <END> if (log.isDebugEnabled()) { log.debug("Get '" + deviceType + "' devices of user with username '" + username + "' requiredDeviceInfo: " + requireDeviceInfo); } } else { String msg = "received incomplete data for getDevicesOfUser"; log.error(msg); throw new DeviceManagementException(msg); } List<Device> userDevices; try { DeviceManagementDAOFactory.openConnection(); userDevices = deviceDAO.getDevicesOfUser(username, deviceType, this.getTenantId()); } catch (DeviceManagementDAOException e) { String msg = "Error occurred while retrieving the list of devices that " + "belong to the user '" + username + "'"; log.error(msg, e); throw new DeviceManagementException(msg, e); } catch (SQLException e) { String msg = "Error occurred while opening a connection to the data source"; log.error(msg); throw new DeviceManagementException(msg, e); } catch (Exception e) { String msg = "Error occurred"; log.error(msg, e); throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } if (requireDeviceInfo) { return this.getAllDeviceInfo(userDevices); } return userDevices; }</code><technical_language>Check for empty strings well. builtin methods StringUtils.isBlank appropriate. Please do for applicable places</technical_language>

Target:
public List<Device> getDevicesOfUser(String username, String deviceType, boolean requireDeviceInfo) throws DeviceManagementException { if (username == null || deviceType == null) { String msg = "Received incomplete data for getDevicesOfUser"; log.error(msg); throw new DeviceManagementException(msg); } if (log.isDebugEnabled()) { log.debug("Get '" + deviceType + "' devices of user with username '" + username + "' requiredDeviceInfo: " + requireDeviceInfo); } List<Device> userDevices; try { DeviceManagementDAOFactory.openConnection(); userDevices = deviceDAO.getDevicesOfUser(username, deviceType, this.getTenantId()); } catch (DeviceManagementDAOException e) { String msg = "Error occurred while retrieving the list of devices that " + "belong to the user '" + username + "'"; log.error(msg, e); throw new DeviceManagementException(msg, e); } catch (SQLException e) { String msg = "Error occurred while opening a connection to the data source"; log.error(msg); throw new DeviceManagementException(msg, e); } catch (Exception e) { String msg = "Error occurred in getDevicesOfUser for '" + username + "'"; log.error(msg, e); throw new DeviceManagementException(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } if (requireDeviceInfo) { return this.getAllDeviceInfo(userDevices); } return userDevices; }
Source:
<code>public Transaction getTransactionById(Object id) { <START> return com.arjuna.ats.internal.jta.transaction.jts.TransactionImple.getTransaction((Uid) id); <END> }</code><technical_language>Try remove package</technical_language>

Target:
public Transaction getTransactionById(Object id) { return TransactionImple.getTransaction((Uid) id); }
Source:
<code>private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); try { synchronized (mPublicSync) { mWifiTetherRequested = enable; final WifiManager mgr = getWifiManager(); if (mgr == null) { <START> Log.e(TAG, <END> "setWifiTethering: failed to get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null )) || (!enable && mgr.stopSoftAp())) { rval = TETHER_ERROR_NO_ERROR; } } } finally { Binder.restoreCallingIdentity(ident); } return rval; }</code><technical_language>For new adding error level log, please mLog.e log entry added system log dumpsys section</technical_language>

Target:
private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); try { synchronized (mPublicSync) { mWifiTetherRequested = enable; final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e(TAG, "setWifiTethering: failed to get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null )) || (!enable && mgr.stopSoftAp())) { rval = TETHER_ERROR_NO_ERROR; } } } finally { Binder.restoreCallingIdentity(ident); } return rval; }
Source:
<code>public void stateChanged(final ChangeEvent<ServerDescription> event) { description = event.getNewValue(); <START> for (final ChangeListener<ServerDescription> listener : changeListeners) { <END> listener.stateChanged(event); } }</code><technical_language>Local variable: final needed. Is IDE configured differently checkstyle</technical_language>

Target:
public void stateChanged(final ChangeEvent<ServerDescription> event) { description = event.getNewValue(); for (ChangeListener<ServerDescription> listener : changeListeners) { listener.stateChanged(event); } }
Source:
<code>private ResourceModel parseResource(Node item) { Integer id = Integer.valueOf(item.getAttributes().getNamedItem("ID").getTextContent()); String name = null; Operations operations = Operations.NONE; boolean multiple = false; boolean mandatory = false; Type type = Type.STRING; String rangeEnumeration = null; String units = null; String description = null; for (int i = 0; i < item.getChildNodes().getLength(); i++) { Node field = item.getChildNodes().item(i); switch (field.getNodeName()) { case "Name": name = field.getTextContent(); break; case "Operations": String strOp = field.getTextContent(); if (strOp != null && !strOp.isEmpty()) { operations = Operations.valueOf(strOp); } break; case "MultipleInstances": multiple = "Multiple".equals(field.getTextContent()); break; case "Mandatory": mandatory = "Mandatory".equals(field.getTextContent()); break; case "Type": switch (field.getTextContent()) { case "String": type = Type.STRING; break; case "Integer": type = Type.INTEGER; break; case "Float": type = Type.FLOAT; break; case "Boolean": type = Type.BOOLEAN; break; case "Opaque": type = Type.OPAQUE; break; case "Time": type = Type.TIME; break; <START> case "Objlnk": <END> type = Type.OBJECTLINK; break; } break; case "RangeEnumeration": rangeEnumeration = field.getTextContent(); break; case "Units": units = field.getTextContent(); break; case "Description": description = field.getTextContent(); break; } } return new ResourceModel(id, name, operations, multiple, mandatory, type, rangeEnumeration, units, description); }</code><technical_language>IMO adding Object link part of another pull request, a feature</technical_language>

Target:
private ResourceModel parseResource(Node item) { Integer id = Integer.valueOf(item.getAttributes().getNamedItem("ID").getTextContent()); String name = null; Operations operations = Operations.NONE; boolean multiple = false; boolean mandatory = false; Type type = Type.STRING; String rangeEnumeration = null; String units = null; String description = null; for (int i = 0; i < item.getChildNodes().getLength(); i++) { Node field = item.getChildNodes().item(i); switch (field.getNodeName()) { case "Name": name = field.getTextContent(); break; case "Operations": String strOp = field.getTextContent(); if (strOp != null && !strOp.isEmpty()) { operations = Operations.valueOf(strOp); } break; case "MultipleInstances": multiple = "Multiple".equals(field.getTextContent()); break; case "Mandatory": mandatory = "Mandatory".equals(field.getTextContent()); break; case "Type": switch (field.getTextContent()) { case "String": type = Type.STRING; break; case "Integer": type = Type.INTEGER; break; case "Float": type = Type.FLOAT; break; case "Boolean": type = Type.BOOLEAN; break; case "Opaque": type = Type.OPAQUE; break; case "Time": type = Type.TIME; break; } break; case "RangeEnumeration": rangeEnumeration = field.getTextContent(); break; case "Units": units = field.getTextContent(); break; case "Description": description = field.getTextContent(); break; } } return new ResourceModel(id, name, operations, multiple, mandatory, type, rangeEnumeration, units, description); }
Source:
<code>MessageCreator(String source, List<String> destination, String text) { if (!Utils.allNotNull(source, destination)) { <START> throw new IllegalArgumentException("source, destination and text must not be null"); <END> } if (destination.contains(source)) { throw new IllegalArgumentException("destination cannot include source"); } this.source = source; this.destination = destination; this.text = text; }</code><technical_language>Change error string well. checking for text == null here, error checking text. for similar</technical_language>

Target:
MessageCreator(String source, List<String> destination, String text) { if (!Utils.allNotNull(source, destination)) { throw new IllegalArgumentException("source, destination must not be null"); } if (destination.contains(source)) { throw new IllegalArgumentException("destination cannot include source"); } this.source = source; this.destination = destination; this.text = text; }
Source:
<code>private byte[] ungzip(byte[] body) { <START> ByteArrayInputStream bytein = new ByteArrayInputStream(body); <END> GZIPInputStream gzin = null; try { gzin = new GZIPInputStream(bytein); ByteArrayOutputStream byteout = new ByteArrayOutputStream(); int res = 0; byte buf[] = new byte[1024]; while (res >= 0) { res = gzin.read(buf, 0, buf.length); if (res > 0) { byteout.write(buf, 0, res); } } byte uncompressed[] = byteout.toByteArray(); return uncompressed; } catch (IOException e) { return null; } }</code><technical_language>closed? try (ByteArrayInputStream bytein = new ByteArrayInputStream(body); GZIPInputStream gzin = new GZIPInputStream(bytein); ByteArrayOutputStream byteout = new ByteArrayOutputStream();) { ... }</technical_language>

Target:
private byte[] ungzip(byte[] body) { ByteArrayInputStream bytein = new ByteArrayInputStream(body); try (GZIPInputStream gzin = new GZIPInputStream(bytein); ByteArrayOutputStream byteout = new ByteArrayOutputStream()) { int res = 0; byte buf[] = new byte[1024]; while (res >= 0) { res = gzin.read(buf, 0, buf.length); if (res > 0) { byteout.write(buf, 0, res); } } byte uncompressed[] = byteout.toByteArray(); return uncompressed; } catch (IOException e) { } return null; }
Source:
<code>public void testBuildMessageNumberSetsWithOneString() throws ImapAsyncClientException { final String msgSetStr = "1"; final MessageNumberSet messageNumberSet = new MessageNumberSet(1, 1); final MessageNumberSet[] messageNumberSets = MessageNumberSet.buildMessageNumberSets(msgSetStr); Assert.assertNotNull(messageNumberSets, "Result mismatched."); Assert.assertEquals(messageNumberSets.length, 1, "Result mismatched."); <START> Assert.assertTrue(messageNumberSets[0].equals(messageNumberSet), "Result mismatched"); <END> }</code><technical_language>assertEquals a fit</technical_language>

Target:
public void testBuildMessageNumberSetsWithOneString() throws ImapAsyncClientException { final MessageNumberSet[] expectedMsgSets = { new MessageNumberSet(1, 1) }; final String msgSetStr = MessageNumberSet.buildString(expectedMsgSets); final MessageNumberSet[] actualMsgSets = MessageNumberSet.buildMessageNumberSets(msgSetStr); Assert.assertNotNull(actualMsgSets, "buildMessageNumberSets() should not return null."); Assert.assertEquals(actualMsgSets.length, 1, "buildMessageNumberSets() size mismatched."); Assert.assertEquals(actualMsgSets[0], expectedMsgSets[0], "buildMessageNumberSets() mismatched."); }
Source:
<code><START> public static int get(String token) { <END> int type = reservedKeys.get(token, -1); if (type == -1) { return commandSet.get(token, -1); } return type; }</code><technical_language>This package visibility now</technical_language>

Target:
static int get(String token) { int type = reservedKeys.get(token, -1); if (type == -1) { return commandSet.get(token, -1); } return type; }
Source:
<code>public Object fromBytes(byte[] bytes) { try { final Object object; final MessageType type = MessageType.values()[bytes[0]]; final byte data = Arrays.copyOfRange(bytes, 1, bytes.length); switch (type) { case USER_MESSAGE: object = userMessageSerde.fromBytes(data); break; case WATERMARK: object = watermarkSerde.fromBytes(data); break; case END_OF_STREAM: object = eosSerde.fromBytes(data); break; default: object = null; break; } return object; } catch (Exception e) { <START> return userMessageSerde.fromBytes(bytes); <END> } }</code><technical_language>safer fail early instead of attempting de-serialize user-provided serde</technical_language>

Target:
public Object fromBytes(byte[] bytes) { try { final Object object; final MessageType type = MessageType.values()[bytes[0]]; final byte data = Arrays.copyOfRange(bytes, 1, bytes.length); switch (type) { case USER_MESSAGE: object = userMessageSerde.fromBytes(data); break; case WATERMARK: object = watermarkSerde.fromBytes(data); break; case END_OF_STREAM: object = eosSerde.fromBytes(data); break; default: throw new UnsupportedOperationException(String.format("Message type %s is not supported", type.name())); } return object; } catch (UnsupportedOperationException ue) { throw new SamzaException(ue); } catch (Exception e) { return userMessageSerde.fromBytes(bytes); } }
Source:
<code>public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { <START> return (getFacing() == facing && energyManager.hasCapability(capability)) || <END> super.hasCapability(capability, facing); }</code><technical_language>Engines receive energy chain, I this change break it</technical_language>

Target:
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return (facing == getFacing() && energyManager.hasCapability(capability)) || super.hasCapability(capability, facing); }
Source:
<code>private void sendAvailablePresenceWithClientIdentifier() { String ver = EntityCapsManager.getInstanceFor(connection).getCapsVersion(); <START> CapsExtension caps = new CapsExtension(XMPP_CLIENT_IDENTIFIER, ver, "sha-1"); <END> Presence p = new Presence(Presence.Type.available); p.addExtension(caps); connection.sendPacket(p); }</code><technical_language>Move hashing algorithm choice static constant easier notice class</technical_language>

Target:
private void sendAvailablePresenceWithClientIdentifier() { String version = EntityCapsManager.getInstanceFor(connection).getCapsVersion(); CapsExtension caps = new CapsExtension(XMPP_CLIENT_IDENTIFIER, version, CAPS_HASH_ALGORITHM); Presence presence = new Presence(Presence.Type.available); presence.addExtension(caps); connection.sendPacket(presence); }
Source:
<code>public boolean isSnapshot() { String version = getVersion(); <START> if (StringUtils.isNotBlank(version)) { <END> if (version.contains("SNAPSHOT")) { return true; } } return false; }</code><technical_language>Sorry, picky: return StringUtils.isNotBlank(version) && version.contains("SNAPSHOT");</technical_language>

Target:
public boolean isSnapshot() { String version = getVersion(); return StringUtils.isNotBlank(version) && version.contains("SNAPSHOT"); }
Source:
<code>protected void configure() { bind(RequestCleanup.class).in(RequestScoped.class); bind(ReviewDb.class).toProvider(RequestScopedReviewDbProvider.class).in( RequestScoped.class); bind(IdentifiedUser.RequestFactory.class).in(SINGLETON); bind(AccountResolver.class); <START> install(new PredicateModule()); <END> bind(ChangeQueryRewriter.class); bind(ChangeControl.Factory.class).in(SINGLETON); bind(GroupControl.Factory.class).in(SINGLETON); bind(ProjectControl.Factory.class).in(SINGLETON); factory(ChangeQueryBuilder.Factory.class); factory(ReceiveCommits.Factory.class); factory(MergeOp.Factory.class); factory(AddReviewerSender.Factory.class); factory(CreateChangeSender.Factory.class); factory(PublishComments.Factory.class); factory(ReplacePatchSetSender.Factory.class); factory(AbandonedSender.Factory.class); factory(CommentSender.Factory.class); factory(MergedSender.Factory.class); factory(MergeFailSender.Factory.class); factory(RegisterNewEmailSender.Factory.class); }</code><technical_language>Lets call this ChangeQueryModule instead</technical_language>

Target:
protected void configure() { bind(RequestCleanup.class).in(RequestScoped.class); bind(ReviewDb.class).toProvider(RequestScopedReviewDbProvider.class).in( RequestScoped.class); bind(IdentifiedUser.RequestFactory.class).in(SINGLETON); bind(AccountResolver.class); install(new ChangeQueryModule()); bind(ChangeControl.Factory.class).in(SINGLETON); bind(GroupControl.Factory.class).in(SINGLETON); bind(ProjectControl.Factory.class).in(SINGLETON); factory(ReceiveCommits.Factory.class); factory(MergeOp.Factory.class); factory(AddReviewerSender.Factory.class); factory(CreateChangeSender.Factory.class); factory(PublishComments.Factory.class); factory(ReplacePatchSetSender.Factory.class); factory(AbandonedSender.Factory.class); factory(CommentSender.Factory.class); factory(MergedSender.Factory.class); factory(MergeFailSender.Factory.class); factory(RegisterNewEmailSender.Factory.class); }
Source:
<code>public String getText() { String arrayText = ""; if(textArr != null){ <START> for(int i = 0;i < textArr.length;i++) arrayText += textArr[i] + "\n"; <END> } if(text.get() != "") return text.get() + "\n" + arrayText; return text.get() + arrayText; }</code><technical_language>replace this a String join call -- more robust is easier read</technical_language>

Target:
public String getText() { String arrayText = ""; if(linesOfText.length > 0) { arrayText = String.join("\n", linesOfText); } if(text.get() != "") { return text.get() + "\n" + arrayText; } return text.get() + arrayText; }
Source:
<code>public List<T> getNextValues() { <START> if(endOfInput) { <END> return (List<T>) Collections.emptyList(); } int retryAttempt = 0; while(true) { final GetBucketRequest request = new GetBucketRequest(bucket); request.withMaxKeys(maxKeys); if (prefix != null) { request.withPrefix(prefix); } if (truncated) { request.withMarker(nextMarker); } if (delimiter != null) { request.withDelimiter(delimiter); } GetBucketResponse response; try { response = this.client.getBucket(request); } catch (final FailedRequestException e) { throw new RuntimeException("Failed to get the list of objects due to a failed request", e); } catch (final IOException e) { if (retryAttempt >= retryCount) { throw new TooManyRetriesException("Failed to get the next set of objects from the getBucketKey request after " + retryCount + " retries", e); } response = null; } if (response == null) { retryAttempt++; } else { final ListBucketResult result = response.getListBucketResult(); truncated = result.getTruncated(); this.nextMarker = result.getNextMarker(); if (Guard.isStringNullOrEmpty(nextMarker) && !truncated) { endOfInput = true; } return function.apply(result); } } }</code><technical_language>Missing a space if (</technical_language>

Target:
public Iterable<T> getNextValues() { if (endOfInput) { return emptyList; } int retryAttempt = 0; while (retryCount > retryAttempt) { final GetBucketRequest request = prepRequest(); final ListBucketResult result; final GetBucketResponse response; try { response = this.client.getBucket(request); } catch (final FailedRequestException e) { throw new FailedToGetBucketException("Failed to get the list of objects due to a failed request", e); } catch (final IOException e) { retryAttempt++; continue; } result = response.getListBucketResult(); this.truncated = result.getTruncated(); this.nextMarker = result.getNextMarker(); if (Guard.isStringNullOrEmpty(nextMarker) && !truncated) { endOfInput = true; } return function.apply(result); } throw new TooManyRetriesException("Failed to get the next set of objects from the getBucketKey request after " + retryCount + " retries"); }
Source:
<code>public void testCharLiteralSurrogatePair() throws Exception { <START> if (Charset.isSupported("windows-1252")) { <END> verifyAst(getPath("InputCharLiteralSurrogatePair_windows-1252.txt"), getPath("InputCharLiteralSurrogatePair.java")); } else { verifyAst(getPath("InputCharLiteralSurrogatePair.txt"), getPath("InputCharLiteralSurrogatePair.java")); } }</code><technical_language>Please AbstractPathTestSupport.readFile ascertain file read in UTF8</technical_language>

Target:
public void testCharLiteralSurrogatePair() throws Exception { verifyAst(getPath("InputCharLiteralSurrogatePair.txt"), getPath("InputCharLiteralSurrogatePair.java")); }
Source:
<code>public void replaceWithMoreThanMaxItems() { List<Object> items = createItems(); Collection<String> messageItems = ReplacementUtils.replaceWith(PROPERTY_NAME, items); validateMessageContainsProperties(messageItems); Iterator<String> messageIterator = messageItems.iterator(); <START> validateMessageDoesNotContainUnexpectedItems(messageIterator.next(), items); <END> assertTrue(messageIterator.next().contains(String.valueOf(items.size()))); }</code><technical_language>Collection guarantee order, problematic test 1st item is message 2nd is count</technical_language>

Target:
public void replaceWithMoreThanMaxItems() { List<Object> items = createItems(); Collection<String> replacements = ReplacementUtils.replaceWith(PROPERTY_NAME, items); validateReplacementsContainsExpectedProperties(replacements, items); validateReplacementsDoNotContainUnexpectedItems(replacements, items); }
Source:
<code>private <T extends ExecutorService> T createExecutorService(ThreadPoolConfiguration threadPoolConfiguration, String componentName, ExecutorServiceType type) { ThreadFactory threadFactory; ThreadPoolExecutorFactory executorFactory; if (threadPoolConfiguration != null) { threadFactory = threadPoolConfiguration.threadFactory() != null ? threadPoolConfiguration.threadFactory() : createThreadFactoryWithDefaults(globalConfiguration, componentName); executorFactory = threadPoolConfiguration.threadPoolFactory() != null ? threadPoolConfiguration.threadPoolFactory() : createThreadPoolFactoryWithDefaults(componentName, type); } else { threadFactory = createThreadFactoryWithDefaults(globalConfiguration, componentName); executorFactory = createThreadPoolFactoryWithDefaults(componentName, type); } switch (type) { case SCHEDULED: return (T) new LazyInitializingScheduledExecutorService(executorFactory, threadFactory); case BLOCKING: return (T) new LazyInitializingBlockingTaskAwareExecutorService(executorFactory, threadFactory, globalComponentRegistry.getTimeService(), "Controller-" + shortened(componentName) + <START> "-" + globalConfiguration.transport().nodeName()); <END> default: return (T) new LazyInitializingExecutorService(executorFactory, threadFactory); } }</code><technical_language>I a local variable for thread name better</technical_language>

Target:
private <T extends ExecutorService> T createExecutorService(ThreadPoolConfiguration threadPoolConfiguration, String componentName, ExecutorServiceType type) { ThreadFactory threadFactory; ThreadPoolExecutorFactory executorFactory; if (threadPoolConfiguration != null) { threadFactory = threadPoolConfiguration.threadFactory() != null ? threadPoolConfiguration.threadFactory() : createThreadFactoryWithDefaults(globalConfiguration, componentName); executorFactory = threadPoolConfiguration.threadPoolFactory() != null ? threadPoolConfiguration.threadPoolFactory() : createThreadPoolFactoryWithDefaults(componentName, type); } else { threadFactory = createThreadFactoryWithDefaults(globalConfiguration, componentName); executorFactory = createThreadPoolFactoryWithDefaults(componentName, type); } switch (type) { case SCHEDULED: return (T) new LazyInitializingScheduledExecutorService(executorFactory, threadFactory); case BLOCKING: final String controllerName = "Controller-" + shortened(componentName) + "-" + globalConfiguration.transport().nodeName(); return (T) new LazyInitializingBlockingTaskAwareExecutorService(executorFactory, threadFactory, globalComponentRegistry.getTimeService(), controllerName); default: return (T) new LazyInitializingExecutorService(executorFactory, threadFactory); } }
Source:
<code>@Test public void testDu() { Assume.assumeFalse("Skip: the 'du' table does not work on Windows", isWindows()); <START> Assume.assumeTrue(checkProcessExists("du")); <END> sql("select * from du") .returns(r -> { try { assertThat(r.next(), is(true)); assertThat(r.getInt(1), notNullValue()); assertThat(r.getString(2), CoreMatchers.startsWith("./")); assertThat(r.wasNull(), is(false)); } catch (SQLException e) { throw new RuntimeException(e); } }); }</code><technical_language>please assumeTrue(String message, boolean b), failed assumptions messages? E.g. assumeToolExists("du")</technical_language>

Target:
@Test public void testDu() { Assume.assumeFalse("Skip: the 'du' table does not work on Windows", isWindows()); assumeToolExists("du"); sql("select * from du") .returns(r -> { try { assertThat(r.next(), is(true)); assertThat(r.getInt(1), notNullValue()); assertThat(r.getString(2), CoreMatchers.startsWith("./")); assertThat(r.wasNull(), is(false)); } catch (SQLException e) { throw new RuntimeException(e); } }); }
Source:
<code>public List<Event> asEvents(Any producerId, @Nullable Version version) { checkNotNull(producerId); EventFactory eventFactory = EventFactory.on(origin, producerId); List<Event> result = messages.stream() .map(eventMessage -> eventFactory.createEvent(eventMessage, version)) <START> .collect(Collectors.toList()); <END> return result; }</code><technical_language>Please add static import for toList()</technical_language>

Target:
public List<Event> asEvents(Any producerId, @Nullable Version version) { checkNotNull(producerId); EventFactory eventFactory = EventFactory.on(origin, producerId); List<Event> result = messages.stream() .map(eventMessage -> eventFactory.createEvent(eventMessage, version)) .collect(toList()); return result; }
Source:
<code>public static NetworkInterfaceCardProperties create(final String provisioningState, final String resourceGuid, final Boolean enableIPForwarding, final List<IpConfiguration> ipConfigurations, final IdReference networkSecurityGroup) { NetworkInterfaceCardProperties.Builder builder = NetworkInterfaceCardProperties.builder() .provisioningState(provisioningState) .resourceGuid(resourceGuid) .enableIPForwarding(enableIPForwarding) .ipConfigurations(ipConfigurations == null ? <START> ImmutableList.<IpConfiguration>of() : ImmutableList.copyOf(ipConfigurations)) <END> .networkSecurityGroup(networkSecurityGroup); return builder.build(); }</code><technical_language>change behavior null empty list. Leave null, is related changes in this PR</technical_language>

Target:
public static NetworkInterfaceCardProperties create(final String provisioningState, final String resourceGuid, final Boolean enableIPForwarding, final List<IpConfiguration> ipConfigurations, final IdReference networkSecurityGroup) { NetworkInterfaceCardProperties.Builder builder = NetworkInterfaceCardProperties.builder() .provisioningState(provisioningState) .resourceGuid(resourceGuid) .enableIPForwarding(enableIPForwarding) .ipConfigurations(ipConfigurations == null ? null : ImmutableList.copyOf(ipConfigurations)) .networkSecurityGroup(networkSecurityGroup); return builder.build(); }
Source:
<code>public Object getParent(Object element) { Object parent = null; <START> if(element instanceof Package) { <END> parent = ((Package)element).getNestingPackage(); } return parent; }</code><technical_language>parent of a ProfileApplication</technical_language>

Target:
public Object getParent(Object element) { Object parent = null; if(element instanceof Package) { parent = ((Package)element).getNestingPackage(); } else if(element instanceof ProfileApplication) { parent = ((ProfileApplication)element).getApplyingPackage(); } return parent; }
Source:
<code>public void pruneToSizeTest() { FeatureVector fv = new FeatureVector(); fv.addFeatureWeight("a", 0.2f); fv.addFeatureWeight("a", 0.3f); fv.addFeatureWeight("b", 0.3f); fv.addFeatureWeight("b", 0.5f); fv.addFeatureWeight("c", 0.4f); assertEquals(fv.pruneToSize(2).getFeatures().size(), 2); assertEquals(fv.pruneToSize(1).getFeatures().size(), 1); <START> assertEquals(fv.pruneToSize(2).getFeatures(), new HashSet<>(Arrays.asList(new String[]{"a", "b"}))); <END> }</code><technical_language>pruning, highest weighted features? FeatureVector needs changed for that</technical_language>

Target:
public void pruneToSizeTest() { FeatureVector fv1 = createAndAddFeatureWeights(); assertEquals(fv1.pruneToSize(2).getFeatures().size(), 2); FeatureVector fv2 = createAndAddFeatureWeights(); assertEquals(fv2.pruneToSize(1).getFeatures().size(), 1); FeatureVector fv3 = createAndAddFeatureWeights(); assertEquals(fv3.pruneToSize(2).getFeatures(), new HashSet<>(Arrays.asList(new String[]{"a", "b"}))); }
Source:
<code>@Override public void store(SPProgramID programId, String remoteFileName, File localFile, AuxFileTransferListener listener) throws AuxFileException { try { String token = ""; int chunkIndex = 0; AuxFileChunk chunk; do { chunk = readChunk(localFile, chunkIndex++); token = server.storeChunk(programId, remoteFileName, chunk, token); if (!notifyListener(chunk, programId, remoteFileName, listener)) return; } while (!chunk.isLastChunk()); Collection<String> auxFileNames = Collections.singleton(localFile.getName()); Collection<AuxFile> auxFile = server.list(programId, auxFileNames); if (auxFile.size() > 0 && auxFile.iterator().next().isChecked()) <START> setChecked(programId, Collections.singleton(localFile.getName()), false, true); <END> } catch (IOException ex) { throw AuxFileException.create(ex); } }</code><technical_language>Instead of explicit suppressNotifications flag explicitly marking files unchecked, if BackendFileSystemImpl handled part of storing file? part of establishing metadata for files accepted. chunk in set checked flag false. notifications NotifyingBackend. (Also, a trivial detail if this suggestion sense is remember mark final.)</technical_language>

Target:
@Override public void store(SPProgramID programId, String remoteFileName, File localFile, AuxFileTransferListener listener) throws AuxFileException { try { String token = ""; int chunkIndex = 0; AuxFileChunk chunk; do { chunk = readChunk(localFile, chunkIndex++); token = server.storeChunk(programId, remoteFileName, chunk, token); if (!notifyListener(chunk, programId, remoteFileName, listener)) return; } while (!chunk.isLastChunk()); } catch (IOException ex) { throw AuxFileException.create(ex); } }
Source:
<code>private void loadLogMessages() { try { <START> String pathToJsonFile = TestProperties.TEST_DATA_FOLDER + TYPICAL_LOG_MESSAGE; <END> String jsonString = FileHelper.readFile(pathToJsonFile); Type listType = new TypeToken<List<List<String>>>(){}.getType(); logMessages = JsonUtils.fromJson(jsonString, listType); } catch (IOException e) { throw new RuntimeException(e); } }</code><technical_language>TYPICAL_LOG_MESSAGE need a local variable? hard-code /typicalLogMessage.json if once</technical_language>

Target:
private void loadLogMessages() { try { String pathToJsonFile = TestProperties.TEST_DATA_FOLDER + "/typicalLogMessage.json"; String jsonString = FileHelper.readFile(pathToJsonFile); Type listType = new TypeToken<List<List<String>>>(){}.getType(); logMessages = JsonUtils.fromJson(jsonString, listType); } catch (IOException e) { throw new RuntimeException(e); } }
Source:
<code>public void configurePipeline(MultiInputPipelineConfigurer pipelineConfigurer) { MultiInputStageConfigurer stageConfigurer = pipelineConfigurer.getMultiInputStageConfigurer(); Map<String, Schema> inputSchemas = stageConfigurer.getInputSchemas(); FailureCollector collector = pipelineConfigurer.getMultiInputStageConfigurer().getFailureCollector(); init(inputSchemas, collector); collector.getOrThrowException(); <START> if (!conf.inputSchemasAvailable(inputSchemas) && !conf.containsMacro(conf.OUTPUT_SCHEMA) && <END> conf.getOutputSchema(collector) == null) { collector.addFailure("Output schema must be specified", null).withConfigProperty(conf.OUTPUT_SCHEMA); } Schema outputSchema = getOutputSchema(inputSchemas, collector); if (outputSchema != null) { stageConfigurer.setOutputSchema(outputSchema); } }</code><technical_language>nit: JoinerConfig.OUTPUT_SCHEMA</technical_language>

Target:
public void configurePipeline(MultiInputPipelineConfigurer pipelineConfigurer) { MultiInputStageConfigurer stageConfigurer = pipelineConfigurer.getMultiInputStageConfigurer(); Map<String, Schema> inputSchemas = stageConfigurer.getInputSchemas(); FailureCollector collector = pipelineConfigurer.getMultiInputStageConfigurer().getFailureCollector(); init(inputSchemas, collector); collector.getOrThrowException(); if (!conf.inputSchemasAvailable(inputSchemas) && !conf.containsMacro(JoinerConfig.OUTPUT_SCHEMA) && conf.getOutputSchema(collector) == null) { collector.addFailure("Output schema must be specified", null).withConfigProperty(JoinerConfig.OUTPUT_SCHEMA); } Schema outputSchema = getOutputSchema(inputSchemas, collector); if (outputSchema != null) { stageConfigurer.setOutputSchema(outputSchema); } }
Source:
<code>public void flush(RequestScope requestScope) { if (!isOpen()) { return; } try { deferredTasks.forEach(Runnable::run); deferredTasks.clear(); FlushModeType flushMode = em.getFlushMode(); if (flushMode == FlushModeType.AUTO && isOpen()) { em.flush(); } } catch (Exception e) { try { rollback(); } catch (RuntimeException e2) { e.addSuppressed(e2); } finally { log.error("Caught entity manager exception during flush", e); } if (e instanceof ConstraintViolationException) { throw e; } else { throw new TransactionException(e); <START> } <END> } }</code><technical_language>better: java if (e instanceof ConstraintViolationException) { throw e; } throw new TransactionException(e);</technical_language>

Target:
public void flush(RequestScope requestScope) { if (!isOpen()) { return; } try { deferredTasks.forEach(Runnable::run); deferredTasks.clear(); FlushModeType flushMode = em.getFlushMode(); if (flushMode == FlushModeType.AUTO && isOpen()) { em.flush(); } } catch (Exception e) { try { rollback(); } catch (RuntimeException e2) { e.addSuppressed(e2); } finally { log.error("Caught entity manager exception during flush", e); } if (e instanceof ConstraintViolationException) { throw e; } throw new TransactionException(e); } }
Source:
<code>private void send(final String endPointId, final ShuffleControlMessage controlMessage) throws NetworkException { <START> final Connection<ShuffleControlMessage> connection = connectionFactory.newConnection( <END> idFactory.getNewInstance(endPointId)); connection.open(); connection.write(controlMessage); }</code><technical_language>Create a new connection time send a ShuffleControlMessage</technical_language>

Target:
private void send(final String endPointId, final ShuffleControlMessage controlMessage) throws NetworkException { final Connection<ShuffleControlMessage> connection = getConnection(endPointId); connection.open(); connection.write(controlMessage); }
Source:
<code>public void testSuccessfulVersionQuery() throws Exception { setupForTest(); String testVersionName = expectedVersionMap.keySet().iterator().next(); Version expectedVersion = expectedVersionMap.get(testVersionName); Version returnedVersion = versionUtil.getVersion(testVersionName); int failureCount = 0; StringBuilder failureReport = new StringBuilder(); <START> if (expectedVersion == null || returnedVersion == null) { <END> if (expectedVersion == null) { failureReport.append(testVersionName + " : no values in expected version hash (internal error)\n"); } if (returnedVersion == null) { failureReport.append(testVersionName + " : version expected but not returned from versionUtil\n"); } } else { String expectedVersionName = expectedVersion.getVersion(); String returnedVersionName = returnedVersion.getVersion(); if (!testValuesMatch(expectedVersionName, returnedVersionName)) { failureReport.append(makeMismatchMessage(testVersionName, "version", returnedVersionName, expectedVersionName)); failureCount = failureCount + 1; } String expectedGraphURI = expectedVersion.getGraphURI(); String returnedGraphURI = returnedVersion.getGraphURI(); if (!testValuesMatch(expectedGraphURI, returnedGraphURI)) { failureReport.append(makeMismatchMessage(testVersionName, "graphURI", returnedGraphURI, expectedGraphURI)); failureCount = failureCount + 1; } String expectedDescription = expectedVersion.getDescription(); String returnedDescription = returnedVersion.getDescription(); if (!testValuesMatch(expectedDescription, returnedDescription)) { failureReport.append(makeMismatchMessage(testVersionName, "description", returnedDescription, expectedDescription)); failureCount = failureCount + 1; } } if (failureCount > 0) { fail(Integer.toString(failureCount) + " failed test conditions. Details follow... " + failureReport.toString()); } return; }</code><technical_language>Failure count incremented</technical_language>

Target:
public void testSuccessfulVersionQuery() throws Exception { String testVersionName = expectedVersionMap.keySet().iterator().next(); Version expectedVersion = expectedVersionMap.get(testVersionName); Version returnedVersion = versionUtil.getVersion(testVersionName); int failureCount = 0; StringBuilder failureReport = new StringBuilder(); failureCount = failureCount + failuresInReturnedVersionComparison(testVersionName, expectedVersion, returnedVersion, failureReport); if (failureCount > 0) { fail(Integer.toString(failureCount) + " failed test conditions. Details follow... " + failureReport.toString()); } return; }
Source:
<code>public IndexRebuildRegionScanner(final RegionScanner innerScanner, final Region region, final Scan scan, final RegionCoprocessorEnvironment env) throws IOException { super(innerScanner, region, scan, env); this.env = env; try (org.apache.hadoop.hbase.client.Connection connection = HBaseFactoryProvider.getHConnectionFactory().createConnection(env.getConfiguration())) { <START> endKeys = connection.getRegionLocator(indexHTable.getName()).getEndKeys(); <END> } indexRowKey = scan.getAttribute(BaseScannerRegionObserver.INDEX_ROW_KEY); if (indexRowKey != null) { setReturnCodeForSingleRowRebuild(); pageSizeInRows = 1; } if (verify) { viewConstants = IndexUtil.deserializeViewConstantsFromScan(scan); byte[] disableLoggingValueBytes = scan.getAttribute(BaseScannerRegionObserver.INDEX_REBUILD_DISABLE_LOGGING_VERIFY_TYPE); if (disableLoggingValueBytes != null) { disableLoggingVerifyType = IndexTool.IndexDisableLoggingType.fromValue(disableLoggingValueBytes); } verificationOutputRepository = new IndexVerificationOutputRepository(indexMaintainer.getIndexTableName() , hTableFactory, disableLoggingVerifyType); verificationResult = new IndexToolVerificationResult(scan); verificationResultRepository = new IndexVerificationResultRepository(indexMaintainer.getIndexTableName(), hTableFactory); } }</code><technical_language>this add pressure meta a large table regions? (Creating connections a bit heavyweight, populating region locator require reading meta?) keys regions of a single table, is a share regions of data table RS, regions of a data table share indexes</technical_language>

Target:
public IndexRebuildRegionScanner(final RegionScanner innerScanner, final Region region, final Scan scan, final RegionCoprocessorEnvironment env) throws IOException { super(innerScanner, region, scan, env); this.env = env; connection = HBaseFactoryProvider.getHConnectionFactory().createConnection(env.getConfiguration()); endKeys = connection.getRegionLocator(indexHTable.getName()).getEndKeys(); indexRowKey = scan.getAttribute(BaseScannerRegionObserver.INDEX_ROW_KEY); if (indexRowKey != null) { setReturnCodeForSingleRowRebuild(); pageSizeInRows = 1; } if (verify) { viewConstants = IndexUtil.deserializeViewConstantsFromScan(scan); byte[] disableLoggingValueBytes = scan.getAttribute(BaseScannerRegionObserver.INDEX_REBUILD_DISABLE_LOGGING_VERIFY_TYPE); if (disableLoggingValueBytes != null) { disableLoggingVerifyType = IndexTool.IndexDisableLoggingType.fromValue(disableLoggingValueBytes); } verificationOutputRepository = new IndexVerificationOutputRepository(indexMaintainer.getIndexTableName() , hTableFactory, disableLoggingVerifyType); verificationResult = new IndexToolVerificationResult(scan); verificationResultRepository = new IndexVerificationResultRepository(indexMaintainer.getIndexTableName(), hTableFactory); } }
Source:
<code>public String template( @NotNull(message = "Template name can't be NULL") final String name) throws IOException { return this.github().entry().reset(HttpHeaders.ACCEPT) .header(HttpHeaders.ACCEPT, "application/vnd.github.v3.raw") <START> .uri().path( <END> new StringBuilder("/gitignore/templates/").append(name) .toString() ).back().fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .body(); }</code><technical_language>do .path("/gitignore/templates").path(name)</technical_language>

Target:
public String template( @NotNull(message = "Template name can't be NULL") final String name) throws IOException { return this.request.reset(HttpHeaders.ACCEPT) .header(HttpHeaders.ACCEPT, "application/vnd.github.v3.raw") .uri().path(name).back().fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .body(); }
Source:
<code>public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { final HttpRequest httpRequest = HttpRequest.decorate(req); final Context context = new Context(httpRequest, res).init(); String id = getObjectId(httpRequest); try { String redirect = getDestination(id, httpRequest, res); if (!StringUtil.isDefined(redirect)) { objectNotFound(context); } else { if (!res.isCommitted()) { if (!redirect.startsWith("http")) { redirect = URLUtil.getFullApplicationURL(httpRequest) + "/autoRedirect.jsp?" + redirect; } res.sendRedirect(res.encodeRedirectURL(UriBuilder.fromUri(redirect) .queryParam("fromResponsiveNavigation", context.isFromResponsiveNavigation()).build() .toString())); } } } catch (AccessForbiddenException afe) { <START> accessForbidden(context); <END> } catch (Exception e) { objectNotFound(context); } }</code><technical_language>![MINOR](<LINK_2> 'Severity: MINOR') Add a "try/catch" block for "accessForbidden". [![rule](<LINK_1>](<LINK_0></technical_language>

Target:
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { final HttpRequest httpRequest = HttpRequest.decorate(req); final Context context = new Context(httpRequest, res).init(); String id = getObjectId(httpRequest); try { String redirect = getDestination(id, httpRequest, res); if (!StringUtil.isDefined(redirect)) { objectNotFound(context); } else { if (!res.isCommitted()) { if (!redirect.startsWith("http")) { redirect = URLUtil.getFullApplicationURL(httpRequest) + "/autoRedirect.jsp?" + redirect; } res.sendRedirect(res.encodeRedirectURL(UriBuilder.fromUri(redirect) .queryParam("fromResponsiveWindow", context.isFromResponsiveWindow()).build() .toString())); } } } catch (AccessForbiddenException afe) { accessForbidden(context); } catch (Exception e) { objectNotFound(context); } }
Source:
<code>public void postProcessModule(Module module) { ChannelRegistry registry = findRegistry(module); <START> DeploymentMetadata md = module.getDeploymentMetadata(); <END> if (registry != null) { MessageChannel channel = module.getComponent("input", MessageChannel.class); if (channel != null) { registry.createInbound(module.getProperties().getProperty("xd.stream.name"), channel, DEFAULT_ACCEPTED_CONTENT_TYPES, true); } } }</code><technical_language>this is currently (the DeploymentMetadata)</technical_language>

Target:
public void postProcessModule(Module module) { ChannelRegistry registry = findRegistry(module); DeploymentMetadata md = module.getDeploymentMetadata(); if (registry != null) { MessageChannel channel = module.getComponent("input", MessageChannel.class); if (channel != null) { registry.createInbound(md.getGroup(), channel, DEFAULT_ACCEPTED_CONTENT_TYPES, true); } } }