auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try{ String upgradeQuery = "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.UNIT_URL + " TEXT " + " ADD COLUMN " + DbStructure.Column.URL_HIGH_QUALITY + " TEXT " <START> + " ADD COLUMN " + DbStructure.Column.URL_LOW_QUALITY + " TEXT " <END> + " ADD COLUMN " + DbStructure.Column.URL_YOUTUBE + " TEXT "; if (oldVersion == 1 && newVersion == 2) { db.execSQL(upgradeQuery); } logger.debug("Database upgraded from " + oldVersion + " to " + newVersion); }catch(Exception e){ logger.error(e); } }</code><technical_language>This work Db version is changed 3 check for version is 2</technical_language>

Target:
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try { String upgradeToV2 = "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.UNIT_URL + " TEXT "; String[] upgradeToV3 = new String[] { "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.UNIT_URL + " TEXT ", "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.URL_HIGH_QUALITY + " TEXT ", "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.URL_LOW_QUALITY + " TEXT ", "ALTER TABLE " + DbStructure.Table.DOWNLOADS + " ADD COLUMN " + DbStructure.Column.URL_YOUTUBE + " TEXT "}; if (oldVersion == 1 && newVersion == 2) { db.execSQL(upgradeToV2); } if (oldVersion == 1 && newVersion == 3) { for (String query : upgradeToV3) { db.execSQL(query); } } logger.debug("Database upgraded from " + oldVersion + " to " + newVersion); }catch(Exception e){ logger.error(e); } }
Source:
<code>static Vector<Vector<Integer>> loadTriangle(String fileName) { return Vector.ofAll( Utils.readLines(Utils.file(fileName)).map(line -> Arrays.stream(line.split("\\s")).map(Integer::parseInt) <START> ).map(s -> List.ofAll(s::iterator).toVector()) <END> ); }</code><technical_language>reverted again</technical_language>

