auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void setup() { for (int i = 0; i < 16; i++) { <START> FloatStatus zero = ControlInterface.mainTuning.getFloat("current-zero", 0.0f); <END> FloatInput current = FloatMixing.createDispatch(Igneous.getPDPChannelCurrent(i), Igneous.globalPeriodic); Cluck.publish("Zero Current (channel " + i + ")", FloatMixing.pumpEvent(current, zero)); Cluck.publish("Current (channel " + i + ")", FloatMixing.subtraction.of(current, (FloatInput) zero)); } }</code><technical_language>single channel zero point</technical_language>

Target:
public static void setup() { for (int i = 0; i < 16; i++) { FloatStatus zero = ControlInterface.mainTuning.getFloat("current-zero-" + i, 0.0f); FloatInput current = FloatMixing.createDispatch(Igneous.getPDPChannelCurrent(i), Igneous.globalPeriodic); Cluck.publish("Zero Current " + i, FloatMixing.pumpEvent(current, zero)); Cluck.publish("Current " + i, FloatMixing.subtraction.of(current, (FloatInput) zero)); } }
Source:
<code>public String getId() { <START> return "org.eclipse.rse.remotecdt.dsf.debug.RemoteCDSFDebuggerTab"; END> }</code><technical_language>put in a new id for docker</technical_language>

Target:
public String getId() { return "org.eclipse.cdt.docker.launch.debug.RemoteCDSFDebuggerTab"; }
Source:
<code>private void cleanUpWorkspaceResources(final String deploymentName, final String namespace) throws IOException { Deployment deployment = KubernetesResourceUtil.getDeploymentByName(deploymentName, namespace); Service service = KubernetesResourceUtil.getServiceBySelector(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); List<Route> routes = KubernetesResourceUtil.getRoutesByLabel(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); List<ReplicaSet> replicaSets = KubernetesResourceUtil.getReplicaSetByLabel(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); try (OpenShiftClient openShiftClient = new DefaultOpenShiftClient()) { <START> if (replicaSets != null && replicaSets.size() > 0) { <END> LOG.info("Removing OpenShift ReplicaSets for deployment {}", deploymentName); replicaSets.forEach(rs -> openShiftClient.resource(rs).delete()); } if (deployment != null) { LOG.info("Removing OpenShift Deployment {}", deployment.getMetadata().getName()); openShiftClient.resource(deployment).delete(); } if (routes != null) { for (Route route: routes) { LOG.info("Removing OpenShift Route {}", route.getMetadata().getName()); openShiftClient.resource(route).delete(); } } if (service != null) { LOG.info("Removing OpenShift Service {}", service.getMetadata().getName()); openShiftClient.resource(service).delete(); } } }</code><technical_language>I worry order of removal here, replica sets controlled deployments. a problem deployment is scaled zero first, I deployment deleted replica set in case. IIRC cases a deployment ensure a replica set exists, causing recreated deployment is deleted</technical_language>

Target:
private void cleanUpWorkspaceResources(final String deploymentName, final String namespace) throws IOException { Deployment deployment = KubernetesResourceUtil.getDeploymentByName(deploymentName, namespace); Service service = KubernetesResourceUtil.getServiceBySelector(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); List<Route> routes = KubernetesResourceUtil.getRoutesByLabel(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); List<ReplicaSet> replicaSets = KubernetesResourceUtil.getReplicaSetByLabel(OpenShiftConnector.OPENSHIFT_DEPLOYMENT_LABEL, deploymentName, namespace); try (OpenShiftClient openShiftClient = new DefaultOpenShiftClient()) { if (deployment != null) { LOG.info("Removing OpenShift Deployment {}", deployment.getMetadata().getName()); openShiftClient.resource(deployment).delete(); } if (replicaSets != null && replicaSets.size() > 0) { LOG.info("Removing OpenShift ReplicaSets for deployment {}", deploymentName); replicaSets.forEach(rs -> openShiftClient.resource(rs).delete()); } if (routes != null) { for (Route route: routes) { LOG.info("Removing OpenShift Route {}", route.getMetadata().getName()); openShiftClient.resource(route).delete(); } } if (service != null) { LOG.info("Removing OpenShift Service {}", service.getMetadata().getName()); openShiftClient.resource(service).delete(); } } }
Source:
<code>private Indexer indexStream(InputStream stream) { try { Indexer indexer = new Indexer(); indexer.index(stream); return indexer; <START> } catch (IOException e) { <END> throw new IllegalStateException(e); } }</code><technical_language>This stream is closed</technical_language>

Target:
private Indexer indexStream(InputStream stream) { try { Indexer indexer = new Indexer(); indexer.index(stream); stream.close(); return indexer; } catch (IOException e) { throw new IllegalStateException(e); } }
Source:
<code>public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { boolean hasListeners = this.hasListeners; CacheEntryChange<K, V> ref = new CacheEntryChange<>(); for (Iterator<InternalCacheEntry<K, V>> it = dataContainer.iterator(); it.hasNext(); ) { InternalCacheEntry<K, V> ice = it.next(); getDataContainer().compute(ice.getKey(), (k, oldEntry, factory) -> { V oldValue = getValue(oldEntry); if (oldValue != null) { V newValue = function.apply(k, oldValue); Objects.requireNonNull(newValue, NULL_VALUES_NOT_SUPPORTED); if (hasListeners) { cacheNotifier.notifyCacheEntryModified(k, newValue, defaultMetadata, oldValue, oldEntry.getMetadata(), true, ImmutableContext.INSTANCE, null); } ref.set(k, newValue, oldValue, oldEntry.getMetadata()); return factory.update(oldEntry, newValue, defaultMetadata); } else { return null; } }); <START> V newValue = ref.getNewValue(); <END> if (hasListeners) { cacheNotifier.notifyCacheEntryModified(ref.getKey(), newValue, defaultMetadata, ref.getOldValue(), ref.getOldMetadata(), false, ImmutableContext.INSTANCE, null); } } }</code><technical_language>put this in if block</technical_language>

