auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static Set<String> getDefaultStopWords() { return new HashSet<>(Arrays.asList( "jenkins", "node", "master", "computer", "item", "label", "view", "all", "unknown", <START> "user", "anonymous", "authenticated" <END> )); }</code><technical_language>add "everyone" "system", "anonymous" "authenticated". specific file I noticed system.properties, turned "user_blah.properties"</technical_language>

Target:
private static Set<String> getDefaultStopWords() { return new HashSet<>(Arrays.asList( "jenkins", "node", "master", "computer", "item", "label", "view", "all", "unknown", "user", "anonymous", "authenticated", "everyone", "system", "admin" )); }
Source:
<code>public void onWikipediaZeroInterstitialEvent(final WikipediaZeroInterstitialEvent event) { alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.zero_interstitial_title)); alert.setMessage(getString(R.string.zero_interstitial_leave_app)); alert.setPositiveButton(getString(R.string.zero_interstitial_continue), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Utils.visitInExternalBrowser(PageActivity.this, event.getUri()); } }); alert.setNegativeButton(getString(R.string.zero_interstitial_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert.setNeutralButton(getString(R.string.nav_item_preferences), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { visitSettings(); } }); final AlertDialog ad = alert.create(); ad.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface d) { ad.getButton(DialogInterface.BUTTON_NEGATIVE).setTypeface(Typeface.DEFAULT, Typeface.BOLD); } <START> }); <END> ad.show(); }</code><technical_language>Bolding dialog buttons is unusual. do need this? Android-y</technical_language>

Target:
public void onWikipediaZeroInterstitialEvent(final WikipediaZeroInterstitialEvent event) { alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.zero_interstitial_title)); alert.setMessage(getString(R.string.zero_interstitial_leave_app)); alert.setPositiveButton(getString(R.string.zero_interstitial_continue), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Utils.visitInExternalBrowser(PageActivity.this, event.getUri()); } }); alert.setNegativeButton(getString(R.string.zero_interstitial_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog ad = alert.create(); ad.show(); }
Source:
<code>public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + fChannels.hashCode(); <START> result = prime * result + (fDomain.equals(DomainEnum.KERNEL) ? 1231 : 1237); <END> result = prime * result + ((fBufferType == null) ? 0 : (fBufferType.ordinal() + 1)); return result; }</code><technical_language>result = prime * result + ((fDomain == null) ? 0 : (fDomain.ordinal() + 1));</technical_language>

Target:
public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + fChannels.hashCode(); result = prime * result + ((fDomain == null) ? 0 : (fDomain.ordinal() + 1)); result = prime * result + ((fBufferType == null) ? 0 : (fBufferType.ordinal() + 1)); return result; }
Source:
<code>private String cookiePath(String rawCookiePath, String requestPath) { <START> if (rawCookiePath != null && !rawCookiePath.isEmpty() && rawCookiePath.charAt(0) == '/') { <END> return rawCookiePath; } else { if (!requestPath.isEmpty() && requestPath.charAt(0) == '/' && requestPath.chars().filter(value -> value == '/').count() > 1) return requestPath.substring(0, requestPath.lastIndexOf('/')); else return "/"; } }</code><technical_language>MiscUtils.isNonEmpty</technical_language>

Target:
private String cookiePath(String rawCookiePath, String requestPath) { if (MiscUtils.isNonEmpty(rawCookiePath) && rawCookiePath.charAt(0) == '/') { return rawCookiePath; } else { int indexOfLastSlash = requestPath.lastIndexOf('/'); if (!requestPath.isEmpty() && requestPath.charAt(0) == '/' && indexOfLastSlash > 0) return requestPath.substring(0, indexOfLastSlash); else return "/"; } }
Source:
<code>public void testClose() throws IOException { final LineIterator lineIterator = new LineIterator(new Reader() { @Override public int read(char[] cbuf, int off, int len) throws IOException { <START> final char[] chs = "\n".toCharArray(); <END> System.arraycopy(chs, 0, cbuf, 0, chs.length); return chs.length; } @Override public void close() throws IOException { throw new RuntimeException("close test for FileIteratingFirehose"); } }); final TestCloseable closeable = new TestCloseable(); final FileIteratingFirehose firehose = new FileIteratingFirehose( ImmutableList.of(lineIterator).iterator(), parser, closeable ); firehose.hasMore(); firehose.close(); Assert.assertTrue(closeable.closed); }</code><technical_language>extract chs static</technical_language>

Target:
public void testClose() throws IOException { final LineIterator lineIterator = new LineIterator(new Reader() { @Override public int read(char[] cbuf, int off, int len) throws IOException { System.arraycopy(LINE_CHARS, 0, cbuf, 0, LINE_CHARS.length); return LINE_CHARS.length; } @Override public void close() throws IOException { throw new RuntimeException("close test for FileIteratingFirehose"); } }); final TestCloseable closeable = new TestCloseable(); final FileIteratingFirehose firehose = new FileIteratingFirehose( ImmutableList.of(lineIterator).iterator(), parser, closeable ); firehose.hasMore(); firehose.close(); Assert.assertTrue(closeable.closed); }
Source:
<code>public String getShortName() { if (isStringBlankOrNull(shortName)) { <START> return alias; <END> } return shortName; }</code><technical_language>This work for naming alias (full project name) is pass validation for naming</technical_language>