Target:
static Vector<Vector<Integer>> loadTriangle(String fileName) { return Vector.ofAll( Utils.readLines(Utils.file(fileName)).map(line -> Arrays.stream(line.split("\\s")).map(Integer::parseInt) ).map(s -> Vector.ofAll(s::iterator)) ); }
Source:
<code>public void onLightStateChanged(HueBridge bridge, FullLight fullLight) { logger.trace("onLightStateChanged() was called"); <START> if (fullLight == null) { <END> logger.warn("Unable to change state for null light."); return; } if (!fullLight.getId().equals(lightId)) { logger.trace("Received state change for another handler's light ({}). Will be ignored.", fullLight.getId()); return; } initializeProperties(); lastSentColorTemp = null; lastSentBrightness = null; if (fullLight.getState().isReachable()) { updateStatus(ThingStatus.ONLINE); } else { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Bridge reports light as not reachable"); } HSBType hsbType = LightStateConverter.toHSBType(fullLight.getState()); if (!fullLight.getState().isOn()) { hsbType = new HSBType(hsbType.getHue(), hsbType.getSaturation(), new PercentType(0)); } updateState(CHANNEL_COLOR, hsbType); PercentType percentType = LightStateConverter.toColorTemperaturePercentType(fullLight.getState()); updateState(CHANNEL_COLORTEMPERATURE, percentType); percentType = LightStateConverter.toBrightnessPercentType(fullLight.getState()); if (!fullLight.getState().isOn()) { percentType = new PercentType(0); } updateState(CHANNEL_BRIGHTNESS, percentType); if (fullLight.getState().isOn()) { updateState(CHANNEL_SWITCH, OnOffType.ON); } else { updateState(CHANNEL_SWITCH, OnOffType.OFF); } StringType stringType = LightStateConverter.toAlertStringType(fullLight.getState()); if (!stringType.toString().equals("NULL")) { updateState(CHANNEL_ALERT, stringType); scheduleAlertStateRestore(stringType); } }</code><technical_language>sense new @NonNull annotation parameter here, this check obsolete</technical_language>

Target:
public void onLightStateChanged(HueBridge bridge, FullLight fullLight) { logger.trace("onLightStateChanged() was called"); if (!fullLight.getId().equals(lightId)) { logger.trace("Received state change for another handler's light ({}). Will be ignored.", fullLight.getId()); return; } initializeProperties(); lastSentColorTemp = null; lastSentBrightness = null; if (fullLight.getState().isReachable()) { updateStatus(ThingStatus.ONLINE); } else { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/offline.light-not-reachable"); } HSBType hsbType = LightStateConverter.toHSBType(fullLight.getState()); if (!fullLight.getState().isOn()) { hsbType = new HSBType(hsbType.getHue(), hsbType.getSaturation(), new PercentType(0)); } updateState(CHANNEL_COLOR, hsbType); PercentType percentType = LightStateConverter.toColorTemperaturePercentType(fullLight.getState()); updateState(CHANNEL_COLORTEMPERATURE, percentType); percentType = LightStateConverter.toBrightnessPercentType(fullLight.getState()); if (!fullLight.getState().isOn()) { percentType = new PercentType(0); } updateState(CHANNEL_BRIGHTNESS, percentType); if (fullLight.getState().isOn()) { updateState(CHANNEL_SWITCH, OnOffType.ON); } else { updateState(CHANNEL_SWITCH, OnOffType.OFF); } StringType stringType = LightStateConverter.toAlertStringType(fullLight.getState()); if (!stringType.toString().equals("NULL")) { updateState(CHANNEL_ALERT, stringType); scheduleAlertStateRestore(stringType); } }
Source:
<code>public HttpClient build() { if (connectionPool != null) { this.httpClientBuilder = httpClientBuilder.connectionPool(connectionPool); } if (dispatcher != null) { this.httpClientBuilder = httpClientBuilder.dispatcher(dispatcher); } return new OkHttpAsyncHttpClient(this.httpClientBuilder.build()); <START> } <END></code><technical_language>I this builder pattern needs consideration. For example, for person create HttpClient instances this builder a dispatcher not, unable null out. I remove constructor takes HttpClientBuilder create in build() method here</technical_language>

Target:
public HttpClient build() { OkHttpClient.Builder httpClientBuilder = this.okHttpClient == null ? new OkHttpClient.Builder() : this.okHttpClient.newBuilder(); for (Interceptor interceptor : this.networkInterceptors) { httpClientBuilder = httpClientBuilder.addNetworkInterceptor(interceptor); } if (this.readTimeout != null) { httpClientBuilder = httpClientBuilder.readTimeout(this.readTimeout); } else { httpClientBuilder = httpClientBuilder.readTimeout(DEFAULT_READ_TIMEOUT); } if (this.connectionTimeout != null) { httpClientBuilder = httpClientBuilder.connectTimeout(this.connectionTimeout); } else { httpClientBuilder = httpClientBuilder.connectTimeout(DEFAULT_CONNECT_TIMEOUT); } if (this.connectionPool != null) { httpClientBuilder = httpClientBuilder.connectionPool(connectionPool); } if (this.dispatcher != null) { httpClientBuilder = httpClientBuilder.dispatcher(dispatcher); } httpClientBuilder = httpClientBuilder.proxy(this.proxy); if (this.proxyAuthenticator != null) { httpClientBuilder = httpClientBuilder.authenticator(this.proxyAuthenticator); } return new OkHttpAsyncHttpClient(httpClientBuilder.build()); }
Source:
<code>public void setIconSclass(String iconSclass) { <START> if (_iconSclass != iconSclass) { <END> _iconSclass = iconSclass; smartUpdate("iconSclass", iconSclass); } }</code><technical_language>String equals</technical_language>

Target:
public void setIconSclass(String iconSclass) { if (!Objects.equals(_iconSclass, iconSclass)) { _iconSclass = iconSclass; smartUpdate("iconSclass", iconSclass); } }
Source:
<code>private static boolean shouldAnalyzeMethod(MethodTree methodTree) { <START> return methodTree.block() != null && ((ClassTree) methodTree.parent()).simpleName() != null && !isWithinLocalClass(methodTree); <END> }</code><technical_language>minor: simpleName() != null extracted isAnonymousClass method, intent of test is more obvious</technical_language>

Target:
private static boolean shouldAnalyzeMethod(MethodTree methodTree) { return methodTree.block() != null && !memberOfAnonymousClass(methodTree) && !isWithinLocalClass(methodTree); }
Source:
<code><START> public boolean equals(Object o) { <END> if (this == o) { return true; } BaseCardinalityKey that = (BaseCardinalityKey) o; if (alias != null ? !alias.equals(that.alias) : that.alias != null) { return false; } if (key != null ? !key.equals(that.key) : that.key != null) { return false; } if (normalizedValue != null ? !normalizedValue.equals(that.normalizedValue) : that.normalizedValue != null) { return false; } return true; }</code><technical_language>Is this autogenerated? dropped null safety check</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } else if(o == null) return false; BaseCardinalityKey that = (BaseCardinalityKey) o; if (alias != null ? !alias.equals(that.alias) : that.alias != null) { return false; } if (key != null ? !key.equals(that.key) : that.key != null) { return false; } if (normalizedValue != null ? !normalizedValue.equals(that.normalizedValue) : that.normalizedValue != null) { return false; } return true; }
Source:
<code>void createStreams(List<StreamSpec> intStreams) throws Exception { if (!intStreams.isEmpty()) { StandAloneCoordinationUtils coordinationUtils1 = null; try { coordinationUtils1 = new StandAloneCoordinationUtils("APP_ID", uid, config); } catch (SamzaException e) { LOG.warn("Coordination utils are not available.", e); } if (coordinationUtils1 != null) { Latch initLatch = coordinationUtils1.getLatch(1, INIT_LATCH_ID); LeaderElector leaderElector = coordinationUtils1.getLeaderElector(); leaderElector.setLeaderElectorListener(() -> { getStreamManager().createStreams(intStreams); initLatch.countDown(); }); leaderElector.tryBecomeLeader(); initLatch.await(LATCH_TIMEOUT_MINUTES, TimeUnit.MINUTES); leaderElector.close(); <START> initLatch.close(); <END> } else { getStreamManager().createStreams(intStreams); } } }</code><technical_language>happen if a new StreamProcessor joins app is started running? trigger leader election</technical_language>

Target:
void createStreams(List<StreamSpec> intStreams) throws Exception { if (!intStreams.isEmpty()) { CoordinationUtils coordinationUtils = null; try { coordinationUtils = CoordinationUtils.getCoordinationUtils("APP_ID", uid, config); } catch (SamzaException e) { LOG.warn("Coordination utils are not available.", e); } if (coordinationUtils != null) { Latch initLatch = coordinationUtils.getLatch(1, INIT_LATCH_ID); LeaderElector leaderElector = coordinationUtils.getLeaderElector(); leaderElector.setLeaderElectorListener(() -> { getStreamManager().createStreams(intStreams); initLatch.countDown(); }); leaderElector.tryBecomeLeader(); initLatch.await(LATCH_TIMEOUT_MINUTES, TimeUnit.MINUTES); leaderElector.close(); initLatch.close(); } else { getStreamManager().createStreams(intStreams); } } }
Source:
<code>public static synchronized EventDeclaration getLostEventDeclaration() { EventDeclaration lostEvent = new EventDeclaration(); IntegerDeclaration lostEventsDeclaration = new IntegerDeclaration(32, false, 32, ByteOrder.LITTLE_ENDIAN, Encoding.ASCII, null, 32); lostEvent.fields = new StructDeclaration(1); <START> lostEvent.fields.addField("Lost events", lostEventsDeclaration); END> lostEvent.id = -1L; lostEvent.name = "Lost event"; return lostEvent; }</code><technical_language>create a string constant for field name</technical_language>

Target:
public static synchronized EventDeclaration getLostEventDeclaration() { EventDeclaration lostEvent = new EventDeclaration(); IntegerDeclaration lostEventsDeclaration = new IntegerDeclaration(32, false, 32, ByteOrder.LITTLE_ENDIAN, Encoding.ASCII, null, 32); lostEvent.fields = new StructDeclaration(1); lostEvent.fields.addField(CTFStrings.LOST_EVENTS_FIELD, lostEventsDeclaration); lostEvent.id = -1L; lostEvent.name = CTFStrings.LOST_EVENT_NAME; return lostEvent; }
Source:
<code>private By buildByFromHtmlElementListAnnotations() { assertValidAnnotations(); if (getField().isAnnotationPresent(FindBys.class)) { FindBys findBys = getField().getAnnotation(FindBys.class); return buildByFromFindBys(findBys); } <START> if (getField().isAnnotationPresent(FindAll.class)) { <END> FindAll findBys = getField().getAnnotation(FindAll.class); return buildBysFromFindAll(findBys); } if (getField().isAnnotationPresent(FindBy.class)) { FindBy findBy = getField().getAnnotation(FindBy.class); return buildByFromFindBy(findBy); } Class<?> listParameterClass = getGenericParameterClass(getField()); while (listParameterClass != Object.class) { if (listParameterClass.isAnnotationPresent(Block.class)) { Block block = listParameterClass.getAnnotation(Block.class); FindBy findBy = block.value(); return buildByFromFindBy(findBy); } listParameterClass = listParameterClass.getSuperclass(); } throw new HtmlElementsException(String.format("Cannot determine how to locate element %s", getField())); }</code><technical_language>if-statements completely in methods, lets move separate method</technical_language>

Target:
private By buildByFromHtmlElementListAnnotations() { assertValidAnnotations(); By result = buildByFromFindAnnotations(); if (result != null) { return result; } Class<?> listParameterClass = getGenericParameterClass(getField()); while (listParameterClass != Object.class) { if (listParameterClass.isAnnotationPresent(Block.class)) { Block block = listParameterClass.getAnnotation(Block.class); FindBy findBy = block.value(); return buildByFromFindBy(findBy); } listParameterClass = listParameterClass.getSuperclass(); } throw new HtmlElementsException(String.format("Cannot determine how to locate element %s", getField())); }
Source:
<code>protected void configure() { install (new ThreadDelegatedScopeModule()); final MetricRegistry metricRegistry = new MetricRegistry(); bind(MetricRegistry.class).toInstance(metricRegistry); install (new MetricsInstrumentationModule(metricRegistry)); bind(HealthCheckRegistry.class).toInstance(new HealthCheckRegistry()); install (new JmxServerModule()); install (new JolokiaModule()); install (new HttpServerModule(config)); bind (OTJacksonJsonProvider.class); install (new OpenTableJacksonModule()); install (new DefaultMetricsModule()); install (new ServerInfoModule()); <START> install (new ConservedHeadersModule()); <END> JaxRsClientBinder.bindFeatureToGroup(binder(), StandardFeatureGroup.PLATFORM_INTERNAL) .to(ClientConservedHeadersFeature.class); install (new OpenTableJaxRsServletModule(config, paths)); install (new OpenTableJaxRsExceptionMapperModule()); }</code><technical_language>This break healthchecks in Java service</technical_language>

Target:
protected void configure() { install (new ThreadDelegatedScopeModule()); final MetricRegistry metricRegistry = new MetricRegistry(); bind(MetricRegistry.class).toInstance(metricRegistry); install (new MetricsInstrumentationModule(metricRegistry)); bind(HealthCheckRegistry.class).toInstance(new HealthCheckRegistry()); install (new JmxServerModule()); install (new JolokiaModule()); install (new HttpServerModule(config)); bind (OTJacksonJsonProvider.class); install (new OpenTableJacksonModule()); install (new DefaultMetricsModule()); install (new HealthHttpModule()); install (new ServerInfoModule()); install (new ConservedHeadersModule()); JaxRsClientBinder.bindFeatureToGroup(binder(), StandardFeatureGroup.PLATFORM_INTERNAL) .to(ClientConservedHeadersFeature.class); install (new OpenTableJaxRsServletModule(config, paths)); install (new OpenTableJaxRsExceptionMapperModule()); }
Source:
<code>public CacheStream<CacheEntry<K, V>> stream() { <START> return stream(false); <END> }</code><technical_language>a name, e.g. doStream</technical_language>

Target:
public CacheStream<CacheEntry<K, V>> stream() { return doStream(false); }
Source:
<code>public void onServiceConnected(ComponentName component, IBinder service) { if (component.equals(new ComponentName( FileDisplayActivity.this, FileDownloader.class))) { Log_OC.d(TAG, "Download service connected"); mDownloaderBinder = (FileDownloaderBinder) service; if (mFileWaitingToPreview != null) if (getStorageManager() != null) { mFileWaitingToPreview = getStorageManager().getFileById(mFileWaitingToPreview.getFileId()); if (!mFileWaitingToPreview.isDown()) { requestForDownload(); } } if (getFile() != null && mDownloaderBinder.isDownloading(getAccount(), getFile())) { FileFragment secondFragment = getSecondFragment(); if (secondFragment != null && secondFragment instanceof PreviewVideoFragment) { cleanSecondFragment(); <START> Fragment detailFragment = FileDetailFragment.newInstance(getFile(), getAccount()); <END> setSecondFragment(detailFragment); updateFragmentsVisibility(true); updateActionBarTitleAndHomeButton(getFile()); } } } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; } else { return; } OCFileListFragment listOfFiles = getListOfFilesFragment(); if (listOfFiles != null) { listOfFiles.listDirectory(false); } FileFragment secondFragment = getSecondFragment(); if (secondFragment != null) { secondFragment.onTransferServiceConnected(); } }</code><technical_language>call showDetails(getFile()) instead of 4 duplicated lines</technical_language>

Target:
public void onServiceConnected(ComponentName component, IBinder service) { if (component.equals(new ComponentName( FileDisplayActivity.this, FileDownloader.class))) { Log_OC.d(TAG, "Download service connected"); mDownloaderBinder = (FileDownloaderBinder) service; if (mFileWaitingToPreview != null) if (getStorageManager() != null) { mFileWaitingToPreview = getStorageManager().getFileById(mFileWaitingToPreview.getFileId()); if (!mFileWaitingToPreview.isDown()) { requestForDownload(); } } if (getFile() != null && mDownloaderBinder.isDownloading(getAccount(), getFile())) { FileFragment secondFragment = getSecondFragment(); if (secondFragment != null && secondFragment instanceof PreviewVideoFragment) { cleanSecondFragment(); showDetails(getFile()); } } } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; } else { return; } OCFileListFragment listOfFiles = getListOfFilesFragment(); if (listOfFiles != null) { listOfFiles.listDirectory(false); } FileFragment secondFragment = getSecondFragment(); if (secondFragment != null) { secondFragment.onTransferServiceConnected(); } }
Source:
<code>public NetworkSecurityRuleImpl withAnyProtocol() { <START> return this.withProtocol(SecurityRuleProtocol.fromString("*")); <END> }</code><technical_language>enum</technical_language>