Target:
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { boolean hasListeners = this.hasListeners; CacheEntryChange<K, V> ref = new CacheEntryChange<>(); for (Iterator<InternalCacheEntry<K, V>> it = dataContainer.iterator(); it.hasNext(); ) { InternalCacheEntry<K, V> ice = it.next(); getDataContainer().compute(ice.getKey(), (k, oldEntry, factory) -> { V oldValue = getValue(oldEntry); if (oldValue != null) { V newValue = function.apply(k, oldValue); Objects.requireNonNull(newValue, NULL_VALUES_NOT_SUPPORTED); if (hasListeners) { cacheNotifier.notifyCacheEntryModified(k, newValue, defaultMetadata, oldValue, oldEntry.getMetadata(), true, ImmutableContext.INSTANCE, null); } ref.set(k, newValue, oldValue, oldEntry.getMetadata()); return factory.update(oldEntry, newValue, defaultMetadata); } else { return null; } }); if (hasListeners) { cacheNotifier.notifyCacheEntryModified(ref.getKey(), ref.getNewValue(), defaultMetadata, ref.getOldValue(), ref.getOldMetadata(), false, ImmutableContext.INSTANCE, null); } } }
Source:
<code><START> public void setAllowedQueryParamNames(final Set<String> allowedQueryParamNames) { <END> this.allowedQueryParamNames = allowedQueryParamNames; }</code><technical_language>'add'</technical_language>

Target:
public HttpLogOptions setAllowedQueryParamNames(final Set<String> allowedQueryParamNames) { this.allowedQueryParamNames = allowedQueryParamNames; return this; }
Source:
<code>public void onFeaturedImageSelected(@NonNull FeaturedImageCard card) { <START> PageTitle imageTitle = new PageTitle(card.filename(), card.site()); <END> GalleryActivity.showGallery(this, card.baseImage(), imageTitle, GalleryFunnel.SOURCE_FEED_FEATURED_IMAGE); }</code><technical_language>Is a title here? I PageTitle wants normalized title. I in this case card.filename() title internally a weird PageTitle dependency filenames if changes. For example, I imagine file://foo PageTitle interprets File page for //foo</technical_language>

Target:
public void onFeaturedImageSelected(@NonNull FeaturedImageCard card) { GalleryActivity.showGallery(this, card.baseImage(), card.filename(), card.site(), GalleryFunnel.SOURCE_FEED_FEATURED_IMAGE); }
Source:
<code>public Response getSentLogs(@QueryParam("queryId") final Long queryId, @DefaultValue("-1") @QueryParam("fragmentId") final long fragmentId, @Context final UriInfo uriInfo) throws DbException { if (queryId == null) { <START> throw new WebApplicationException(Response.status(HttpURLConnection.HTTP_BAD_REQUEST).entity("queryId missing") <END> .build()); } return getLogs(queryId, fragmentId, MyriaConstants.LOG_SENT_RELATION, MyriaConstants.LOG_SENT_SCHEMA); }</code><technical_language>MyriaApiException, is a wrapper intended simplify precisely this type of code</technical_language>

Target:
public Response getSentLogs(@QueryParam("queryId") final Long queryId, @DefaultValue("-1") @QueryParam("fragmentId") final long fragmentId, @Context final UriInfo uriInfo) throws DbException { if (queryId == null) { throw new MyriaApiException(Status.BAD_REQUEST, "Query ID missing."); } return getLogs(queryId, fragmentId, MyriaConstants.LOG_SENT_RELATION, MyriaConstants.LOG_SENT_SCHEMA); }
Source:
<code>private Registry<ConnectionSocketFactory> createConfiguredRegistry() { if (registry != null) { return registry; } final SSLConnectionSocketFactory sslConnectionSocketFactory; if (configuration.getTlsConfiguration() == null) { <START> if (verifier == null) { <END> sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); } else { sslConnectionSocketFactory = new DropwizardSSLConnectionSocketFactory(new TlsConfiguration(), verifier) .getSocketFactory(); } } else { sslConnectionSocketFactory = new DropwizardSSLConnectionSocketFactory(configuration.getTlsConfiguration(), verifier) .getSocketFactory(); } return RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslConnectionSocketFactory) .build(); }</code><technical_language>If I understand correctly, setting a HostnameVerifier means a TlsConfiguration. do extracting TlsConfiguration a local mutable variable? java TlsConfiguration tlsConfiguration = configuration.getTlsConfiguration(); if (tlsConfiguration == null && verifier != null) { tlsConfiguration = new TlsConfiguration(); } final SSLConnectionSocketFactory sslConnectionSocketFactory; if (tlsConfiguration == null) { sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); } else { sslConnectionSocketFactory = new DropwizardSSLConnectionSocketFactory(tlsConfiguration, verifier).getSocketFactory(); }</technical_language>

Target:
Registry<ConnectionSocketFactory> createConfiguredRegistry() { if (registry != null) { return registry; } TlsConfiguration tlsConfiguration = configuration.getTlsConfiguration(); if (tlsConfiguration == null && verifier != null) { tlsConfiguration = new TlsConfiguration(); } final SSLConnectionSocketFactory sslConnectionSocketFactory; if (tlsConfiguration == null) { sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); } else { sslConnectionSocketFactory = new DropwizardSSLConnectionSocketFactory(tlsConfiguration, verifier).getSocketFactory(); } return RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslConnectionSocketFactory) .build(); }
Source:
<code>public static Credentials freshCredentials(@NonNull Config config) { String randomUdid = UUID.randomUUID().toString(); String testEmail = ResourceUtil.getFormattedString( config.getEndToEndConfig().getEmailTemplate(), "unique_id", randomUdid).toString(); Credentials creds = new Credentials(testEmail, randomUdid); <START> creds.username = testEmail.split("@")[0]; <END> return creds; }</code><technical_language>This assignment done in constructor, in case username field defined final</technical_language>