Target:
public String getShortName() { if (isStringBlankOrNull(shortName)) { String syntheticShortName = alias.toUpperCase().replaceAll("[^A-Z0-9]", ""); if (syntheticShortName.length() > 5) { syntheticShortName = syntheticShortName.substring(0, 5); } return syntheticShortName; } return shortName; }
Source:
<code>public static OWLOntology getInputOntology( <START> IOHelper ioHelper, CommandLine line, String catalogPath) throws IOException { <END> List<String> inputOntologyPaths = getOptionalValues(line, "input"); List<String> inputOntologyIRIs = getOptionalValues(line, "input-iri"); int check = inputOntologyPaths.size() + inputOntologyIRIs.size(); if (check > 1) { throw new IllegalArgumentException(multipleInputsError); } if (!inputOntologyPaths.isEmpty()) { if (catalogPath != null) { return ioHelper.loadOntology(inputOntologyPaths.get(0), catalogPath); } else { return ioHelper.loadOntology(inputOntologyPaths.get(0)); } } else if (!inputOntologyIRIs.isEmpty()) { if (catalogPath != null) { return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0)), catalogPath); } else { return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0))); } } else { throw new IllegalArgumentException(missingInputError); } }</code><technical_language>this need throws IllegalArgumentException</technical_language>

Target:
public static OWLOntology getInputOntology( IOHelper ioHelper, CommandLine line, String catalogPath) throws IllegalArgumentException, IOException { List<String> inputOntologyPaths = getOptionalValues(line, "input"); List<String> inputOntologyIRIs = getOptionalValues(line, "input-iri"); int check = inputOntologyPaths.size() + inputOntologyIRIs.size(); if (check > 1) { throw new IllegalArgumentException(multipleInputsError); } if (!inputOntologyPaths.isEmpty()) { if (catalogPath != null) { return ioHelper.loadOntology(inputOntologyPaths.get(0), catalogPath); } else { return ioHelper.loadOntology(inputOntologyPaths.get(0)); } } else if (!inputOntologyIRIs.isEmpty()) { if (catalogPath != null) { return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0)), catalogPath); } else { return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0))); } } else { throw new IllegalArgumentException(missingInputError); } }
Source:
<code>public static BlockData getWaterData(final int level) { <START> return Material.WATER.createBlockData(d -> ((Levelled) d).setLevel((level < 0 || level > 15) ? 0 : level)); <END> }</code><technical_language>I expect this change anytime soon, prevent of magic values in checks good Levelled::getMaximumLevel()</technical_language>

Target:
public static BlockData getWaterData(final int level) { return Material.WATER.createBlockData(d -> ((Levelled) d).setLevel((level < 0 || level > ((Levelled) d).getMaximumLevel()) ? 0 : level)); }
Source:
<code>private static ResourceNode generateCoreRootResourceNode() { ResourceNode node = new ResourceNode(); <START> node.setContent(new IRootResource() { <END> @Override public ITransactionBehavior getTransactionBehaviour() { return null; } @Override public ILockingBehaviour getLockingBehaviour() { return null; } @Override public Specification getSpecification() { return new Specification(Type.CORE, "MQNaaS Core", "0.0.1"); } @Override public Collection<Endpoint> getEndpoints() { return null; } }); return node; }</code><technical_language>Is a shorter initialize resource, e.g. constructor</technical_language>

Target:
private static ResourceNode generateCoreRootResourceNode() { ResourceNode node = new ResourceNode(); node.setContent(generateRootResource(new Specification(Type.CORE, "MQNaaS Core", "0.0.1"), null)); return node; }
Source:
<code>public void executeTask() throws MojoExecutionException, MojoFailureException { boolean projectDetected = false; boolean buildExecuted = false; <START> if(serverId == null){ <END> File configFile = new File("webpack.config.js"); if (configFile.exists()) { projectDetected = true; boolean buildOwa = wizard.promptYesNo("OWA Project found in this directory, do you want to build it?"); if (buildOwa) { buildOwaProject(); buildExecuted = true; } } File userDir = new File(System.getProperty("user.dir")); if(Project.hasProject(userDir)) { Project config = Project.loadProject(userDir); String artifactId = config.getArtifactId(); String groupId = config.getGroupId(); String version = config.getVersion(); if ((artifactId != null) && (groupId != null) && version != null) { projectDetected = true; boolean buildMavenProject = wizard.promptYesNo(String.format( "Maven artifact %s:%s:%s detected in this directory, would you like to build it?", groupId, artifactId, version) ); if(buildMavenProject){ try { cleanInstallServerProject(userDir); buildExecuted = true; } catch (Exception e) { throw new RuntimeException("Failed to build project"); } } } } } if(!projectDetected){ buildWatchedProjects(); } else if(!buildExecuted) { boolean buildWatched = wizard.promptYesNo("Do you want to build all watched projects instead?"); if(buildWatched){ buildWatchedProjects(); } else { wizard.showMessage("Task aborted"); } } }</code><technical_language>StringUtils.isBlank</technical_language>

Target:
public void executeTask() throws MojoExecutionException, MojoFailureException { boolean projectDetected = false; boolean buildExecuted = false; if(StringUtils.isBlank(serverId)){ File configFile = new File("webpack.config.js"); if (configFile.exists()) { projectDetected = true; boolean buildOwa = wizard.promptYesNo("OWA Project found in this directory, do you want to build it?"); if (buildOwa) { buildOwaProject(); buildExecuted = true; } } File userDir = new File(System.getProperty("user.dir")); if(Project.hasProject(userDir)) { Project config = Project.loadProject(userDir); String artifactId = config.getArtifactId(); String groupId = config.getGroupId(); String version = config.getVersion(); if ((artifactId != null) && (groupId != null) && version != null) { projectDetected = true; boolean buildMavenProject = wizard.promptYesNo(String.format( "Maven artifact %s:%s:%s detected in this directory, would you like to build it?", groupId, artifactId, version) ); if(buildMavenProject){ try { cleanInstallServerProject(userDir); buildExecuted = true; } catch (Exception e) { throw new RuntimeException("Failed to build project"); } } } } } if(!projectDetected){ buildWatchedProjects(); } else if(!buildExecuted) { boolean buildWatched = wizard.promptYesNo("Do you want to build all watched projects instead?"); if(buildWatched){ buildWatchedProjects(); } else { wizard.showMessage("Task aborted"); } } }
Source:
<code>public void write( final int b ) throws IOException { if ( (int) b == -1 ) { currBlock.setEOF(); doFlush( true ); } <START> if ( !currBlock.full() ) <END> { currBlock.writeToBuffer( (byte) b ); } else { UUID newBlockID = UUID.randomUUID(); FileBlock block = new FileBlock( metadata.getFilePath(), newBlockID ); currBlock.setNextBlockID( newBlockID ); prevBlock = currBlock; currBlock = block; flush(); currBlock.writeToBuffer( (byte) b ); } }</code><technical_language>flip this condition determine front need create a new block. actual write logic in place. Stylistic I guess, another option</technical_language>