Target:
public NetworkSecurityRuleImpl withAnyProtocol() { return this.withProtocol(SecurityRuleProtocol.STAR); }
Source:
<code>private Properties collapse(final Properties properties, final String envName) { Properties collapsed = new Properties(); for (final String key : properties.stringPropertyNames()) { if (isDefaultProperty(key)) { String value = properties.getProperty(key); LOG.debug("Set Key=" + key + " with value=" + value); collapsed.setProperty(key, value); } } for (final String key : properties.stringPropertyNames()) { if (key.startsWith(envName + ".")) { String value = properties.getProperty(key); String strippedName = key.substring(envName.length() + 1); LOG.debug("Overwrite Key=" + key + " with value=" + value); collapsed.setProperty(strippedName, value); } } <START> for (final String key : properties.stringPropertyNames()) { <END> String value = sysReader.read(key); if (value == null) { value = envReader.read(key); } if (value != null) { if (key.startsWith(envName + ".")) { String strippedName = key.substring(envName.length() + 1); LOG.debug("Overwrite with Env Key=" + strippedName + " with value=" + value); collapsed.setProperty(strippedName, value); } else { LOG.debug("Overwrite with Env Key=" + key + " with value=" + value); collapsed.setProperty(key, value); } } } return collapsed; }</code><technical_language>store AWS keys in env vars, this accidentally leak keys logs</technical_language>