Target:
public static Credentials freshCredentials(@NonNull Config config) { String randomUdid = UUID.randomUUID().toString(); String testEmail = ResourceUtil.getFormattedString( config.getEndToEndConfig().getEmailTemplate(), "unique_id", randomUdid).toString(); return new Credentials(testEmail, randomUdid); }
Source:
<code>getCache(VolumeChooserEnvironment env) { if (choiceCache == null) { String propertyValue = env.getServiceEnv().getConfiguration().getCustom(RECOMPUTE_INTERVAL); <START> long computationCacheDuration = !propertyValue.isBlank() ? Long.parseLong(propertyValue) <END> : defaultComputationCacheDuration; choiceCache = CacheBuilder.newBuilder() .expireAfterWrite(computationCacheDuration, TimeUnit.MILLISECONDS) .build(new CacheLoader<List<String>,WeightedRandomCollection>() { @Override public WeightedRandomCollection load(List<String> key) { return new WeightedRandomCollection(key, env, random); } }); } return choiceCache; }</code><technical_language>isBlank is another handles nulls</technical_language>

Target:
getCache(VolumeChooserEnvironment env) { if (choiceCache == null) { String propertyValue = env.getServiceEnv().getConfiguration().getCustom(RECOMPUTE_INTERVAL); long computationCacheDuration = StringUtils.isNotBlank(propertyValue) ? Long.parseLong(propertyValue) : defaultComputationCacheDuration; choiceCache = CacheBuilder.newBuilder() .expireAfterWrite(computationCacheDuration, TimeUnit.MILLISECONDS) .build(new CacheLoader<List<String>,WeightedRandomCollection>() { @Override public WeightedRandomCollection load(List<String> key) { return new WeightedRandomCollection(key, env, random); } }); } return choiceCache; }
Source:
<code>public boolean isPurposeFor(CallbackProperties properties) { NHIN_SERVICE_NAMES serviceName; boolean purposeFor = false; String action = properties.getAction(); try { serviceName = NHIN_SERVICE_NAMES.fromValueString(action); } catch (IllegalArgumentException ex) { LOG.warn("Could not read purpose of / for action: {}", ex.getLocalizedMessage()); LOG.trace("Could not read purpose of / for action: {}", ex.getLocalizedMessage(), ex); return purposeFor; } GATEWAY_API_LEVEL apiLevel = properties.getTargetApiLevel(); String hcid = properties.getTargetHomeCommunityId(); if (hcid.startsWith(NhincConstants.HCID_PREFIX)) { hcid = hcid.replace(NhincConstants.HCID_PREFIX, ""); } if (apiLevel == null && serviceName != null && hcid != null) { NhinEndpointManager nem = getNhinEndpointManager(); apiLevel = nem.getApiVersion(hcid, serviceName); } if (GATEWAY_API_LEVEL.LEVEL_g0 == apiLevel) { PurposeUseProxy purposeUse = getPurposeUseProxyObjectFactory(); purposeFor = purposeUse.isPurposeForUseEnabled(properties); } if (LOG.isDebugEnabled()) { <START> if (serviceName != null){ <END> logPurposeDecision(purposeFor, hcid, serviceName.getUDDIServiceName()); }else{ logPurposeDecision(purposeFor, hcid, null); } } return purposeFor; }</code><technical_language>this if else block re-written logPurposeDecision(purposeFor, hcid, serviceName.getUDDIServiceName()!=null? serviceName.getUDDIServiceName():null)</technical_language>

Target:
public boolean isPurposeFor(CallbackProperties properties) { NHIN_SERVICE_NAMES serviceName; boolean purposeFor = false; String action = properties.getAction(); try { serviceName = NHIN_SERVICE_NAMES.fromValueString(action); } catch (IllegalArgumentException ex) { LOG.warn("Could not read purpose of / for action: {}", ex.getLocalizedMessage()); LOG.trace("Could not read purpose of / for action: {}", ex.getLocalizedMessage(), ex); return purposeFor; } GATEWAY_API_LEVEL apiLevel = properties.getTargetApiLevel(); String hcid = properties.getTargetHomeCommunityId(); if (hcid.startsWith(NhincConstants.HCID_PREFIX)) { hcid = hcid.replace(NhincConstants.HCID_PREFIX, ""); } if (apiLevel == null && serviceName != null && hcid != null) { NhinEndpointManager nem = getNhinEndpointManager(); apiLevel = nem.getApiVersion(hcid, serviceName); } if (GATEWAY_API_LEVEL.LEVEL_g0 == apiLevel) { PurposeUseProxy purposeUse = getPurposeUseProxyObjectFactory(); purposeFor = purposeUse.isPurposeForUseEnabled(properties); } if (LOG.isDebugEnabled()) { logPurposeDecision(purposeFor, hcid, serviceName != null ? serviceName.getUDDIServiceName() : null); } return purposeFor; }
Source:
<code>public void createHttpCacheWithProxy() throws IOException { RemoteOptions options = Options.getDefaults(RemoteOptions.class); options.remoteHttpCache = "<LINK_1>"; options.remoteCacheProxy = "unix://some-proxy"; <START> options.diskCache = null; <END> SimpleBlobStore blobStore = SimpleBlobStoreFactory.create(options, null, workingDirectory); assertThat(blobStore).isNotNull(); assertThat(blobStore).isInstanceOf(HttpBlobStore.class); }</code><technical_language>this null default</technical_language>

Target:
public void createHttpCacheWithProxy() throws IOException { remoteOptions.remoteHttpCache = "<LINK_0>"; remoteOptions.remoteCacheProxy = "unix://some-proxy"; SimpleBlobStore blobStore = SimpleBlobStoreFactory.create(remoteOptions, null, workingDirectory); assertThat(blobStore).isInstanceOf(HttpBlobStore.class); }
Source:
<code>protected List<String> getPlugins() { try { final JsonObject jsonFile = getJsonFile( "plugins/webpack-plugins.json"); if (jsonFile == null) { <START> log().error("Couldn't locate webpack-plugins.json"); <END> return Collections.emptyList(); } final JsonArray plugins = jsonFile.getArray("plugins"); List<String> pluginsToInstall = new ArrayList<>(plugins.length()); for (int i = 0; i < plugins.length(); i++) { pluginsToInstall.add(plugins.getString(i)); } return pluginsToInstall; } catch (IOException ioe) { throw new UncheckedIOException( "Couldn't load webpack-plugins.json file", ioe); } }</code><technical_language>I this happen, expose impact "... Webpack plugins for Flow installed node_modules/@vaddin"</technical_language>