Target:
public void write( final int b ) throws IOException { if ( (int) b == -1 ) { currBlock.setEOF(); doFlush( true ); } if ( currBlock.full() ) { String newBlockID = UUID.randomUUID().toString(); FileBlock block = new FileBlock( metadata.getFilePath(), newBlockID ); currBlock.setNextBlockID( newBlockID ); prevBlock = currBlock; currBlock = block; flush(); } currBlock.writeToBuffer( (byte) b ); }
Source:
<code>public void write(byte[] data, int offset, int len) { if(!this.running) { return; } <START> requestObserver.onNext(StreamingRecognizeRequest.newBuilder().setAudioContent(ByteString.copyFrom(data)).build()); <END> }</code><technical_language>respect offset data length</technical_language>

Target:
public void write(byte[] data, int offset, int len) { if(!this.running.get()) { return; } requestObserver.onNext(StreamingRecognizeRequest.newBuilder().setAudioContent(ByteString.copyFrom(data, offset, len)).build()); }
Source:
<code>public Table getAugmentedTableForInTransactionRead() { if (!table.getPartitionColumns().isEmpty()) { return table; } Table table = this.table; String currentLocation = this.currentLocation.get().toString(); if (!currentLocation.equals(table.getStorage().getLocation())) { table = Table.builder(table) .withStorage(storage -> storage.setLocation(currentLocation)) <START> .build(); <END> } return table; }</code><technical_language>this.currentLocation.get() this fail, currentLocation is guaranteed set. Check for presence</technical_language>