Target:
private Properties collapse(final Properties properties, final String envName) { Properties collapsed = new Properties(); for (final String key : properties.stringPropertyNames()) { if (isDefaultProperty(key)) { collapsed.setProperty(key, properties.getProperty(key)); } } for (final String key : properties.stringPropertyNames()) { if (key.startsWith(envName + ".")) { String strippedName = key.substring(envName.length() + 1); collapsed.setProperty(strippedName, properties.getProperty(key)); } } for (final String key : properties.stringPropertyNames()) { String value = sysReader.read(key); if (value == null) { value = envReader.read(key); } if (value != null) { if (key.startsWith(envName + ".")) { String strippedName = key.substring(envName.length() + 1); collapsed.setProperty(strippedName, value); } else { collapsed.setProperty(key, value); } } } return collapsed; }
Source:
<code>public CoreEvent process(final CoreEvent event) throws MuleException { if (nestedChain == null) { return event; } <START> final boolean alreadyActiveTx = isTransactionActive(); <END> ExecutionTemplate<CoreEvent> executionTemplate = createScopeTransactionalExecutionTemplate(muleContext, transactionConfig); ExecutionCallback<CoreEvent> processingCallback = () -> { if (!alreadyActiveTx && isTransactionActive()) { TransactionAdapter transaction = (TransactionAdapter) TransactionCoordination.getInstance().getTransaction(); transaction.setComponentLocation(getLocation()); return processWithChildContextBlocking(event, nestedChain, ofNullable(getLocation()), messagingExceptionHandler); } else { return processWithChildContextBlocking(event, nestedChain, ofNullable(getLocation()), messagingExceptionHandler); } }; try { return executionTemplate.execute(processingCallback); } catch (MuleException e) { throw e; } catch (Exception e) { throw new DefaultMuleException(errorInvokingMessageProcessorWithinTransaction(nestedChain, transactionConfig), e); } }</code><technical_language>rename this variable txPrevoiuslyActive</technical_language>

Target:
public CoreEvent process(final CoreEvent event) throws MuleException { if (nestedChain == null) { return event; } final boolean txPrevoiuslyActive = isTransactionActive(); ExecutionTemplate<CoreEvent> executionTemplate = createScopeTransactionalExecutionTemplate(muleContext, transactionConfig); ExecutionCallback<CoreEvent> processingCallback = () -> { if (!txPrevoiuslyActive && isTransactionActive()) { TransactionAdapter transaction = (TransactionAdapter) TransactionCoordination.getInstance().getTransaction(); transaction.setComponentLocation(getLocation()); return processWithChildContextBlocking(event, nestedChain, ofNullable(getLocation()), messagingExceptionHandler); } else { return processWithChildContextBlocking(event, nestedChain, ofNullable(getLocation()), messagingExceptionHandler); } }; try { return executionTemplate.execute(processingCallback); } catch (MuleException e) { throw e; } catch (Exception e) { throw new DefaultMuleException(errorInvokingMessageProcessorWithinTransaction(nestedChain, transactionConfig), e); } }
Source:
<code>public int compareTo(TextTrackScore other) { if (this.isWithinRendererCapabilities != other.isWithinRendererCapabilities) { return this.isWithinRendererCapabilities ? 1 : -1; } if (this.preferredLanguageScore != other.preferredLanguageScore) { return compareInts(this.preferredLanguageScore, other.preferredLanguageScore); } <START> if (this.preferredRoleFlagsScore != other.preferredRoleFlagsScore) { <END> return compareInts(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore); } if (this.isDefault != other.isDefault) { return this.isDefault ? 1 : -1; } if (this.hasPreferredIsForcedFlag != other.hasPreferredIsForcedFlag) { return this.hasPreferredIsForcedFlag ? 1 : -1; } return compareInts(this.selectedAudioLanguageScore, other.selectedAudioLanguageScore); }</code><technical_language>If else is same, role flag preference is provided in parameters, compare existing role flags prefer tracks *without* DESCRIBES_MUSIC_AND_SOUND role flags. This assumption specification means non-captioning text tracks preferred. This comparison selectedAudioLanguageScore</technical_language>