Target:
protected List<String> getPlugins() { try { final JsonObject jsonFile = getJsonFile( "plugins/webpack-plugins.json"); if (jsonFile == null) { log().error( "Couldn't locate plugins/webpack-plugins.json, no Webpack plugins for Flow will be installed." + "If webpack build fails validate flow-server jar content."); return Collections.emptyList(); } final JsonArray plugins = jsonFile.getArray("plugins"); List<String> pluginsToInstall = new ArrayList<>(plugins.length()); for (int i = 0; i < plugins.length(); i++) { pluginsToInstall.add(plugins.getString(i)); } return pluginsToInstall; } catch (IOException ioe) { throw new UncheckedIOException( "Couldn't load webpack-plugins.json file", ioe); } }
Source:
<code>public static String serialize(ColumnStatisticMetadata value) { return value.getStatisticType().name() + ":" + value.getColumnName(); <START> } <END></code><technical_language>"column name" refer to? plan IR references column names, column handles, instead</technical_language>

Target:
static String serialize(ColumnStatisticMetadata value) { return value.getStatisticType().name() + ":" + value.getColumnName(); }
Source:
<code>void clearLegacyEditingSetup() { if (!getControl().isDisposed() && getCellEditors() != null) { int count = doGetColumnCount(); for (int i = 0; i < count || i == 0; i++) { Widget owner = getColumnViewerOwner(i); if (owner != null && !owner.isDisposed()) { <START> ViewerColumn<E,I> column = (ViewerColumn<E,I>) owner <END> .getData(ViewerColumn.COLUMN_VIEWER_KEY); if (column != null) { EditingSupport e = column.getEditingSupport(); if (e != null && e.isLegacySupport()) { column.setEditingSupport(null); } } } } } }</code><technical_language>I get a warning cast Object</technical_language>

Target:
void clearLegacyEditingSetup() { if (!getControl().isDisposed() && getCellEditors() != null) { int count = doGetColumnCount(); for (int i = 0; i < count || i == 0; i++) { Widget owner = getColumnViewerOwner(i); if (owner != null && !owner.isDisposed()) { @SuppressWarnings("unchecked") ViewerColumn<E,I> column = (ViewerColumn<E,I>) owner .getData(ViewerColumn.COLUMN_VIEWER_KEY); if (column != null) { EditingSupport e = column.getEditingSupport(); if (e != null && e.isLegacySupport()) { column.setEditingSupport(null); } } } } } }
Source:
<code>protected void validateMandatoryFieldsNotSelected(final StringBuilder sb, final List<FieldToContractInputMapping> mappings, final IObservableSet checkedElements) { int numberOfElements = 0; for (final FieldToContractInputMapping mapping : mappings) { if (!checkedElements.contains(mapping) && !mapping.isGenerated() && !mapping.getField().isNullable()) { numberOfElements++; if (mapping.getParent() != null) { sb.append(mapping.getParent().getField().getName()); sb.append("."); } sb.append(mapping.getField().getName()); sb.append(", "); <START> <END> } else { if (checkedElements.contains(mapping) && mapping.isGenerated()) { validateMandatoryFieldsNotSelected(sb, mapping.getChildren(), checkedElements); } } } if (numberOfElements == 1) { sb.replace(sb.lastIndexOf(","), sb.lastIndexOf(",") + 1, ""); } }</code><technical_language>useless emtpy line</technical_language>

Target:
private void validateMandatoryFieldsNotSelected(final StringBuilder sb, final List<FieldToContractInputMapping> mappings, final IObservableSet checkedElements) { for (final FieldToContractInputMapping mapping : mappings) { if (!checkedElements.contains(mapping) && !mapping.isGenerated() && !mapping.getField().isNullable()) { if (mapping.getParent() != null) { sb.append(mapping.getParent().getField().getName()); sb.append("."); } sb.append(mapping.getField().getName()); sb.append(", "); } else { if (checkedElements.contains(mapping) && mapping.isGenerated()) { validateMandatoryFieldsNotSelected(sb, mapping.getChildren(), checkedElements); } } } }
Source:
<code>private long queryStreamTail() { Set<String> streamsToReplicate = logReplicationConfig.getStreamsToReplicate(); long maxTail = Address.NON_ADDRESS; for (String s : streamsToReplicate) { UUID currentUUID = CorfuRuntime.getStreamID(s); <START> Map<UUID, Long> tailMap = corfuRuntime.getAddressSpaceView().getAllTails().getStreamTails(); <END> Long currentTail = tailMap.get(currentUUID); if (currentTail != null) { maxTail = Math.max(maxTail, currentTail); } } return maxTail; }</code><technical_language>Query tailMap multiple times is efficient</technical_language>

Target:
private long queryStreamTail() { Set<String> streamsToReplicate = context.getConfig().getStreamsToReplicate(); long maxTail = Address.NON_ADDRESS; Map<UUID, Long> tailMap = corfuRuntime.getAddressSpaceView().getAllTails().getStreamTails(); for (String s : streamsToReplicate) { UUID currentUUID = CorfuRuntime.getStreamID(s); Long currentTail = tailMap.get(currentUUID); if (currentTail != null) { maxTail = Math.max(maxTail, currentTail); } } return maxTail; }
Source:
<code>protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); loginCurrentlyInProgress = savedInstanceState.getBoolean(LOGGING_IN, false); errorMessageShown = savedInstanceState.getBoolean(ERROR_MESSAGE_SHOWN, false); if (loginCurrentlyInProgress){ performLogin(); } if (errorMessageShown){ resultantError = savedInstanceState.getString(RESULTANT_ERROR); <START> handleOtherResults(Objects.requireNonNull(resultantError)); <END> } }</code><technical_language>this null</technical_language>