Target:
public Table getAugmentedTableForInTransactionRead() { if (!table.getPartitionColumns().isEmpty()) { return table; } if (!currentLocation.isPresent()) { return table; } String currentLocation = this.currentLocation.get().toString(); if (!currentLocation.equals(table.getStorage().getLocation())) { return Table.builder(table) .withStorage(storage -> storage.setLocation(currentLocation)) .build(); } return table; }
Source:
<code>private String getVpnMsgOrLinkToBrowser() { final Network network = mCm.getActiveNetwork(); final NetworkCapabilities cap = mCm.getNetworkCapabilities(network); if (cap != null && cap.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { final String vpnMsg = getString(R.string.ssl_error_vpn); return " <div <START> class=example>" <END> + vpnMsg + "</div><br>"; } final String continueMsg = getString(R.string.ssl_error_continue); return " <a href=" + mBrowserBailOutToken + ">" + continueMsg + "</a><br>"; }</code><technical_language>For cleanliness a style specific this instead of re-purposing "example", this is example. add another name div.example (e.g. div.example, div.vpnwarning { ... } rename "example" reflect new role</technical_language>

Target:
String getVpnMsgOrLinkToBrowser() { final Network network = mCm.getActiveNetwork(); final NetworkCapabilities cap = mCm.getNetworkCapabilities(network); if (cap != null && cap.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { final String vpnWarning = getString(R.string.ssl_error_vpnwarning); return " <div class=vpnwarning>" + vpnWarning + "</div><br>"; } final String continueMsg = getString(R.string.ssl_error_continue); return " <a href=" + mBrowserBailOutToken + ">" + continueMsg + "</a><br>"; }
Source:
<code>String checkForError() { if (dateFilterCheckBox.isSelected()) { if (!(rangeRadioButton.isSelected() || mostRecentRadioButton.isSelected())) { <START> return "Range or Only Last must be selected"; <END> } else if (rangeRadioButton.isSelected() && !(startCheckBox.isSelected() || endCheckBox.isSelected())) { return "A start or end date must be specified to use the range filter"; } } return ""; }</code><technical_language>bundle messages</technical_language>

Target:
String checkForError() { if (dateFilterCheckBox.isSelected()) { if (!(rangeRadioButton.isSelected() || mostRecentRadioButton.isSelected())) { return Bundle.DateFilterPanel_invalidRange_text(); } else if (rangeRadioButton.isSelected() && !(startCheckBox.isSelected() || endCheckBox.isSelected())) { return Bundle.DateFilterPanel_startOrEndNeeded_text(); } } return ""; }
Source:
<code>public void write(OutboundFrame frame) { if (frame.isUrgent()) { priorityWriteQueue.offer(frame); } else { writeQueue.offer(frame); } for (; ; ) { State state = scheduled.get(); if (state == State.UNSCHEDULED) { if (!scheduled.compareAndSet(State.UNSCHEDULED, State.SCHEDULED)) { continue; } if (writeThroughEnabled && !concurrencyDetection.isDetected()) { try { process(); } catch (Throwable t) { onError(t); } } else { <START> registerOp(OP_WRITE); <END> selectionKey.selector().wakeup(); } return; } else if (state == State.SCHEDULED || state == State.RESCHEDULE) { if (writeThroughEnabled) { concurrencyDetection.onDetected(); } return; } else if (state == State.BLOCKED) { return; } else { throw new IllegalStateException("Unexpected state:" + state); } } }</code><technical_language>@pveentjer potential reason observe worse latencies is registration of selection key is blocking operation. Typically, calls selector methods wrapped in a synchronized block. registration of a new selection key treated a call blocking queue. E.g. this is in Linux in JDK 11 [1]. change concurrent queue + wakeup, do blocking queue + wakeup. need some throttling mechanism, prevent a call selector if write operation is scheduled. E.g. AtomicBoolean. WDYT? [1] <LINK_0></technical_language>

Target:
public void write(OutboundFrame frame) { if (frame.isUrgent()) { priorityWriteQueue.offer(frame); } else { writeQueue.offer(frame); } for (; ; ) { State state = scheduled.get(); if (state == State.UNSCHEDULED) { if (!scheduled.compareAndSet(State.UNSCHEDULED, State.SCHEDULED)) { continue; } executePipeline(); return; } else if (state == State.SCHEDULED || state == State.RESCHEDULE) { if (writeThroughEnabled) { concurrencyDetection.onDetected(); } return; } else if (state == State.BLOCKED) { return; } else { throw new IllegalStateException("Unexpected state:" + state); } } }
Source:
<code>private void dumpWebAuthnCredentialModel(WebAuthnCredentialModel auth) { <START> logger.debugv(" Context Credential Info::"); <END> String id = auth.getAuthenticatorId(); AttestationStatement attrStatement = auth.getAttestationStatement(); AttestedCredentialData attrCredData = auth.getAttestedCredentialData(); WebAuthnAuthenticationContext context = auth.getAuthenticationContext(); if (id != null) logger.debugv(" Authenticator Id = {0}", id); if (attrStatement != null) logger.debugv(" Attestation Statement Format = {0}", attrStatement.getFormat()); if (attrCredData != null) { CredentialPublicKey credPubKey = attrCredData.getCredentialPublicKey(); byte[] keyId = credPubKey.getKeyId(); logger.debugv(" AAGUID = {0}", attrCredData.getAaguid().toString()); logger.debugv(" CREDENTIAL_ID = {0}", Base64.encodeBytes(attrCredData.getCredentialId())); if (keyId != null) logger.debugv(" CREDENTIAL_PUBLIC_KEY.key_id = {0}", Base64.encodeBytes(keyId)); logger.debugv(" CREDENTIAL_PUBLIC_KEY.algorithm = {0}", credPubKey.getAlgorithm().name()); logger.debugv(" CREDENTIAL_PUBLIC_KEY.key_type = {0}", credPubKey.getKeyType().name()); } if (context != null) { logger.infov(" Credential Id = {0}", Base64.encodeBytes(context.getCredentialId())); } }</code><technical_language>a minor issue related logging. I vote wrap this method "if (logger.isDebugEnabled()" avoid some unecessary calls Base64 encode in case debug logging is enabled anyway. slightly is implement method "toString()" WebAuthnCredentialModel. This allow "logger.debug(auth)" in case debug is enabled, "toString()" called (hence call unecessary Base64 encodings etc). same/similar code need duplicated in WebAuthnRegister class</technical_language>

Target:
private void dumpWebAuthnCredentialModel(WebAuthnCredentialModel auth) { logger.debug(" Context Credential Info::"); logger.debug(auth); }
Source:
<code>public synchronized void stop() { if (started) { try { lock.release(); rw.close(); if (!lockFile.delete()) { <START> LOGGER.info("Lock file was not deleted {}.", lockFile.getPath()); <END> } } catch (IOException e) { throw new RuntimeException("Couldn't unlock rootDir: " + rootDirectory.getAbsolutePath(), e); } started = false; LOGGER.debug("RootDirectory Unlocked"); } }</code><technical_language>I in favour of WARN level for this</technical_language>

Target:
public synchronized void stop() { if (started) { try { lock.release(); rw.close(); if (!lockFile.delete()) { LOGGER.debug("Lock file was not deleted {}.", lockFile.getPath()); } } catch (IOException e) { throw new RuntimeException("Couldn't unlock rootDir: " + rootDirectory.getAbsolutePath(), e); } started = false; LOGGER.debug("RootDirectory Unlocked"); } }
Source:
<code>private void assertMessages(Batch expected, Batch actual) { assertNotNull(actual); <START> assertEquals(expected.getMessages().get(0).getSequence(), actual.getMessages().get(0).getSequence()); <END> assertEquals(expected.getMessages().get(1).getSequence(), actual.getMessages().get(1).getSequence()); assertEquals(expected.getMessages().get(0).getData().get("line"), actual.getMessages().get(0).getData().get("line")); assertEquals(expected.getMessages().get(1).getData().get("line"), actual.getMessages().get(1).getData().get("line")); assertEquals(expected.getMessages().get(0).getData().get("from"), actual.getMessages().get(0).getData().get("from")); assertEquals(expected.getMessages().get(1).getData().get("from"), actual.getMessages().get(1).getData().get("from")); assertEquals(expected.size(), actual.size()); }</code><technical_language>assertEquals(expected.getMessages(), actual.getMessages())? ah, I 20 messages in batch</technical_language>

Target:
private void assertMessages(Batch expected, Batch actual) { assertNotNull(actual); assertEquals(expected.size(), actual.size()); for(int i=0; i < expected.size(); i++) { assertEquals(expected.getMessages().get(i).getSequence(), actual.getMessages().get(i).getSequence()); assertEquals(expected.getMessages().get(i).getData().get("line"), actual.getMessages().get(i).getData().get("line")); assertEquals(expected.getMessages().get(i).getData().get("from"), actual.getMessages().get(i).getData().get("from")); } }
Source:
<code>private List<ViewCSSProperty> getViewProperties() { if (mViewProperties == null) { synchronized (this) { if (mViewProperties == null) { <START> Set<ViewCSSProperty> props = new TreeSet<>(new Comparator<ViewCSSProperty>() { <END> @Override public int compare(ViewCSSProperty lhs, ViewCSSProperty rhs) { return lhs.getCSSName().compareTo(rhs.getCSSName()); } }); for (final Method method : View.class.getDeclaredMethods()) { ViewDebug.ExportedProperty annotation = method.getAnnotation( ViewDebug.ExportedProperty.class); if (annotation != null) { props.add(new MethodBackedCSSProperty( method, convertViewPropertyNameToCSSName(method.getName()), annotation)); } } for (final Field field : View.class.getDeclaredFields()) { ViewDebug.ExportedProperty annotation = field.getAnnotation( ViewDebug.ExportedProperty.class); if (annotation != null) { props.add(new FieldBackedCSSProperty( field, convertViewPropertyNameToCSSName(field.getName()), annotation)); } } mViewProperties = Collections.unmodifiableList(new ArrayList<>(props)); } } } return mViewProperties; }</code><technical_language>keeping a List sorting afterward? intentionally avoiding Map Set add extra allocation entry. This code adds extra copy operation (new ArrayList<>(props)') prefer avoid</technical_language>

Target:
private List<ViewCSSProperty> getViewProperties() { if (mViewProperties == null) { synchronized (this) { if (mViewProperties == null) { List<ViewCSSProperty> props = new ArrayList<>(); for (final Method method : View.class.getDeclaredMethods()) { ViewDebug.ExportedProperty annotation = method.getAnnotation( ViewDebug.ExportedProperty.class); if (annotation != null) { props.add(new MethodBackedCSSProperty( method, convertViewPropertyNameToCSSName(method.getName()), annotation)); } } for (final Field field : View.class.getDeclaredFields()) { ViewDebug.ExportedProperty annotation = field.getAnnotation( ViewDebug.ExportedProperty.class); if (annotation != null) { props.add(new FieldBackedCSSProperty( field, convertViewPropertyNameToCSSName(field.getName()), annotation)); } } Collections.sort(props, new Comparator<ViewCSSProperty>() { @Override public int compare(ViewCSSProperty lhs, ViewCSSProperty rhs) { return lhs.getCSSName().compareTo(rhs.getCSSName()); } }); mViewProperties = Collections.unmodifiableList(props); } } } return mViewProperties; }
Source:
<code>public ScheduledFuture<ExchangeScheduler> deferredTaskManager(ThreadPoolTaskScheduler scheduler) { long intervalMinutes = DEFAULT_EXCHANGE_REFRESH_INTERVAL; try { ExchangeInfoType exInfo = ExchangeInfoDAOFileImpl.getInstance().loadExchangeInfo(); long interval = exInfo.getRefreshInterval(); if (interval <= 0) { <START> intervalMinutes = DEFAULT_EXCHANGE_REFRESH_INTERVAL; <END> } else { intervalMinutes = interval; } } catch (ExchangeManagerException e) { LOG.error("Could not set interval rate. Defaulting to seconds by default. Error is : {}", DEFAULT_EXCHANGE_REFRESH_INTERVAL, e.getMessage()); } PeriodicTrigger periodicTrigger = new PeriodicTrigger(intervalMinutes, TimeUnit.MINUTES); periodicTrigger.setInitialDelay(intervalMinutes); return (ScheduledFuture<ExchangeScheduler>) scheduler.schedule(new ExchangeScheduler(), periodicTrigger); }</code><technical_language>exchangexml miliseconds. need convert Min u pass PeriodicTrigger</technical_language>

Target:
public ScheduledFuture<ExchangeScheduler> deferredTaskManager(ThreadPoolTaskScheduler scheduler) { long intervalMinutes = DEFAULT_EXCHANGE_REFRESH_INTERVAL; try { ExchangeInfoType exInfo = ExchangeInfoDAOFileImpl.getInstance().loadExchangeInfo(); long interval = exInfo.getRefreshInterval(); if (interval <= 0) { intervalMinutes = DEFAULT_EXCHANGE_REFRESH_INTERVAL; } else { intervalMinutes = interval; } } catch (ExchangeManagerException e) { LOG.error("Could not set interval rate. Defaulting to minutes by default. Error is : {}", DEFAULT_EXCHANGE_REFRESH_INTERVAL, e.getMessage()); LOG.error("Exception Occurred:", e); } PeriodicTrigger periodicTrigger = new PeriodicTrigger(intervalMinutes, TimeUnit.MINUTES); periodicTrigger.setInitialDelay(intervalMinutes); return (ScheduledFuture<ExchangeScheduler>) scheduler.schedule(new ExchangeScheduler(), periodicTrigger); }
Source:
<code>public int message(String message, String actionMessage, View.OnClickListener actionOnClick, int priority){ <START> MessageKey key = new MessageKey(++mMessageId, priority); <END> Message value = new Message(key, message, actionMessage, actionOnClick); mMessagesList.put(key, value); updateList(); if (mMessagesList.size() == 0) { hide(); } else { show(); } return mMessageId; }</code><technical_language>I prefer incrementing decrementing separate lines; easier read update code. ++mMessageId; MessageKey key = new MessageKey(mMessageId, priority);</technical_language>

Target:
public int message(String message, String actionMessage, View.OnClickListener actionOnClick, int priority){ return message(message, actionMessage, actionOnClick, priority, true, 0); }
Source:
<code><START> public Integer getResolvedCount() { <END> int resolved = 0; Integer[] partials = { getFailedCount(), getInvalidCount(), getDeliveredCount() }; for (Integer partial : partials) { if (partial != null) { resolved += partial; } } return resolved; }</code><technical_language>this grealy simplified primitive ints</technical_language>

Target:
public int getResolvedCount() { return getFailedCount() + getInvalidCount() + getDeliveredCount(); }
Source:
<code>void loadData(String tblName, String TEST_DATA_FILE, WebTarget parent, GrillSessionHandle grillSessionId) throws InterruptedException { Connection conn = null; PreparedStatement stmt = null; try { conn = driver.getConnection(conf); stmt = conn.prepareStatement("INSERT INTO " + tblName + " VALUES(?, ?)"); for (int i = 0; i < NUM_RECORDS; i++) { <START> stmt.setInt(1, i); <END> stmt.setString(2, "" + i); stmt.executeUpdate(); } conn.commit(); LOG.info("@@ Inserted " + NUM_RECORDS + " in " + tblName); } catch (Exception e) { e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (Exception e) { e.printStackTrace(); } } }</code><technical_language>include some null values in input? similar data loaded in TestQueryService validation methods</technical_language>

Target:
void loadData(String tblName, String TEST_DATA_FILE, WebTarget parent, GrillSessionHandle grillSessionId) throws InterruptedException { Connection conn = null; PreparedStatement stmt = null; try { conn = driver.getConnection(conf); stmt = conn.prepareStatement("INSERT INTO " + tblName + " VALUES(?, ?)"); for (int i = 0; i < NUM_RECORDS; i++) { stmt.setInt(1, i); if (i % 2 == 0) { stmt.setString(2, "" + i); } else { stmt.setString(2, null); } stmt.executeUpdate(); } conn.commit(); LOG.info("@@ Inserted " + NUM_RECORDS + " in " + tblName); } catch (Exception e) { e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (Exception e) { e.printStackTrace(); } } }
Source:
<code>private String getAnonymousClassTypeName(TypeSymbol symbol) { String name = ""; <START> if (!symbol.getSuperclass().is("java.lang.Object")) { <END> name = symbol.getSuperclass().getSymbol().getName(); } else { name = symbol.getInterfaces().get(0).getSymbol().getName(); } return name; }</code><technical_language>test superclass is null interfaces is empty. create anonymous class based Object. Object j = new Object(){};</technical_language>

Target:
private String getAnonymousClassTypeName(TypeSymbol symbol) { String name = ""; if (symbol.getInterfaces().isEmpty()) { name = getTypeName(symbol.getSuperclass()); } else { name = getTypeName(symbol.getInterfaces().get(0)); } return name; }
Source:
<code>public static void main(String[] args) { WebHDFSCommand cmd = new WebHDFSCommand(new Groovysh()); <START> List<String> args2 = new ArrayList<>(); cmd.execute(args2); <END> }</code><technical_language>args is passed. want change to: cmd.execute(new ArrayList<>(Arrays.asList(args)));</technical_language>

Target:
public static void main(String[] args) { WebHDFSCommand cmd = new WebHDFSCommand(new Groovysh()); cmd.execute(new ArrayList<>(Arrays.asList(args))); }
Source:
<code>public JSONObject getAdminAnnouncements() { LOG.debug("get admin announcements"); final SqlSession session = factory.openSession(); JSONObject data = new JSONObject(); try { final AnnouncementsMapper mapper = session.getMapper(AnnouncementsMapper.class); data = parser.parseAnnouncementsMap(mapper.getAdminAnnouncements()); <START> session.commit(); <END> } catch (Exception e) { throw new RuntimeException("Failed to get admin announcements", e); } finally { session.close(); } return data; }</code><technical_language>need commit reading</technical_language>

Target:
public JSONObject getAdminAnnouncements() { try (final SqlSession session = factory.openSession()) { final AnnouncementsMapper mapper = session.getMapper(AnnouncementsMapper.class); return parser.parseAnnouncementsMap(mapper.getAdminAnnouncements()); } catch (Exception e) { throw new ServiceRuntimeException("Failed to get admin announcements", e); } }
Source:
<code>public Object getObject(int field) <START> { <END> return null; }</code><technical_language>need populate builder if expectedTypes contains actual</technical_language>

Target:
public Object getObject(int field) { return serializeObject(columnHandles.get(field).getColumnType(), null, getFieldValue(field)); }
Source:
<code>public Set<User> showUsers() { <START> return (Set<User>)userService.getAllUsers(); <END> }</code><technical_language>wtf</technical_language>

Target:
public List<User> showUsers() { return (List<User>)userService.getAllUsers(); }
Source:
<code>public Builder withAADPrefix(byte[] aadPrefixBytes) { if (null == aadPrefixBytes) { <START> return this; <END> } if (null != this.aadPrefixBytes) { throw new IllegalArgumentException("AAD Prefix already set"); } this.aadPrefixBytes = aadPrefixBytes; return this; }</code><technical_language>is this restriction, call this builder method twice</technical_language>

Target:
public Builder withAADPrefix(byte[] aadPrefixBytes) { if (null == aadPrefixBytes) { return this; } if (null != this.aadPrefixBytes) { throw new IllegalStateException("AAD Prefix already set"); } this.aadPrefixBytes = aadPrefixBytes; return this; }
Source:
<code>public void requestBulletCreation(GameObjectDAO data) { ByteBuffer buffer = ByteBuffer.allocate(256); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put((byte)1); <START> buffer.put((byte)Opcodes.REQUEST_BULLET.getValue()); <END> buffer.put((byte)2); buffer.putDouble(data.x); buffer.putDouble(data.y); buffer.putDouble(data.height); buffer.putDouble(data.velocityX); buffer.putDouble(data.velocityY); buffer.putInt(data.bulletType.ordinal()); buffer.putDouble(data.damage); buffer.putInt(data.ownerId); buffer.put((byte)4); sendTcp(buffer.array()); }</code><technical_language>ordinal</technical_language>

Target:
public void requestBulletCreation(GameObjectDAO data) { ByteBuffer buffer = ByteBuffer.allocate(256); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put((byte)1); buffer.put((byte)Opcodes.REQUEST_BULLET.getValue()); buffer.put((byte)2); buffer.putDouble(data.x); buffer.putDouble(data.y); buffer.putDouble(data.height); buffer.putDouble(data.velocityX); buffer.putDouble(data.velocityY); buffer.putInt(data.bulletType.ordinal()); buffer.putDouble(data.damage); buffer.putInt(data.ownerId); buffer.putInt(data.entityType.ordinal()); buffer.put((byte)4); sendTcp(buffer.array()); }
Source:
<code>protected void init() { getRegexTextField().setText(""); getEnabledCheckBox().setSelected(true); getDescTextField().setText(""); token = null; <START> KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); <END> AbstractAction escapeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispatchEvent(new WindowEvent(DialogAddToken.this, WindowEvent.WINDOW_CLOSING)); } }; getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); getRootPane().getActionMap().put("ESCAPE", escapeAction); }</code><technical_language>This added in getFieldsPanel (or constructors), this method (init) is called time dialogue is shown. apply add dialogue? (In case added a flag do this once.)</technical_language>