Target:
public int compareTo(TextTrackScore other) { if (this.isWithinRendererCapabilities != other.isWithinRendererCapabilities) { return this.isWithinRendererCapabilities ? 1 : -1; } if (this.preferredLanguageScore != other.preferredLanguageScore) { return compareInts(this.preferredLanguageScore, other.preferredLanguageScore); } if (this.isDefault != other.isDefault) { return this.isDefault ? 1 : -1; } if (this.hasPreferredIsForcedFlag != other.hasPreferredIsForcedFlag) { return this.hasPreferredIsForcedFlag ? 1 : -1; } if (this.selectedAudioLanguageScore != other.selectedAudioLanguageScore) { return compareInts(this.selectedAudioLanguageScore, other.selectedAudioLanguageScore); } if (!this.hasPreferredRoleFlags) { return compareInts(other.hasCaptionRoleFlags, this.hasCaptionRoleFlags); } return compareInts(this.preferredRoleFlagsScore, other.preferredRoleFlagsScore); }
Source:
<code>public void attach(Attachable attachable) { if (attachable instanceof OpenCV) { opencv = (OpenCV) attachable; subscribe(opencv.getName(), "publishClassification"); } else if (attachable instanceof SpeechRecognizer) { if (attachable.getClass().getSimpleName().equals("WebkitSpeechRecognition")) { <START> WebGui webgui = (WebGui) Runtime.create("webgui", "WebGui"); <END> webgui.autoStartBrowser(false); webgui.startService(); webgui.startBrowser("http://localhost:8888/#/service/" + attachable.getName()); } ear = (SpeechRecognizer) attachable; } else if (attachable instanceof ProgramAB) { if (htmlFilter == null) { htmlFilter = (HtmlFilter) Runtime.start(this.getIntanceName() + ".htmlFilter", "HtmlFilter"); } chatBot = (ProgramAB) attachable; } if (chatBot != null && ear != null) { chatBot.attach((Attachable) ear); } if (chatBot != null && mouth != null) { chatBot.addTextListener(htmlFilter); htmlFilter.addListener("publishText", this.getName(), "speak"); } if (mouth != null && ear != null) { ear.addMouth(mouth); } broadcastState(); }</code><technical_language>changing parameters of webgui creating it. created if passed this method. Please remove</technical_language>

Target:
public void attach(Attachable attachable) { if (attachable instanceof OpenCV) { opencv = (OpenCV) attachable; subscribe(opencv.getName(), "publishClassification"); } else if (attachable instanceof SpeechSynthesis) { mouth = (SpeechSynthesis) attachable; if (ear != null) { ear.addMouth(mouth); } } else if (attachable instanceof SpeechRecognizer) { ear = (SpeechRecognizer) attachable; if (mouth != null) { ear.addMouth(mouth); } } else if (attachable instanceof ProgramAB) { chatBot = (ProgramAB) attachable; } }
Source:
<code>public boolean downloadTemplate() { s_logger.debug("Retrieving metalink file from: " + getUrl() + " to file: " + getDownloadedFilePath()); List<String> metalinkUrls = UriUtils.getMetalinkUrls(getUrl()); if (CollectionUtils.isNotEmpty(metalinkUrls)) { String downloadDir = getDirectDownloadTempPath(getTemplateId()); boolean downloaded = false; int i = 0; <START> while (!downloaded && i < metalinkUrls.size()) { <END> try { setUrl(metalinkUrls.get(i)); s_logger.debug("Trying to download template from metalink url: " + getUrl()); File f = new File(getDestPoolPath() + File.separator + downloadDir + File.separator + getFileNameFromUrl()); if (f.exists()) { f.delete(); f.createNewFile(); } setDownloadedFilePath(f.getAbsolutePath()); request = createRequest(getUrl(), reqHeaders); downloaded = super.downloadTemplate(); if (downloaded) { s_logger.debug("Successfully downloaded template from metalink url: " + getUrl()); break; } } catch (Exception e) { s_logger.error("Error downloading template: " + getTemplateId() + " from " + getUrl() + ": " + e.getMessage()); } i++; } return downloaded; } return true; }</code><technical_language>do while this a shorter, no? complexity of this method warrant a refactor extracting a private method</technical_language>

Target:
public boolean downloadTemplate() { if (StringUtils.isBlank(getUrl())) { throw new CloudRuntimeException("Download url has not been set, aborting"); } String downloadDir = getDirectDownloadTempPath(getTemplateId()); boolean downloaded = false; int i = 0; do { if (!isRedownload()) { setUrl(metalinkUrls.get(i)); } s_logger.info("Trying to download template from url: " + getUrl()); try { File f = new File(getDestPoolPath() + File.separator + downloadDir + File.separator + getFileNameFromUrl()); if (f.exists()) { f.delete(); f.createNewFile(); } setDownloadedFilePath(f.getAbsolutePath()); request = createRequest(getUrl(), reqHeaders); downloaded = super.downloadTemplate(); if (downloaded) { s_logger.info("Successfully downloaded template from url: " + getUrl()); } } catch (Exception e) { s_logger.error("Error downloading template: " + getTemplateId() + " from " + getUrl() + ": " + e.getMessage()); } i++; } while (!downloaded && !isRedownload() && i < metalinkUrls.size()); return downloaded; }
Source:
<code>protected void execute() { logger.debug("execute() method is called!"); if (this.devicesMap.isEmpty()) { return; } List<MystromDevice> devices = this.mystromClient.getDevicesState(); for (MyStromEcoPowerBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { logger.debug("Mystrom eco power switch '{}' state will be updated", itemName); String friendlyName = provider.getMystromFriendlyName(itemName); String id = this.devicesMap.get(friendlyName); if (id != null) { MystromDevice device = null; for (MystromDevice searchDevice : devices) { if (searchDevice.id.equals(id)) { device = searchDevice; break; } } if (device != null) { if (provider.getIsSwitch(itemName)) { State state = device.state.equals("on") ? OnOffType.ON : OnOffType.OFF; eventPublisher.postUpdate(itemName, state); } if (provider.getIsStringItem(itemName)) { eventPublisher.postUpdate(itemName, new StringType(device.state)); } if (provider.getIsNumberItem(itemName)) { eventPublisher.postUpdate(itemName, new DecimalType(device.power)); } } } else { <START> logger.warn("The device itemName '{}' not found on discovery verify device is not offline", <END> itemName); } } } }</code><technical_language>If I merge this is, open a new PR revert this change in message? Otherwise, revert change a new commit this PR branch, squash is commit</technical_language>