Target:
protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); loginCurrentlyInProgress = savedInstanceState.getBoolean(LOGGING_IN, false); errorMessageShown = savedInstanceState.getBoolean(ERROR_MESSAGE_SHOWN, false); if (loginCurrentlyInProgress) { performLogin(); } if (errorMessageShown) { resultantError = savedInstanceState.getString(RESULTANT_ERROR); handleOtherResults(resultantError); } }
Source:
<code>private void populateRequest(List<Artifact> artifacts, DataRightInput request) { if (request.isEmpty()) { List<Artifact> allArtifacts = new ArrayList<>(); if (recurseChildren || (renderer.getBooleanOption( RECURSE_ON_LOAD) && !renderer.getBooleanOption("Orig Publish As Diff"))) { for (Artifact art : artifacts) { <START> if (!art.artifactIsExcluded(excludeArtifactTypes, art)) { <END> allArtifacts.add(art); } if (!art.isHistorical()) { allArtifacts.addAll(art.getDescendants(excludeArtifactTypes)); } } } else { allArtifacts.addAll(artifacts); } int index = 0; String overrideClassification = (String) renderer.getOption(IRenderer.OVERRIDE_DATA_RIGHTS_OPTION); for (Artifact artifact : allArtifacts) { String classification = null; if (overrideClassification != null && ITemplateRenderer.DataRightsClassification.isValid( overrideClassification)) { classification = overrideClassification; } else { classification = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, ""); } PageOrientation orientation = WordRendererUtil.getPageOrientation(artifact); request.addData(artifact.getGuid(), classification, orientation, index); index++; } } }</code><technical_language>change if (!art.isOfType(excludeArtifactTypes)) {</technical_language>

Target:
private void populateRequest(List<Artifact> artifacts, DataRightInput request) { if (request.isEmpty()) { List<Artifact> allArtifacts = new ArrayList<>(); if (recurseChildren || (renderer.getBooleanOption( RECURSE_ON_LOAD) && !renderer.getBooleanOption("Orig Publish As Diff"))) { for (Artifact art : artifacts) { if (!art.isOfType(excludeArtifactTypes)) { allArtifacts.add(art); } if (!art.isHistorical()) { allArtifacts.addAll(art.getDescendants(excludeArtifactTypes)); } } } else { allArtifacts.addAll(artifacts); } int index = 0; String overrideClassification = (String) renderer.getOption(IRenderer.OVERRIDE_DATA_RIGHTS_OPTION); for (Artifact artifact : allArtifacts) { String classification = null; if (overrideClassification != null && ITemplateRenderer.DataRightsClassification.isValid( overrideClassification)) { classification = overrideClassification; } else { classification = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, ""); } PageOrientation orientation = WordRendererUtil.getPageOrientation(artifact); request.addData(artifact.getGuid(), classification, orientation, index); index++; } } }
Source:
<code>private LanguageMapping computeInheritedMapping(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException { LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true); LanguageMapping inheritedMapping = mappings[0]; int index = 1; while (inheritedMapping.inheritedFrom == LanguageMappingResolver.FILE_MAPPING) { <START> inheritedMapping = mappings[index++]; <END> } return inheritedMapping; }</code><technical_language>is index guard? cleaner if do standard for loop for (int i=0; i<mappinsg.length;i++) { if (mappings[i].inheritedFrom!=LanguageMappingResolver.FILE_MAPPING) return mappinsg[i]; } // do</technical_language>

Target:
private LanguageMapping computeInheritedMapping(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException { LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true); for (int i = 0; i < mappings.length; i++) { if (mappings[i].inheritedFrom != LanguageMappingResolver.FILE_MAPPING) { return mappings[i]; } } return null; }
Source:
<code>protected void closeTab() { <START> String frameId = getContent().getElement().getElementsByTagName( "iframe" ).getItem( 0 ).getAttribute( "id" ); <END> fireCloseTab( frameId ); tabPanel.closeTab( this, true ); }</code><technical_language>Please program in a more defensive way. (for some reason) iframe in tab? DOM is a shared resource (including badly written scripts written 3rd parties) modify freely. Check nodelist returned getElementsByTagName is empty. If access element in case, get error. If empty, try get ID fire event</technical_language>

Target:
protected void closeTab() { if ( getContent().getElement().getElementsByTagName( "iframe" ).getLength() > 0 ) { String frameId = getContent().getElement().getElementsByTagName( "iframe" ).getItem( 0 ).getAttribute( "id" ); fireCloseTab( frameId ); } tabPanel.closeTab( this, true ); }
Source:
<code>Collection<ResourceDMBean> getResourceDMBeansFromComponents() { Collection<ComponentRef<?>> components = basicComponentRegistry.getRegisteredComponents(); Collection<ResourceDMBean> resourceDMBeans = new LinkedHashSet<>(components.size()); for (ComponentRef<?> component : components) { if (!component.isAlias()) { Object instance = component.wired(); if (instance != null) { ResourceDMBean resourceDMBean = getResourceDMBean(instance, component.getName()); if (resourceDMBean != null) { boolean added = resourceDMBeans.add(resourceDMBean); if (!added) { <START> throw new IllegalStateException("Found duplicate: " + resourceDMBean); <END> } } } } } return resourceDMBeans; }</code><technical_language>this updated ComponentRef.isAlias() <LINK_0></technical_language>

Target:
private Collection<ResourceDMBean> getResourceDMBeansFromComponents() { Collection<ComponentRef<?>> components = basicComponentRegistry.getRegisteredComponents(); Collection<ResourceDMBean> resourceDMBeans = new ArrayList<>(components.size()); for (ComponentRef<?> component : components) { if (!component.isAlias()) { Object instance = component.wired(); if (instance != null) { ResourceDMBean resourceDMBean = getResourceDMBean(instance, component.getName()); if (resourceDMBean != null) { resourceDMBeans.add(resourceDMBean); } } } } return resourceDMBeans; }
Source:
<code>public void forceGroupSynchronization(PerunSession sess, Group group) throws GroupSynchronizationAlreadyRunningException, InternalErrorException { Utils.notNull(group, "group"); <START> if (groupSynchronizerThreads.values().contains(group.getId())) { <END> throw new GroupSynchronizationAlreadyRunningException(group); } else { putGroupToQueueToBeSynchronized(group, true); log.info("Scheduling synchronization for the group by force!", group); } }</code><technical_language>race condition</technical_language>