Target:
protected void init() { getRegexTextField().setText(""); getEnabledCheckBox().setSelected(true); getDescTextField().setText(""); token = null; }
Source:
<code>public void run() { printStats(this.replicationManager.getStats()); printStats(this.replicationSink.getStats()); <START> globalMetricsSource.setWALReaderEditsBufferBytes(replicationManager.getTotalBufferUsed().get()); <END> }</code><technical_language>this feels odd. is do updates for this global metric here? is other tracked in global metrics</technical_language>

Target:
public void run() { printStats(this.replicationManager.getStats()); printStats(this.replicationSink.getStats()); }
Source:
<code>public void setUp() { Sprite sprite = new SingleSprite("TestSprite"); <START> physicsLook = new PhysicsLook(sprite, new PhysicsWorld(1920, 1600)); <END> look = new Look(sprite); method.setAccessible(true); }</code><technical_language>please mock PhysicsWorld</technical_language>

Target:
public void setUp() { Sprite sprite = mock(Sprite.class); PhysicsWorld physicsWorld = new PhysicsWorld(1920, 1600); physicsLook = new PhysicsLook(sprite, physicsWorld); look = new Look(sprite); method.setAccessible(true); }
Source:
<code>private static void responseError(HttpServletRequest request, HttpServletResponse response, String errmsg) throws IOException { <START> if (errmsg == null || errmsg.length() == 0) <END> errmsg = "Invalid Request (see: Server logs for details)"; response.sendError(400, errmsg); }</code><technical_language>remove</technical_language>