Target:
protected void execute() { logger.debug("execute() method is called!"); if (this.devicesMap.isEmpty()) { return; } List<MystromDevice> devices = this.mystromClient.getDevicesState(); for (MyStromEcoPowerBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { logger.debug("Mystrom eco power switch '{}' state will be updated", itemName); String friendlyName = provider.getMystromFriendlyName(itemName); String id = this.devicesMap.get(friendlyName); if (id != null) { MystromDevice device = null; for (MystromDevice searchDevice : devices) { if (searchDevice.id.equals(id)) { device = searchDevice; break; } } if (device != null) { if (provider.getIsSwitch(itemName)) { State state = device.state.equals("on") ? OnOffType.ON : OnOffType.OFF; eventPublisher.postUpdate(itemName, state); } if (provider.getIsStringItem(itemName)) { eventPublisher.postUpdate(itemName, new StringType(device.state)); } if (provider.getIsNumberItem(itemName)) { eventPublisher.postUpdate(itemName, new DecimalType(device.power)); } } } else { logger.warn("The device itemName '{}' not found on discovery. Verify device is not offline", itemName); } } } }
Source:
<code>public boolean contains(OGCGeometry another) { if (another.geometryType() == OGCConcreteGeometryCollection.TYPE) { <START> return another.contains(this); <END> } com.esri.core.geometry.Geometry geom1 = getEsriGeometry(); com.esri.core.geometry.Geometry geom2 = another.getEsriGeometry(); return com.esri.core.geometry.GeometryEngine.contains(geom1, geom2, getEsriSpatialReference()); }</code><technical_language>this.contains(another) is equal another.contains(this), is it? test in [TestOGCContains.java.txt](<LINK_0> fails: assertContains("MULTIPOINT (1 2, 3 4)", "GEOMETRYCOLLECTION (POINT (1 2))");</technical_language>

Target:
public boolean contains(OGCGeometry another) { if (another.geometryType() == OGCConcreteGeometryCollection.TYPE) { return new OGCConcreteGeometryCollection(this, esriSR).contains(another); } com.esri.core.geometry.Geometry geom1 = getEsriGeometry(); com.esri.core.geometry.Geometry geom2 = another.getEsriGeometry(); return com.esri.core.geometry.GeometryEngine.contains(geom1, geom2, getEsriSpatialReference()); }
Source:
<code><START> protected void delete(Context context, Integer id) { <END> XmlWorkflowItem witem = null; try { witem = wis.find(context, id); } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } try { wfs.abort(context, witem, context.getCurrentUser()); context.addEvent(new Event(Event.MODIFY, Constants.ITEM, witem.getItem().getID(), null, itemService.getIdentifiers(context, witem.getItem()))); } catch (SQLException | AuthorizeException | IOException e) { log.error(e.getMessage(), e); } }</code><technical_language>Is a need for a separate delete function here? configurable workflow handles this result of action</technical_language>

Target:
protected void delete(Context context, Integer id) { XmlWorkflowItem witem = null; try { witem = wis.find(context, id); if (witem == null) { throw new ResourceNotFoundException("WorkflowItem ID " + id + " not found"); } wfs.abort(context, witem, context.getCurrentUser()); } catch (AuthorizeException e) { throw new RESTAuthorizationException(e); } catch (SQLException | IOException e) { throw new RuntimeException(e.getMessage(), e); } }
Source:
<code>public void shouldMakeAbsoluteUriOnRealPlatform() throws Exception { File testDir = new File( BASE_DIR, "target/@2 test with white spaces" ); testDir.mkdir(); URI testDirUri = new URI( JarManifestForkConfiguration.toAbsoluteUri( testDir.getCanonicalPath() ) ); assertThat( testDirUri.getScheme() ) .isEqualTo( "file" ); assertThat( testDirUri.getRawPath() ) <START> .isEqualTo( testDir.toURI().getRawPath() ); <END> }</code><technical_language>This fail run Windows a project directory is a UNC path a drive letter: File.toURL numerous problems corrected File.toUri, File.toUri some problems corrected Path.toUri. I suggest dropping shouldRelativizeOnRealPlatform shouldMakeAbsoluteUriOnRealPlatform. If want unit tests, is I originally wrote. If want more realistic, demonstrating _result_ is intended, shouldMakeRelativeUriOnRealPlatform is better</technical_language>

Target:
public void shouldMakeAbsoluteUriOnRealPlatform() throws Exception { Path testDir = new File( TMP, "@2 test with white spaces" ) .toPath(); URI testDirUri = new URI( toAbsoluteUri( testDir ) ); assertThat( testDirUri.getScheme() ) .isEqualTo( "file" ); assertThat( testDirUri.getRawPath() ) .isEqualTo( testDir.toUri().getRawPath() ); }
Source:
<code>public String getStringData() { try { return IOUtils.toString(this.stream); } catch (final IOException exception) { <START> throw new RuntimeException("Unable to read input", exception); <END> } }</code><technical_language>throw RuntimeException? Throw IllegalArgumentException remove SuppressWarnings</technical_language>

Target:
public String getStringData() { try { return IOUtils.toString(this.stream); } catch (final IOException exception) { throw new IllegalArgumentException( "Unable to read input", exception ); } }
Source:
<code>public EventExecutor next() { <START> if (isPowerOfTwo(children.length)) { <END> return children[idx.getAndIncrement() & children.length - 1]; } return children[Math.abs(idx.getAndIncrement() % children.length)]; }</code><technical_language>Nit: children is final, children.length change need calculate this single time</technical_language>