Target:
public void forceGroupSynchronization(PerunSession sess, Group group) throws GroupSynchronizationAlreadyRunningException, InternalErrorException { if(poolOfGroupsToBeSynchronized.putJobIfAbsent(group, true)) { log.info("Scheduling synchronization for the group by force!", group); } else { throw new GroupSynchronizationAlreadyRunningException(group); } }
Source:
<code>public List<String> getAsciidoctorOption(String optionKey) { Configuration subConfig = compositeConfiguration.subset(JBakeProperty.ASCIIDOCTOR_OPTION); if (subConfig.containsKey(optionKey)) { return subConfig.getList(String.class, optionKey); } else { logger.warn("Cannot find asciidoctor option '{}.{}'", JBakeProperty.ASCIIDOCTOR_OPTION, optionKey); <START> return new ArrayList<>(); <END> } }</code><technical_language>this Collections.emptyList() return immutable list</technical_language>

Target:
public List<String> getAsciidoctorOption(String optionKey) { Configuration subConfig = compositeConfiguration.subset(JBakeProperty.ASCIIDOCTOR_OPTION); if (subConfig.containsKey(optionKey)) { return subConfig.getList(String.class, optionKey); } else { logger.warn("Cannot find asciidoctor option '{}.{}'", JBakeProperty.ASCIIDOCTOR_OPTION, optionKey); return Collections.emptyList(); } }
Source:
<code>public static String format(String value, int version) { Media media; int savedVersion; try { media = JSON_OBJECT_MAPPER.readValue(value, Media.class); savedVersion = VERSION_GEOTAGGING; <START> } catch(IOException e) { <END> media = new Media(); media.setFilename(value); savedVersion = VERSION_INITIAL; } if (version == savedVersion) { return value; } if (version == VERSION_GEOTAGGING) { try { return JSON_OBJECT_MAPPER.writeValueAsString(media); } catch(IOException e) { log.warning(e.getMessage()); return ""; } } return media.getFilename(); }</code><technical_language>idea distinguish more precisely whats exception is a filename string possibly a malformed JSON string</technical_language>