Target:
private static void responseError(HttpServletRequest request, HttpServletResponse response, String errmsg) throws IOException { response.sendError(HttpServletResponse.SC_BAD_REQUEST, errmsg); }
Source:
<code><START> public static void loadLibrary(String name) { <END> String libname = System.mapLibraryName(name); if (tryLoadLibraryFromBuildDir(libname)) { return; } String os = System.getProperty("os.name"); if (os.equals("Linux")) { if (tryLoadLibraryFromFHS(libname)) { return; } } System.loadLibrary(name); }</code><technical_language>ensure this works for Hadoop. Placing library in Hadoop lib dir useful able install Hadoop root permissions</technical_language>

Target:
public static void loadLibrary(String name) { loadLibraryCalled = true; String libname = System.mapLibraryName(name); if (tryLoadFromXtreemfsLibPath(libname)) { return; } if (tryLoadLibraryFromBuildDir(libname)) { return; } String os = System.getProperty("os.name"); if (os.equals("Linux")) { if (tryLoadLibraryFromFHS(libname)) { return; } } System.loadLibrary(name); }
Source:
<code>public boolean performNextOperation(int completedChildCount) { syncChildCommandList(getParameters().getCommandStep(), getParameters().getChildCommands()); Guid currentChildId = getCurrentChildId(getParameters().getCommandStep(), getParameters().getChildCommands()); if (currentChildId != null) { getParameters().setCommandStep(getParameters().getNextCommandStep()); } <START> log.info("Executing Cold Merge command step '{}'", getParameters().getCommandStep()); <END> Pair<VdcActionType, ? extends VdcActionParametersBase> nextCommand = null; switch (getParameters().getCommandStep()) { case PREPARE_MERGE: break; case MERGE: break; case FINALIZE_MERGE: break; case DESTROY_IMAGE: break; case DESTROY_IMAGE_CHECK: break; case COMPLETE: getParameters().setDestroyImageCommandComplete(true); setCommandStatus(CommandStatus.SUCCEEDED); break; } persistCommand(getParameters().getParentCommand(), true); if (nextCommand != null) { runInternalActionWithTasksContext(nextCommand.getFirst(), nextCommand.getSecond()); return true; } else { return false; } }</code><technical_language>add command id (see logging is done in callback) - ease tracking concurrent execution of merge for disks</technical_language>