Target:
public EventExecutor next() { if (powerOfTwo) { return children[idx.getAndIncrement() & children.length - 1]; } return children[Math.abs(idx.getAndIncrement() % children.length)]; }
Source:
<code>private static boolean isAnalyticsEnabled() { Settings settings = SoapUI.getSettings(); boolean analyticsEnabled = settings.getBoolean(UISettings.DISABLE_ANALYTICS, false); if (analyticsEnabled) { return true; } Version optOutVersion = new Version(settings.getString(UISettings.ANALYTICS_OPT_OUT_VERSION, "0.0")); Version currentSoapUIVersion = new Version(SoapUI.SOAPUI_VERSION); if (!optOutVersion.getMajorVersion().equals(currentSoapUIVersion.getMajorVersion()) && SoapUI.usingGraphicalEnvironment()) { analyticsEnabled = StatisticsCollectionConfirmationDialog.showDialog() == JOptionPane.YES_OPTION; settings.setBoolean(UISettings.DISABLE_ANALYTICS, !analyticsEnabled); } if (!analyticsEnabled) { <START> settings.setString(UISettings.ANALYTICS_OPT_OUT_VERSION, currentSoapUIVersion.getMajorVersion()); <END> } return analyticsEnabled; }</code><technical_language>set this setting if StatisticsCollectionConfirmationDialog shown</technical_language>

Target:
private static boolean isAnalyticsEnabled() { Settings settings = SoapUI.getSettings(); boolean analyticsEnabled = settings.getBoolean(UISettings.DISABLE_ANALYTICS, false); if (analyticsEnabled) { return true; } Version optOutVersion = new Version(settings.getString(UISettings.ANALYTICS_OPT_OUT_VERSION, "0.0")); Version currentSoapUIVersion = new Version(SoapUI.SOAPUI_VERSION); if (!optOutVersion.getMajorVersion().equals(currentSoapUIVersion.getMajorVersion()) && SoapUI.usingGraphicalEnvironment()) { analyticsEnabled = StatisticsCollectionConfirmationDialog.showDialog() == JOptionPane.YES_OPTION; settings.setBoolean(UISettings.DISABLE_ANALYTICS, !analyticsEnabled); if (!analyticsEnabled) { settings.setString(UISettings.ANALYTICS_OPT_OUT_VERSION, currentSoapUIVersion.getMajorVersion()); } } return analyticsEnabled; }
Source:
<code>public void realm_closeInDoOnUnsubscribe() { Flowable<Realm> observable = realm.asFlowable() .doOnCancel(new Action() { @Override public void run() throws Exception { realm.close(); } }); subscription = observable.subscribe(new Consumer<Realm>() { @Override public void accept(Realm ignored) throws Exception { <START> assertEquals(2, Realm.getLocalInstanceCount(ignored.getConfiguration())); <END> } }); subscription.dispose(); assertTrue(realm.isClosed()); }</code><technical_language>anymore</technical_language>

Target:
public void realm_closeInDoOnUnsubscribe() { Flowable<Realm> observable = realm.asFlowable() .doOnCancel(new Action() { @Override public void run() throws Exception { realm.close(); } }); subscription = observable.subscribe(new Consumer<Realm>() { @Override public void accept(Realm realm) throws Exception { assertEquals(2, Realm.getLocalInstanceCount(realm.getConfiguration())); } }); subscription.dispose(); assertTrue(realm.isClosed()); }
Source:
<code>public Gateway3DSAuthorisationResponse authorise3dsResponse(Auth3dsResponseGatewayRequest request) { Either<GatewayError, GatewayClient.Response> response = client.postRequestFor(null, request.getGatewayAccount(), build3dsResponseAuthOrderFor(request)); <START> GatewayResponse<BaseAuthoriseResponse> gatewayResponse = GatewayResponseGenerator.getSmartpayGatewayResponse(client, response, SmartpayAuthorisationResponse.class); <END> if (gatewayResponse.getBaseResponse().isPresent()) { return new Gateway3DSAuthorisationResponse(gatewayResponse.getBaseResponse().get().authoriseStatus(), gatewayResponse.getBaseResponse().get().getTransactionId()); } return new Gateway3DSAuthorisationResponse(BaseAuthoriseResponse.AuthoriseStatus.EXCEPTION, null); }</code><technical_language>This block replaced functional style Java, example in Epdq</technical_language>

Target:
public Gateway3DSAuthorisationResponse authorise3dsResponse(Auth3dsResponseGatewayRequest request) { Either<GatewayError, GatewayClient.Response> response = client.postRequestFor(null, request.getGatewayAccount(), build3dsResponseAuthOrderFor(request)); GatewayResponse<BaseAuthoriseResponse> gatewayResponse = GatewayResponseGenerator.getSmartpayGatewayResponse(client, response, SmartpayAuthorisationResponse.class); return gatewayResponse.getBaseResponse().map( baseResponse -> Gateway3DSAuthorisationResponse.of(baseResponse.authoriseStatus(), baseResponse.getTransactionId())) .orElseGet(Gateway3DSAuthorisationResponse::ofException); }
Source:
<code>Type getPropertyType(String propertyName) throws MappingException; int[] findDirty(Object[] currentState, Object[] previousState, Object owner, SharedSessionContractImplementor session); int[] findModified(Object[] old, Object[] current, Object object, SharedSessionContractImplementor session); boolean hasIdentifierProperty(); boolean canExtractIdOutOfEntity(); boolean isVersioned(); VersionType getVersionType(); int getVersionProperty(); boolean hasNaturalIdentifier(); int[] getNaturalIdentifierProperties(); Object[] getNaturalIdentifierSnapshot(Serializable id, SharedSessionContractImplementor session); IdentifierGenerator getIdentifierGenerator(); boolean hasLazyProperties(); Serializable loadEntityIdByNaturalId( Object[] naturalIdValues, LockOptions lockOptions, SharedSessionContractImplementor session); Object load(Serializable id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session, Boolean readOnly) throws HibernateException; <START> default Object load(Serializable id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session) { <END> return load( id, optionalObject, lockMode, session, null ); }</code><technical_language>default implementation new signature in order remain compatibility custom persisters</technical_language>