Target:
public static String format(String value, int version) { Media media; int savedVersion; try { media = JSON_OBJECT_MAPPER.readValue(value, Media.class); savedVersion = VERSION_GEOTAGGING; } catch(IOException e) { media = new Media(); media.setFilename(value); savedVersion = VERSION_STRING; } if (version == savedVersion) { return value; } if (version == VERSION_GEOTAGGING) { try { return JSON_OBJECT_MAPPER.writeValueAsString(media); } catch(IOException e) { log.warning(e.getMessage()); return ""; } } return media.getFilename(); }
Source:
<code>public void run() { InitializerWizard wizard = new InitializerWizard(this.editingDomain.getResourceSet(), selection); WizardDialog dialog = new WizardDialog(null, wizard); dialog.create(); if (dialog.open() == Window.OK) <START> this.result = wizard.getCommand(); <END> }</code><technical_language>Please, add { } if statement. if (dialog.open() == Window.OK) { ICommand cmd = wizard.getCommand(); //command execution ? } Modifiy inheritance of action add command execution</technical_language>

Target:
public void run() { InitializerWizard wizard = new InitializerWizard(this.editingDomain.getResourceSet(), selection); WizardDialog dialog = new WizardDialog(null, wizard); dialog.create(); if (dialog.open() == Window.OK) { this.result = wizard.getCommand(); result.execute(); } }
Source:
<code>private void calculateAndUpdateBaseline(ClusterModel clusterModel, RebalanceAlgorithm algorithm, boolean shouldSchedulePartialRebalance, String clusterName) throws HelixRebalanceException { LOG.info("Start calculating the new baseline."); _baselineCalcCounter.increment(1L); _baselineCalcLatency.startMeasuringLatency(); boolean isBaselineChanged = false; Map<String, ResourceAssignment> newBaseline = calculateAssignment(clusterModel, algorithm); if (_assignmentMetadataStore != null) { try { _writeLatency.startMeasuringLatency(); isBaselineChanged = _assignmentMetadataStore.persistBaseline(newBaseline); _writeLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException("Failed to persist the new baseline assignment.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } else { LOG.debug("Assignment Metadata Store is null. Skip persisting the baseline assignment."); } _baselineCalcLatency.endMeasuringLatency(); LOG.info("Global baseline calculation completed and has been persisted into metadata store."); if (isBaselineChanged && shouldSchedulePartialRebalance) { <START> LOG.info("Schedule a new rebalance after the new baseline calculated."); <END> RebalanceUtil.scheduleOnDemandPipeline(clusterName, 0L, false); } }</code><technical_language>Nit: "after new baseline calculated." -> "after new baseline calculation finished"</technical_language>

Target:
private void calculateAndUpdateBaseline(ClusterModel clusterModel, RebalanceAlgorithm algorithm, boolean shouldSchedulePartialRebalance, String clusterName) throws HelixRebalanceException { LOG.info("Start calculating the new baseline."); _baselineCalcCounter.increment(1L); _baselineCalcLatency.startMeasuringLatency(); boolean isBaselineChanged = false; Map<String, ResourceAssignment> newBaseline = calculateAssignment(clusterModel, algorithm); if (_assignmentMetadataStore != null) { try { _writeLatency.startMeasuringLatency(); isBaselineChanged = _assignmentMetadataStore.persistBaseline(newBaseline); _writeLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException("Failed to persist the new baseline assignment.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } else { LOG.debug("Assignment Metadata Store is null. Skip persisting the baseline assignment."); } _baselineCalcLatency.endMeasuringLatency(); LOG.info("Global baseline calculation completed and has been persisted into metadata store."); if (isBaselineChanged && shouldSchedulePartialRebalance) { LOG.info("Schedule a new rebalance after the new baseline calculation has finished."); RebalanceUtil.scheduleOnDemandPipeline(clusterName, 0L, false); } }
Source:
<code>private JSONObject processJSONResponse(SocketChannel sc, String remoteAddress, Set<String> activeVersions, boolean checkVersion) throws IOException, JSONException { JSONObject jsonResponse = readJSONObjFromWire(sc, remoteAddress); <START> if (checkVersion) { <END> VersionChecker versionChecker = m_acceptor.getVersionChecker(); String remoteVersionString = jsonResponse.getString(VERSION_STRING); String remoteBuildString = jsonResponse.getString(BUILD_STRING); boolean remoteAcceptsLocalVersion = jsonResponse.getBoolean(VERSION_COMPATIBLE); if (remoteVersionString.equals(versionChecker.getVersionString())) { if (!versionChecker.getBuildString().equals(remoteBuildString)) { if (!versionChecker.getBuildString().equals("VoltDB") && !remoteBuildString.equals("VoltDB")) { org.voltdb.VoltDB.crashLocalVoltDB("For VoltDB version " + versionChecker.getVersionString() + " git tag/hash is not identical across the cluster. Node join failed.\n" + " joining build string: " + versionChecker.getBuildString() + "\n" + " existing build string: " + remoteBuildString, false, null); return null; } } } else if (!remoteAcceptsLocalVersion) { if (!versionChecker.isCompatibleVersionString(remoteVersionString)) { org.voltdb.VoltDB.crashLocalVoltDB("Cluster contains nodes running VoltDB version " + remoteVersionString + " which is incompatibile with local version " + versionChecker.getVersionString() + ".\n", false, null); return null; } } activeVersions.add(remoteVersionString); } return jsonResponse; }</code><technical_language>This is place early return helps you. need introduce indentation, diffs clear</technical_language>

Target:
private JSONObject processJSONResponse(SocketChannel sc, String remoteAddress, Set<String> activeVersions, boolean checkVersion) throws IOException, JSONException { JSONObject jsonResponse = readJSONObjFromWire(sc, remoteAddress); if (!checkVersion) { return jsonResponse; } VersionChecker versionChecker = m_acceptor.getVersionChecker(); String remoteVersionString = jsonResponse.getString(VERSION_STRING); String remoteBuildString = jsonResponse.getString(BUILD_STRING); boolean remoteAcceptsLocalVersion = jsonResponse.getBoolean(VERSION_COMPATIBLE); if (remoteVersionString.equals(versionChecker.getVersionString())) { if (!versionChecker.getBuildString().equals(remoteBuildString)) { if (!versionChecker.getBuildString().equals("VoltDB") && !remoteBuildString.equals("VoltDB")) { org.voltdb.VoltDB.crashLocalVoltDB("For VoltDB version " + versionChecker.getVersionString() + " git tag/hash is not identical across the cluster. Node join failed.\n" + " joining build string: " + versionChecker.getBuildString() + "\n" + " existing build string: " + remoteBuildString, false, null); return null; } } } else if (!remoteAcceptsLocalVersion) { if (!versionChecker.isCompatibleVersionString(remoteVersionString)) { org.voltdb.VoltDB.crashLocalVoltDB("Cluster contains nodes running VoltDB version " + remoteVersionString + " which is incompatibile with local version " + versionChecker.getVersionString() + ".\n", false, null); return null; } } activeVersions.add(remoteVersionString); return jsonResponse; }
Source:
<code>public MysqlSchemaStore(MaxwellContext context, Position initialPosition) throws SQLException { this( context, context.getServerID(), initialPosition, context.getFilter(), <START> context.getReplayMode() <END> ); }</code><technical_language>need re-tab. tab correct</technical_language>

Target:
public MysqlSchemaStore(MaxwellContext context, Position initialPosition) throws SQLException { this( context.getMaxwellConnectionPool(), context.getReplicationConnectionPool(), context.getSchemaConnectionPool(), context.getServerID(), initialPosition, context.getCaseSensitivity(), context.getFilter(), context.getConfig().schemaChainMaxLength, context.getReplayMode() ); }
Source:
<code>public void banExecServiceOnFacility(PerunSession sess, ExecService execService, Facility facility) throws InternalErrorException { execServiceDenialDao.banExecServiceOnFacility(execService.getId(), facility.getId()); <START> sess.getPerun().getAuditer().logWithoutTransaction(sess, BAN_EXECSERVICE + "{} on ", execService, facility); <END> }</code><technical_language>I recommend BAN_SERVICE another variable pass Auditer.log. consider reformat messages more in perun-core. java log("{} {}", execService, BAN_EXECSERVICE, facility); more think. reason logWithoutTransaction instead of log</technical_language>

Target:
public void banExecServiceOnFacility(PerunSession sess, ExecService execService, Facility facility) throws InternalErrorException { execServiceDenialDao.banExecServiceOnFacility(execService.getId(), facility.getId()); sess.getPerun().getAuditer().log(sess, "{} on {}", BAN_SERVICE, execService, facility); }
Source:
<code>public static Map<IPluginModelBase, String> getTargetBundleMap(ILaunchConfiguration configuration, Set<String> set, String attribute) throws CoreException { <START> List<String> selected = configuration.getAttribute(attribute, new ArrayList<>()); <END> Map<IPluginModelBase, String> map = new LinkedHashMap<>(); for (String token : selected) { int index = token.indexOf('@'); if (index < 0) { token = token.concat("@default:default"); index = token.indexOf('@'); } String idVersion = token.substring(0, index); int versionIndex = idVersion.indexOf(VERSION_SEPARATOR); String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion; String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null; if (set != null && set.contains(id)) continue; ModelEntry entry = PluginRegistry.findEntry(id); if (entry != null) { IPluginModelBase[] models = entry.getExternalModels(); for (IPluginModelBase model : models) { if (model.isEnabled()) { IPluginBase base = model.getPluginBase(); if (base.getVersion().equals(version) || version == null || models.length == 1) addBundleToMap(map, model, token.substring(index + 1)); } } } } return map; }</code><technical_language>Set</technical_language>

Target:
public static Map<IPluginModelBase, String> getTargetBundleMap(ILaunchConfiguration configuration, Set<String> set, String attribute) throws CoreException { Set<String> selected = configuration.getAttribute(attribute, Collections.emptySet()); Map<IPluginModelBase, String> map = new LinkedHashMap<>(); for (String token : selected) { int index = token.indexOf('@'); if (index < 0) { token = token.concat("@default:default"); index = token.indexOf('@'); } String idVersion = token.substring(0, index); int versionIndex = idVersion.indexOf(VERSION_SEPARATOR); String id = (versionIndex > 0) ? idVersion.substring(0, versionIndex) : idVersion; String version = (versionIndex > 0) ? idVersion.substring(versionIndex + 1) : null; if (set != null && set.contains(id)) continue; ModelEntry entry = PluginRegistry.findEntry(id); if (entry != null) { IPluginModelBase[] models = entry.getExternalModels(); for (IPluginModelBase model : models) { if (model.isEnabled()) { IPluginBase base = model.getPluginBase(); if (base.getVersion().equals(version) || version == null || models.length == 1) addBundleToMap(map, model, token.substring(index + 1)); } } } } return map; }
Source:
<code>public boolean send(CarbonMessage msg, CarbonCallback callback) throws ClientConnectorException { if (msg instanceof TextCarbonMessage) { TextCarbonMessage textCarbonMessage = (TextCarbonMessage) msg; sendText(textCarbonMessage); } else if (msg instanceof ControlCarbonMessage) { ControlCarbonMessage controlCarbonMessage = (ControlCarbonMessage) msg; handleControlMessage(controlCarbonMessage); } else if (msg instanceof BinaryCarbonMessage) { BinaryCarbonMessage binaryCarbonMessage = (BinaryCarbonMessage) msg; sendBinary(binaryCarbonMessage); } <START> return true; <END> }</code><technical_language>elaborate purpose boolean returned this method? occasion this return false</technical_language>

Target:
public boolean send(CarbonMessage msg, CarbonCallback callback) throws ClientConnectorException { throw new ClientConnectorException("Method not supported for WebSocket. Use session to send messages."); }
Source:
<code>private int deltaSizeLimit(DeltaWindowEntry src) { if (bestBase == null) { int n = res.size() >>> 1; return n - (n * src.depth() / maxDepth); } int d = bestBase.depth(); int n = (int) bestDelta.length(); <START> return n * (maxDepth - src.depth()) / (maxDepth - d); <END> }</code><technical_language>FYI, i confirmed this equation is correct</technical_language>

Target:
private int deltaSizeLimit(DeltaWindowEntry src) { if (bestBase == null) { int n = res.size() >>> 1; return n * (maxDepth - src.depth()) / maxDepth; } int d = bestBase.depth(); int n = (int) bestDelta.length(); return n * (maxDepth - src.depth()) / (maxDepth - d); }
Source:
<code>protected void addSeriesMeta(String key, boolean value) { <START> addSeriesMeta(key, new Boolean(value)); <END> }</code><technical_language>valueOf</technical_language>

Target:
protected void addSeriesMeta(String key, boolean value) { addSeriesMeta(key, Boolean.valueOf(value)); }
Source:
<code>public static boolean testRepositoryState(Repository repository, String property) { if ("isShared".equals(property)) return repository != null; if (repository != null) { RepositoryState state = repository.getRepositoryState(); if (property.length() > 3 && property.startsWith("is")) { String lookFor = property.substring(2,3) + property.substring(3).replaceAll("([A-Z])","_$1").toUpperCase(); if (state.toString().equals(lookFor)) return true; } try { <START> Method method = RepositoryState.class.getMethod(property, (Class[])null); <END> if (method.getReturnType() == boolean.class) { Boolean ret = (Boolean) method.invoke(state, (Object[])null); return ret.booleanValue(); } } catch (Exception e) { } } return false; }</code><technical_language>simply leave out varargs arguments instead of casting null ? class.getMethod(property)</technical_language>

Target:
public static boolean testRepositoryState(Repository repository, String property) { if ("isShared".equals(property)) return repository != null; if (repository != null) { RepositoryState state = repository.getRepositoryState(); if (property.length() > 3 && property.startsWith("is")) { String lookFor = property.substring(2,3) + property.substring(3).replaceAll("([A-Z])","_$1").toUpperCase(); if (state.toString().equals(lookFor)) return true; } try { Method method = RepositoryState.class.getMethod(property); if (method.getReturnType() == boolean.class) { Boolean ret = (Boolean) method.invoke(state); return ret.booleanValue(); } } catch (Exception e) { } } return false; }
Source:
<code>public void setUp() { assumeTrue(CameraUtil.deviceHasCamera()); <START> assumeTrue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M); <END> Context context = ApplicationProvider.getApplicationContext(); AppConfig appConfig = Camera2AppConfig.create(context); CameraX.init(context, appConfig); mLifecycleOwner = new FakeLifecycleOwner(); mLifecycleOwner.startAndResume(); mImageCaptureConfigBuilder = new ImageCaptureConfig.Builder(); mPreviewConfigBuilder = new PreviewConfig.Builder(); mCameraStatusCallback = new CameraDevice.StateCallback() { @Override public void onOpened(@NonNull CameraDevice camera) { mLatch = new CountDownLatch(1); } @Override public void onDisconnected(@NonNull CameraDevice camera) { } @Override public void onError(@NonNull CameraDevice camera, int error) { } @Override public void onClosed(@NonNull CameraDevice camera) { mLatch.countDown(); } }; new Camera2Config.Extender(mImageCaptureConfigBuilder).setDeviceStateCallback( mCameraStatusCallback); }</code><technical_language>@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) top of ExtensionTest</technical_language>

Target:
public void setUp() { assumeTrue(CameraUtil.deviceHasCamera()); Context context = ApplicationProvider.getApplicationContext(); AppConfig appConfig = Camera2AppConfig.create(context); CameraX.init(context, appConfig); mLifecycleOwner = new FakeLifecycleOwner(); mLifecycleOwner.startAndResume(); mImageCaptureConfigBuilder = new ImageCaptureConfig.Builder(); mPreviewConfigBuilder = new PreviewConfig.Builder(); mCameraStatusCallback = new CameraDevice.StateCallback() { @Override public void onOpened(@NonNull CameraDevice camera) { mLatch = new CountDownLatch(1); } @Override public void onDisconnected(@NonNull CameraDevice camera) { } @Override public void onError(@NonNull CameraDevice camera, int error) { } @Override public void onClosed(@NonNull CameraDevice camera) { mLatch.countDown(); } }; new Camera2Config.Extender(mImageCaptureConfigBuilder).setDeviceStateCallback( mCameraStatusCallback); }