Target:
public boolean performNextOperation(int completedChildCount) { log.info("Executing Cold Merge command step '{}'", getParameters().getCommandStep()); Pair<VdcActionType, ? extends VdcActionParametersBase> nextCommand = null; switch (getParameters().getCommandStep()) { case PREPARE_MERGE: break; case MERGE: break; case FINALIZE_MERGE: break; case DESTROY_IMAGE: break; case DESTROY_IMAGE_CHECK: break; case COMPLETE: getParameters().setDestroyImageCommandComplete(true); setCommandStatus(CommandStatus.SUCCEEDED); break; } persistCommand(getParameters().getParentCommand(), true); if (nextCommand != null) { runInternalActionWithTasksContext(nextCommand.getFirst(), nextCommand.getSecond()); return true; } else { return false; } }
Source:
<code>public void profileChangePassword(WebContext ctx) { UserAccount userAccount = oma.refreshOrFail(getUser().getUserObject(UserAccount.class)); assertNotNew(userAccount); if (ctx.isSafePOST()) { try { String oldPassword = ctx.get(PARAM_OLD_PASSWORD).asString(); String newPassword = ctx.get(PARAM_NEW_PASSWORD).asString(); String confirmation = ctx.get(PARAM_CONFIRMATION).asString(); validateOldPassword(oldPassword, userAccount); userAccount.getLogin().verifyPassword(newPassword, confirmation, userAccount.getMinPasswordLength()); userAccount.getLogin().setCleartextPassword(newPassword); oma.update(userAccount); auditLog.neutral("%s changed her or his password.", UserContext.getCurrentUser().getUserName()) .forCurrentUser() .log(); showSavedMessage(); } catch (Exception e) { <START> auditLog.neutral("Ann error occurred when %s tried to changed her or his password: %s", <END> UserContext.getCurrentUser().getUserName(), e.getMessage()).forCurrentUser().log(); UserContext.handle(e); } } ctx.respondWith().template("/templates/tenants/profile-change-password.html.pasta", userAccount); }</code><technical_language>Typo</technical_language>