Target:
Type getPropertyType(String propertyName) throws MappingException; int[] findDirty(Object[] currentState, Object[] previousState, Object owner, SharedSessionContractImplementor session); int[] findModified(Object[] old, Object[] current, Object object, SharedSessionContractImplementor session); boolean hasIdentifierProperty(); boolean canExtractIdOutOfEntity(); boolean isVersioned(); VersionType getVersionType(); int getVersionProperty(); boolean hasNaturalIdentifier(); int[] getNaturalIdentifierProperties(); Object[] getNaturalIdentifierSnapshot(Serializable id, SharedSessionContractImplementor session); IdentifierGenerator getIdentifierGenerator(); boolean hasLazyProperties(); Serializable loadEntityIdByNaturalId( Object[] naturalIdValues, LockOptions lockOptions, SharedSessionContractImplementor session); Object load(Serializable id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session) throws HibernateException; default Object load(Serializable id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session, Boolean readOnly) throws HibernateException { return load( id, optionalObject, lockMode, session ); }
Source:
<code>public Object execute(CommandContext commandContext) { EnsureUtil.ensureNotNull("licenseKey", LicenseKey); AuthorizationManager authorizationManager = commandContext.getAuthorizationManager(); authorizationManager.checkCamundaAdmin(); final ResourceManager resourceManager = commandContext.getResourceManager(); ResourceEntity key = resourceManager.findLicenseKeyResource(); if (key != null) { new DeleteLicenseKeyCmd(false).execute(commandContext); } key = new ResourceEntity(); key.setName(LICENSE_KEY_PROPERTY_NAME); <START> key.setBytes(LicenseKey.getBytes()); <END> resourceManager.insertResource(key); new SetPropertyCmd(LICENSE_KEY_BYTE_ARRAY_ID, key.getId()).execute(commandContext); new DeletePropertyCmd(LICENSE_KEY_PROPERTY_NAME).execute(commandContext); return null; }</code><technical_language>Do want platform's default charset store this in database? I suggest a fix encoding UTF-8? suggestion key.setBytes(licenseKey.getBytes(java.nio.charset.StandardCharsets.UTF_8));</technical_language>

Target:
public Object execute(CommandContext commandContext) { EnsureUtil.ensureNotNull("licenseKey", licenseKey); AuthorizationManager authorizationManager = commandContext.getAuthorizationManager(); authorizationManager.checkCamundaAdmin(); final ResourceManager resourceManager = commandContext.getResourceManager(); ResourceEntity key = resourceManager.findLicenseKeyResource(); if (key != null) { new DeleteLicenseKeyCmd(false).execute(commandContext); } key = new ResourceEntity(); key.setName(LICENSE_KEY_PROPERTY_NAME); key.setBytes(licenseKey.getBytes(StandardCharsets.UTF_8)); resourceManager.insertResource(key); new SetPropertyCmd(LICENSE_KEY_BYTE_ARRAY_ID, key.getId()).execute(commandContext); new DeletePropertyCmd(LICENSE_KEY_PROPERTY_NAME).execute(commandContext); return null; }
Source:
<code>public boolean visit(MethodDeclaration node) { if (isMethod(node, "android.widget.TextView", "onDraw", "android.graphics.Canvas")) { final ASTBuilder b = this.ctx.getASTBuilder(); <START> final Refactorings r = this.ctx.getRefactorings(); <END> node.accept(new OnDrawTransformer(this.ctx, node)); } return VISIT_SUBTREE; }</code><technical_language>Please remove unused b r</technical_language>

Target:
public boolean visit(MethodDeclaration node) { if (isMethod(node, "android.widget.TextView", "onDraw", "android.graphics.Canvas")) { node.accept(new OnDrawTransformer(this.ctx, node)); } return VISIT_SUBTREE; }
Source:
<code>public void marshallAsXml(final ModelNode model, final OutputStream output) throws ConfigurationPersistenceException { final XMLMapper mapper = XMLMapper.Factory.create(); try { XMLStreamWriter streamWriter = null; try { streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output); ModelMarshallingContext extensibleModel = new ModelMarshallingContext() { @Override public ModelNode getModelNode() { return model; } @Override <START> public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String extensionName) { <END> return subsystemWriters.computeIfAbsent(extensionName, name -> subsystemWriterSuppliers.getOrDefault(name, () -> null).get()); } }; mapper.deparseDocument(rootDeparser, extensibleModel, streamWriter); streamWriter.close(); subsystemWriters.clear(); } finally { safeClose(streamWriter); } } catch (Exception e) { throw ControllerLogger.ROOT_LOGGER.failedToWriteConfiguration(e); } }</code><technical_language>subsystemWriters a final local var in marshalAsXml. is need for instance field more need for clear() call. If instance var "clear" call a concurrency issue some day, e.g. concurrent CLI requests read-config-as-xml. final Map<String, XMLElementWriter<SubsystemMarshallingContext>> subsystemWriters = new HashMap<>(); ModelMarshallingContext extensibleModel = new ModelMarshallingContext() {</technical_language>

Target:
public void marshallAsXml(final ModelNode model, final OutputStream output) throws ConfigurationPersistenceException { final XMLMapper mapper = XMLMapper.Factory.create(); final Map<String, XMLElementWriter<SubsystemMarshallingContext>> subsystemWriters = new ConcurrentHashMap<>(); try { XMLStreamWriter streamWriter = null; try { streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output); final ModelMarshallingContext extensibleModel = new ModelMarshallingContext() { @Override public ModelNode getModelNode() { return model; } @Override public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String extensionName) { return subsystemWriters.computeIfAbsent(extensionName, name -> subsystemWriterSuppliers.getOrDefault(name, () -> null).get()); } }; mapper.deparseDocument(rootDeparser, extensibleModel, streamWriter); streamWriter.close(); } finally { safeClose(streamWriter); } } catch (Exception e) { throw ControllerLogger.ROOT_LOGGER.failedToWriteConfiguration(e); } }