Target:
public void profileChangePassword(WebContext ctx) { UserAccount userAccount = oma.refreshOrFail(getUser().getUserObject(UserAccount.class)); assertNotNew(userAccount); if (ctx.ensureSafePOST()) { try { String oldPassword = ctx.get(PARAM_OLD_PASSWORD).asString(); String newPassword = ctx.get(PARAM_NEW_PASSWORD).asString(); String confirmation = ctx.get(PARAM_CONFIRMATION).asString(); validateOldPassword(oldPassword, userAccount); userAccount.getLogin().verifyPassword(newPassword, confirmation, userAccount.getMinPasswordLength()); userAccount.getLogin().setCleartextPassword(newPassword); oma.update(userAccount); auditLog.neutral("%s changed the password.", UserContext.getCurrentUser().getUserName()) .forCurrentUser() .log(); showSavedMessage(); } catch (Exception e) { auditLog.neutral("An error occurred when %s tried to changed the password: %s", UserContext.getCurrentUser().getUserName(), e.getMessage()).forCurrentUser().log(); UserContext.handle(e); } } ctx.respondWith().template("/templates/tenants/profile-change-password.html.pasta", userAccount); }
Source:
<code>protected void onBindView(@NonNull View view) { super.onBindView(view); TextView titleView = (TextView) view.findViewById(android.R.id.title); if (titleView != null) { Resources res = getContext().getResources(); titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.text_sz_large)); titleView.setTextColor(res.getColor(isEnabled() ? R.color.grey_dark : R.color.grey_lighten_10)); if (!TextUtils.isEmpty(getDependency())) { <START> titleView.setPadding(getContext().getResources().getDimensionPixelSize(R.dimen.margin_large), 0, 0, 0); <END> } } }</code><technical_language>res variable instead of getContext().getResources()</technical_language>

Target:
protected void onBindView(@NonNull View view) { super.onBindView(view); TextView titleView = (TextView) view.findViewById(android.R.id.title); if (titleView != null) { Resources res = getContext().getResources(); titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.text_sz_large)); titleView.setTextColor(res.getColor(isEnabled() ? R.color.grey_dark : R.color.grey_lighten_10)); if (!TextUtils.isEmpty(getDependency())) { titleView.setPadding(res.getDimensionPixelSize(R.dimen.margin_large), 0, 0, 0); } } }
Source:
<code>public static Span startInboundSpan( Request request, Tracer tracer, <START> TracingContext tracingContext) { <END> SpanContext parentContext = null; if (request instanceof TraceableRequest) { TraceableRequest traceableRequest = (TraceableRequest) request; Map<String, String> headers = traceableRequest.getHeaders(); PrefixedHeadersCarrier carrier = new PrefixedHeadersCarrier(headers); try { parentContext = tracer.extract(Format.Builtin.TEXT_MAP, carrier); Map<String, String> nonTracingHeaders = carrier.getNonTracingHeaders(); if (nonTracingHeaders.size() < headers.size()) { traceableRequest.updateHeaders(nonTracingHeaders); } } catch (Exception e) { logger.error("Failed to extract span context from headers", e); } } else { } Tracer.SpanBuilder builder = tracer.buildSpan(request.getEndpoint()); builder .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag("as", request.getArgScheme().name()); Map<String, String> transportHeaders = request.getTransportHeaders(); if (transportHeaders != null && transportHeaders.containsKey("cn")) { builder.withTag(Tags.PEER_SERVICE.getKey(), transportHeaders.get("cn")); } if (parentContext != null) { builder.asChildOf(parentContext); } Span span = builder.start(); tracingContext.clear(); tracingContext.pushSpan(span); return span; }</code><technical_language>nitty nit: move ) { next line</technical_language>

Target:
public static Span startInboundSpan( Request request, Tracer tracer, TracingContext tracingContext ) { SpanContext parentContext = null; if (request instanceof TraceableRequest) { TraceableRequest traceableRequest = (TraceableRequest) request; Map<String, String> headers = traceableRequest.getHeaders(); PrefixedHeadersCarrier carrier = new PrefixedHeadersCarrier(headers); try { parentContext = tracer.extract(Format.Builtin.TEXT_MAP, carrier); Map<String, String> nonTracingHeaders = carrier.getNonTracingHeaders(); if (nonTracingHeaders.size() < headers.size()) { traceableRequest.setHeaders(nonTracingHeaders); } } catch (Exception e) { logger.error("Failed to extract span context from headers", e); } } else { } Tracer.SpanBuilder builder = tracer.buildSpan(request.getEndpoint()); builder .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag("as", request.getArgScheme().name()); Map<String, String> transportHeaders = request.getTransportHeaders(); if (transportHeaders != null && transportHeaders.containsKey("cn")) { builder.withTag(Tags.PEER_SERVICE.getKey(), transportHeaders.get("cn")); } if (parentContext != null) { builder.asChildOf(parentContext); } Span span = builder.start(); tracingContext.clear(); tracingContext.pushSpan(span); return span; }
Source:
<code>public GenericRow next(GenericRow reuse) throws IOException { Message message = null; try { <START> DynamicMessage tmp = DynamicMessage.getDefaultInstance(_descriptor); <END> Message.Builder builder = tmp.newBuilderForType(); builder.mergeDelimitedFrom(_inputStream); message = builder.build(); } catch (Exception e) { throw new IOException("Caught exception while reading protobuf object", e); } _recordExtractor.extract(message, reuse); _hasNext = hasMoreToRead(); return reuse; }</code><technical_language>s/tmp/tempDynamicMessage</technical_language>

Target:
public GenericRow next(GenericRow reuse) throws IOException { Message message = null; try { Message.Builder builder = _dynamicMessage.newBuilderForType(); builder.mergeDelimitedFrom(_inputStream); message = builder.build(); } catch (Exception e) { throw new IOException("Caught exception while reading protobuf object", e); } _recordExtractor.extract(message, reuse); _hasNext = hasMoreToRead(); return reuse; }