auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { if(!context.isBooting() && context.getProcessType() == ProcessType.EMBEDDED_SERVER && context.getRunningMode() == RunningMode.ADMIN_ONLY) { context.reloadRequired(); <START> context.completeStep(new OperationContext.RollbackHandler() { <END> @Override public void handleRollback(OperationContext context, ModelNode operation) { context.revertReloadRequired(); } }); } else { context.addStep(ServiceInstallStepHandler.INSTANCE, OperationContext.Stage.RUNTIME); } }</code><technical_language>add a rollback handler, override rollbackRuntime, is called RollbackHandler added superclass</technical_language>

Target:
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { if(!context.isBooting() && context.getProcessType() == ProcessType.EMBEDDED_SERVER && context.getRunningMode() == RunningMode.ADMIN_ONLY) { context.reloadRequired(); } else { context.addStep(ServiceInstallStepHandler.INSTANCE, OperationContext.Stage.RUNTIME); } }
Source:
<code>public LockableResourcesStruct(RequiredResourcesProperty property, EnvVars env) { required = new ArrayList<>(); LockableResourcesManager resourcesManager = LockableResourcesManager.get(); List<LockableResource> declaredResources = resourcesManager.getDeclaredResources(); for (String name : property.getResources()) { String resourceName = env.expand(name); if (resourceName == null) { continue; } <START> if (resourceName.contains("$")) { <END> boolean isDeclared = false; for (LockableResource r : declaredResources) { if (r.getName().equals(resourceName)) { isDeclared = true; break; } } if (!isDeclared) { continue; } } resourcesManager.createResource(resourceName); LockableResource r = resourcesManager.fromName(resourceName); this.required.add(r); } label = env.expand(property.getLabelName()); if (label == null) label = ""; resourceMatchScript = property.getResourceMatchScript(); serializableResourceMatchScript = new SerializableSecureGroovyScript(resourceMatchScript); requiredVar = property.getResourceNamesVar(); requiredNumber = property.getResourceNumber(); if (requiredNumber != null && requiredNumber.equals("0")) requiredNumber = null; }</code><technical_language>Scenario: - declared resource: resource-1 - job configuration: - lock: resource-$id - build parameter: id triggering job id=1, resource resource-1 effectively locked released execution finishes. ephemeral resource named resource-$id created queued current build, LockableResourcesQueueTaskDispatcher tests is build run (LockableResourcesQueueTaskDispatcher.java:108). expansion of variable id occurs this point, EnvVars object is empty. ephemeral resource is eventually removed queue a minute so. solution I proposed is skip creating ephemeral resources for names dollar symbol $ previously declared (i.e. Jenkins configuration manager)</technical_language>

Target:
public LockableResourcesStruct(RequiredResourcesProperty property, EnvVars env) { required = new ArrayList<>(); LockableResourcesManager resourcesManager = LockableResourcesManager.get(); for (String name : property.getResources()) { String resourceName = env.expand(name); if (resourceName == null) { continue; } resourcesManager.createResource(resourceName); LockableResource r = resourcesManager.fromName(resourceName); this.required.add(r); } label = env.expand(property.getLabelName()); if (label == null) label = ""; resourceMatchScript = property.getResourceMatchScript(); serializableResourceMatchScript = new SerializableSecureGroovyScript(resourceMatchScript); requiredVar = property.getResourceNamesVar(); requiredNumber = property.getResourceNumber(); if (requiredNumber != null && requiredNumber.equals("0")) requiredNumber = null; }
Source:
<code>private void saveItemsToPreference(List<Item> items) { StringBuilder sb = new StringBuilder(); items.stream().forEach(i->sb.append(i.toPreferenceValue())); <START> getPreferenceStore().setValue(ALLOWED_SERTIFICATES, sb.toString()); <END> }</code><technical_language>this survive a workspace restart. prompted allow certificates I restart eclipse</technical_language>

Target:
private void saveItemsToPreference(List<Item> items) { StringBuilder sb = new StringBuilder(); items.stream().forEach(i->sb.append(i.toPreferenceValue())); getPreferenceStore().setValue(ALLOWED_CERTIFICATES, sb.toString()); }
Source:
<code>public String getType(Uri uri) { int match = sUriMatcher.match(uri); switch (match) { case NOTES_V2: case NOTES: return FlashCardsContract.Note.CONTENT_TYPE; case NOTES_ID: return FlashCardsContract.Note.CONTENT_ITEM_TYPE; case NOTES_ID_CARDS: return FlashCardsContract.Card.CONTENT_TYPE; case NOTES_ID_CARDS_ORD: return FlashCardsContract.Card.CONTENT_ITEM_TYPE; case MODELS: return FlashCardsContract.Model.CONTENT_TYPE; case MODELS_ID: return FlashCardsContract.Model.CONTENT_ITEM_TYPE; case MODELS_ID_EMPTY_CARDS: <START> return FlashCardsContract.Model.CONTENT_TYPE; <END> case MODELS_ID_TEMPLATES: return FlashCardsContract.CardTemplate.CONTENT_TYPE; case MODELS_ID_TEMPLATES_ID: return FlashCardsContract.CardTemplate.CONTENT_ITEM_TYPE; case SCHEDULE: return FlashCardsContract.ReviewInfo.CONTENT_TYPE; case DECKS: return FlashCardsContract.Deck.CONTENT_TYPE; case DECKS_ID: return FlashCardsContract.Deck.CONTENT_TYPE; case DECK_SELECTED: return FlashCardsContract.Deck.CONTENT_TYPE; default: throw new IllegalArgumentException("uri " + uri + " is not supported"); } }</code><technical_language>This FlashCardsContract.Card.CONTENT_ITEM_TYPE I guess</technical_language>

Target:
public String getType(Uri uri) { int match = sUriMatcher.match(uri); switch (match) { case NOTES_V2: case NOTES: return FlashCardsContract.Note.CONTENT_TYPE; case NOTES_ID: return FlashCardsContract.Note.CONTENT_ITEM_TYPE; case NOTES_ID_CARDS: return FlashCardsContract.Card.CONTENT_TYPE; case NOTES_ID_CARDS_ORD: return FlashCardsContract.Card.CONTENT_ITEM_TYPE; case MODELS: return FlashCardsContract.Model.CONTENT_TYPE; case MODELS_ID: return FlashCardsContract.Model.CONTENT_ITEM_TYPE; case MODELS_ID_EMPTY_CARDS: return FlashCardsContract.Card.CONTENT_TYPE; case MODELS_ID_TEMPLATES: return FlashCardsContract.CardTemplate.CONTENT_TYPE; case MODELS_ID_TEMPLATES_ID: return FlashCardsContract.CardTemplate.CONTENT_ITEM_TYPE; case SCHEDULE: return FlashCardsContract.ReviewInfo.CONTENT_TYPE; case DECKS: return FlashCardsContract.Deck.CONTENT_TYPE; case DECKS_ID: return FlashCardsContract.Deck.CONTENT_TYPE; case DECK_SELECTED: return FlashCardsContract.Deck.CONTENT_TYPE; default: throw new IllegalArgumentException("uri " + uri + " is not supported"); } }
Source:
<code><START> public Document getDocument() { <END> return rs.getQuery().getDatabase().getDocument(documentID); }</code><technical_language>in spec</technical_language>

Target:
Document getDocument() { return rs.getQuery().getDatabase().getDocument(documentID); }
Source:
<code>public static MultiTableSweepQueueWriter createWriter(TargetedSweepMetrics metrics, KeyValueService kvs, Supplier<Integer> shardsConfig) { <START> return create(metrics, kvs, shardsConfig, new TargetedSweepFollower(ImmutableList.of(), null)); <END> }</code><technical_language>This is safe (because TM in follower invoked if a cleanup task is invoked, none), nice if this clearer</technical_language>

Target:
public static MultiTableSweepQueueWriter createWriter(TargetedSweepMetrics metrics, KeyValueService kvs, Supplier<Integer> shardsConfig) { return SweepQueueFactory.create(metrics, kvs, shardsConfig).createWriter(); }
Source:
<code>private Exception copyFromFeatureSource(ImportData data, ImportTask task, DataStoreFormat format, DataStore dataStoreDestination, Transaction transaction, String featureTypeName, String uniquifiedFeatureTypeName, FeatureDataConverter featureDataConverter, VectorTransformChain tx) throws IOException { Exception error = null; ProgressMonitor monitor = task.progress(); try { long startTime = System.currentTimeMillis(); task.clearMessages(); task.setTotalToProcess(format.getFeatureCount(task.getData(), task)); LOGGER.fine("begining import - highlevel api"); FeatureSource fs = format.getFeatureSource(data, task); FeatureCollection fc = fs.getFeatures(); FeatureStore featureStore = (FeatureStore) dataStoreDestination .getFeatureSource(uniquifiedFeatureTypeName); featureStore.setTransaction(transaction); fc = new ImportTransformFeatureCollection(fc, featureDataConverter, featureStore.getSchema(), tx, task, dataStoreDestination); featureStore.addFeatures(fc); <START> } catch (Exception e) { <END> error = e; } if (error != null || monitor.isCanceled()) { try { transaction.rollback(); } catch (Exception e1) { LOGGER.log(Level.WARNING,"Unable to load data into "+ uniquifiedFeatureTypeName+", rolling back data insert:"+e1, e1); } try { dropSchema(dataStoreDestination, featureTypeName); } catch (Exception e1) { LOGGER.log(Level.WARNING, "Error dropping schema in rollback", e1); } } return error; }</code><technical_language>want catch Throwable - a try/finally block ensure transaction is committed rolled back. is transaction closed call chain</technical_language>

Target:
private Throwable copyFromFeatureSource(ImportData data, ImportTask task, DataStoreFormat format, DataStore dataStoreDestination, Transaction transaction, String featureTypeName, String uniquifiedFeatureTypeName, FeatureDataConverter featureDataConverter, VectorTransformChain tx) throws IOException { Throwable error = null; ProgressMonitor monitor = task.progress(); try { long startTime = System.currentTimeMillis(); task.clearMessages(); task.setTotalToProcess(format.getFeatureCount(task.getData(), task)); LOGGER.fine("begining import - highlevel api"); FeatureSource fs = format.getFeatureSource(data, task); FeatureCollection fc = fs.getFeatures(); FeatureStore featureStore = (FeatureStore) dataStoreDestination .getFeatureSource(uniquifiedFeatureTypeName); featureStore.setTransaction(transaction); fc = new ImportTransformFeatureCollection(fc, featureDataConverter, featureStore.getSchema(), tx, task, dataStoreDestination); featureStore.addFeatures(fc); } catch (Throwable e) { error = e; } if (error != null || monitor.isCanceled()) { try { transaction.rollback(); } catch (Exception e1) { LOGGER.log(Level.WARNING,"Unable to load data into "+ uniquifiedFeatureTypeName+", rolling back data insert:"+e1, e1); } try { dropSchema(dataStoreDestination, featureTypeName); } catch (Exception e1) { LOGGER.log(Level.WARNING, "Error dropping schema in rollback", e1); } } return error; }
Source:
<code>@Override public void onSuccess(Void value) { <START> complete(new byte[0] ); <END> }</code><technical_language>static final byte[] EMPTY = new byte[0]</technical_language>

Target:
@Override public void onSuccess(Void value) { complete(EMPTY); }
Source:
<code>public void addMethods(HaxeMethodBuilder... methodBuilders) { String out = ""; for (HaxeMethodBuilder builder : methodBuilders) { <START> out += "public " + builder.toString() + "\n"; <END> } this.getDocument().addTextAfterElement(getBodyPsi(), out); }</code><technical_language>add public? match accessibility of underlying methods? And, if this is interface, "public" is redundant</technical_language>

Target:
public void addMethods(HaxeMethodBuilder... methodBuilders) { String out = ""; for (HaxeMethodBuilder builder : methodBuilders) { out += builder.modifiers.toStringCombined() + " " + builder.toString() + "\n"; } this.getDocument().addTextAfterElement(getBodyPsi(), out); }
Source:
<code>public void badgeCountShouldNotIncludeOldNotifications() { NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, getBaseNotifBundle(), null); <START> advanceSystemTimeBy(604_801 * 1_000L); <END> SQLiteDatabase readableDb = OneSignalDbHelper.getInstance(blankActivity).getReadableDatabase(); OneSignalPackagePrivateHelper.BadgeCountUpdater.update(readableDb, blankActivity); assertEquals(0, ShadowBadgeCountUpdater.lastCount); }</code><technical_language>Lets include units here. call advanceSystemTimeByMs</technical_language>

Target:
public void badgeCountShouldNotIncludeOldNotifications() { NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, getBaseNotifBundle(), null); advanceSystemTimeBy(604_801); SQLiteDatabase readableDb = OneSignalDbHelper.getInstance(blankActivity).getReadableDatabase(); OneSignalPackagePrivateHelper.BadgeCountUpdater.update(readableDb, blankActivity); assertEquals(0, ShadowBadgeCountUpdater.lastCount); }
Source:
<code>public ParentBuildAction() { final Executor currentExecutor = Executor.currentExecutor(); if (currentExecutor != null) { <START> parent = (MatrixBuild) currentExecutor.getCurrentExecutable(); <END> } number = parent == null ? null : parent.getNumber(); }</code><technical_language>Unchecked cast in code</technical_language>

Target:
public ParentBuildAction() { final Executor currentExecutor = Executor.currentExecutor(); if (currentExecutor != null) { Queue.Executable executable = currentExecutor.getCurrentExecutable(); if (executable instanceof MatrixBuild) { parent = (MatrixBuild) executable; } } number = parent == null ? null : parent.getNumber(); }
Source:
<code>private void loadRoutingTable() { Map<String, List<String>> newRoutingTable = new ConcurrentHashMap<>(); Config config = gondola.getConfig(); for(String hostId : config.getHostIds()) { if (hostId.equals(gondola.getHostId())) { continue; } for(String clusterId : config.getClusterIds(hostId)) { InetSocketAddress address = config.getAddressForHost(hostId); List<String> addresses = newRoutingTable.get(clusterId); if (addresses == null) { addresses = new ArrayList<>(); newRoutingTable.put(clusterId, addresses); } Map<String, String> attrs = config.getAttributesForHost(hostId); if (attrs.get(APP_PORT) == null || attrs.get(APP_SCHEME) == null) { <START> throw new RuntimeException( <END> String.format("Attribute '%s|%s' is required in gondola configuration. (gondola.hosts[].%s|%s)", APP_PORT, APP_SCHEME, APP_PORT, APP_SCHEME)); } String appUri = String.format("%s://%s:%s", attrs.get(APP_SCHEME), address.getHostName(), attrs.get(APP_PORT)); addresses.add(appUri); } } routingTable = newRoutingTable; }</code><technical_language>illegalstateexception is better</technical_language>

Target:
private void loadRoutingTable() { Map<String, List<String>> newRoutingTable = new ConcurrentHashMap<>(); Config config = gondola.getConfig(); for(String hostId : config.getHostIds()) { if (hostId.equals(gondola.getHostId())) { continue; } for(String clusterId : config.getClusterIds(hostId)) { InetSocketAddress address = config.getAddressForHost(hostId); List<String> addresses = newRoutingTable.get(clusterId); if (addresses == null) { addresses = new ArrayList<>(); newRoutingTable.put(clusterId, addresses); } Map<String, String> attrs = config.getAttributesForHost(hostId); if (attrs.get(APP_PORT) == null || attrs.get(APP_SCHEME) == null) { throw new IllegalStateException( String.format("gondola.hosts[%s] is missing either the %s or %s config values", hostId, APP_PORT, APP_SCHEME)); } String appUri = String.format("%s://%s:%s", attrs.get(APP_SCHEME), address.getHostName(), attrs.get(APP_PORT)); addresses.add(appUri); } } routingTable = newRoutingTable; }
Source:
<code>public void run() { RedisQueueMessageDrivenEndpoint.this.listening = true; try { while (RedisQueueMessageDrivenEndpoint.this.active) { RedisQueueMessageDrivenEndpoint.this.popMessageAndSend(); } } catch (RedisSystemException e) { if (RedisQueueMessageDrivenEndpoint.this.active) { RedisQueueMessageDrivenEndpoint.this.listening = false; <START> RedisQueueMessageDrivenEndpoint.this.sleepBeforeRecoveryAttempt(); <END> throw e; } else { logger.error(e); } } finally { if (RedisQueueMessageDrivenEndpoint.this.active) { RedisQueueMessageDrivenEndpoint.this.restart(); } else { RedisQueueMessageDrivenEndpoint.this.listening = false; } } }</code><technical_language>Instead of sleeping, IOS TaskScheduler - MQTT adapter in extensions. (Remember cancel ScheduledFuture if null)</technical_language>

Target:
public void run() { RedisQueueMessageDrivenEndpoint.this.listening = true; try { while (RedisQueueMessageDrivenEndpoint.this.active) { RedisQueueMessageDrivenEndpoint.this.popMessageAndSend(); } } finally { if (RedisQueueMessageDrivenEndpoint.this.active) { RedisQueueMessageDrivenEndpoint.this.restart(); } else { RedisQueueMessageDrivenEndpoint.this.listening = false; } } }
Source:
<code>protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { if (!containsUserCredentials(request)) { <START> throw new AuthenticationException("Credentials Required"); <END> } else { request.getSession(true).setAttribute(SSOUtils.USER_CREDENTIALS, getUserCredentials(request)); response.sendRedirect(request.getContextPath() + SSOUtils.LOGIN_PHASE2_URI + request.getQueryString()); } } catch (AuthenticationException ex) { response.setHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\""); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } }</code><technical_language>skip exception, no? set header error here</technical_language>

Target:
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Credentials credentials = getUserCredentials(request); if (credentials == null) { response.setHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\""); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } else { request.getSession(true).setAttribute(SSOUtils.USER_CREDENTIALS, credentials); response.sendRedirect(request.getContextPath() + SSOUtils.LOGIN_PHASE2_URI); } }
Source:
<code>private void refreshCommitedMemory() { Integer memCommited = _vds.getGuestOverhead(); int vmsCoresCount = 0; for (VM vm : _vmDict.values()) { if <START> (!VMStatus.WaitForLaunch.equals(vm.getStatus())) <END> { memCommited += vm.getVmMemSizeMb(); memCommited += _vds.getGuestOverhead(); vmsCoresCount += vm.getNumOfCpus(); } } if (memCommited == null || !memCommited.equals(_vds.getMemCommited())) { _vds.setMemCommited(memCommited); _saveVdsDynamic = true; } if (_vds.getVmsCoresCount() == null || !_vds.getVmsCoresCount().equals(vmsCoresCount)) { _vds.setVmsCoresCount(vmsCoresCount); _saveVdsDynamic = true; } }</code><technical_language>more standard compare !=</technical_language>

Target:
private void refreshCommitedMemory() { Integer memCommited = _vds.getGuestOverhead(); int vmsCoresCount = 0; for (VM vm : _vmDict.values()) { if (vm.getStatus() != VMStatus.WaitForLaunch) { memCommited += vm.getVmMemSizeMb(); memCommited += _vds.getGuestOverhead(); vmsCoresCount += vm.getNumOfCpus(); } } if (memCommited == null || !memCommited.equals(_vds.getMemCommited())) { _vds.setMemCommited(memCommited); _saveVdsDynamic = true; } if (_vds.getVmsCoresCount() == null || !_vds.getVmsCoresCount().equals(vmsCoresCount)) { _vds.setVmsCoresCount(vmsCoresCount); _saveVdsDynamic = true; } }
Source:
<code>public void testGetConcern() { if(default_stakeholder.getConcern().size()!=2){ <START> fail(); <END> } if(!(default_stakeholder.getConcern().get(0).equals(THIS_IS_THE_BODY_OF_COMMENT1))){ fail(); } if(!(default_stakeholder.getConcern().get(1).equals(THIS_IS_THE_BODY_OF_COMMENT2))){ fail(); } }</code><technical_language>Add a message failing</technical_language>

Target:
public void testGetConcern() { if(default_stakeholder.getConcern().size()!=2){ fail(MESSAGE_ERROR); } if(!THIS_IS_THE_BODY_OF_COMMENT1.equals((default_stakeholder.getConcern().get(0)))){ fail(MESSAGE_ERROR); } if(!THIS_IS_THE_BODY_OF_COMMENT2.equals((default_stakeholder.getConcern().get(1)))){ fail(MESSAGE_ERROR); } }
Source:
<code>@NonNull @Override public GraphCall<T> enqueue(@NonNull final Callback<T> callback) { synchronized (this) { <START> if (executed) throw new IllegalStateException("Already Executed"); <END> executed = true; } httpCall = httpCall(); httpCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(final Call call, final IOException e) { callback.onFailure(e); } @Override public void onResponse(final Call call, final Response response) throws IOException { try { TopLevelResponse topLevelResponse = parse(response); callback.onResponse(responseConverter.convert(topLevelResponse)); } catch (Exception e) { callback.onFailure(e); } } }); return this; }</code><technical_language>do want throw exception drop it</technical_language>

Target:
@NonNull @Override public GraphCall<T> enqueue(@NonNull final Callback<T> callback) { synchronized (this) { if (executed) throw new IllegalStateException("Already Executed"); executed = true; } httpCall = httpCall(); httpCall.enqueue(new okhttp3.Callback() { @Override public void onFailure(final Call call, final IOException e) { callback.onFailure(GraphError.networkError(null, e)); } @Override public void onResponse(final Call call, final Response response) throws IOException { try { checkResponse(response); callback.onResponse(parseResponse(response)); } catch (GraphError error) { callback.onFailure(error); } } }); return this; }
Source:
<code>public RequestLogger get() { LoggingRequestLogger logger = new LoggingRequestLogger(mapper, setMDC, setContextMDC); <START> log.info(new Exception("Stack trace"), "Creating %s at", logger); <END> return logger; }</code><technical_language>debug level</technical_language>

Target:
public RequestLogger get() { LoggingRequestLogger logger = new LoggingRequestLogger(mapper, setMDC, setContextMDC); log.debug(new Exception("Stack trace"), "Creating %s at", logger); return logger; }
Source:
<code>public Properties getHibernateProperties() { Properties properties = super.getHibernateProperties(); properties.setProperty( "hibernate.search.default.directory_provider", "filesystem" ); <START> properties.setProperty( "hibernate.search.default.indexBase", "target/filesystem-default" ); <END> return properties; }</code><technical_language>work test is run IDE? is a test helper TestConstants#getTargetDir target dir. If I understoof correctly tests running in container, work then!</technical_language>

Target:
public Properties getHibernateProperties() { Properties properties = super.getHibernateProperties(); properties.setProperty( "hibernate.search.default.directory_provider", "filesystem" ); properties.setProperty( "hibernate.search.default.indexBase", TestConstants.getIndexDirectory( FileSystemDefaultTestScenario.class ) ); return properties; }
Source:
<code>private String encode() { <START> String value = username + ":" + timestamp + ":" + path; <END> String mac = KEY.mac(value); return mac + Util.toHexString((value.getBytes(StandardCharsets.UTF_8))); }</code><technical_language>This give values for null "" for username marked @Nullable</technical_language>

Target:
private String encode() { String value = username + ":" + timestamp.toEpochMilli() + ":" + path; byte[] valueBytes = value.getBytes(StandardCharsets.UTF_8); byte[] byteValue = ArrayUtils.addAll(KEY.mac(valueBytes), valueBytes); return Base64.getUrlEncoder().encodeToString(byteValue); }
Source:
<code>public Map<Map.Entry<K, V>, Map.Entry<K, V>> apply(Set<Map.Entry<K, V>> request) { CacheDescriptor cacheDescriptor = offHeapCache.cacheDescriptor.get(); if (cacheDescriptor.currentSize().get() >= offHeapCache.maxSize.getAsLong()) { offHeapCache.taggedMetricRegistry.counter(CACHE_NUKE).inc(); offHeapCache.clear(); } cacheDescriptor = offHeapCache.cacheDescriptor.get(); try { Map<K, V> response = offHeapCache.persistentStore.get( cacheDescriptor.storeNamespace(), request.stream().map(Map.Entry::getKey).collect(Collectors.toList())); int sizeIncrease = Sets.difference(request, response.entrySet()).size(); offHeapCache.persistentStore.put( cacheDescriptor.storeNamespace(), ImmutableMap.copyOf(request)); cacheDescriptor.currentSize().addAndGet(sizeIncrease); } catch (SafeIllegalArgumentException exception) { log.warn("Clear called concurrently, writing failed", exception); } finally { <START> offHeapCache.inFlightRequests.clear(); <END> } return KeyedStream.of(request.stream()).collectToMap(); }</code><technical_language>is this correct? if a request in for key K, autobatcher is in here, in next batch. If clear, another request for key in (still in batch, returned) in flight request anymore. if matter, in flight request map matter autobatcher do right (you're coalescing one). if matter, gonna fix this</technical_language>

Target:
public Map<Map.Entry<K, V>, Void> apply(Set<Map.Entry<K, V>> request) { CacheDescriptor cacheDescriptor = offHeapCache.cacheDescriptor.get(); if (cacheDescriptor.currentSize().get() >= offHeapCache.maxSize.getAsLong()) { offHeapCache.cacheNuke.inc(); offHeapCache.clear(); } cacheDescriptor = offHeapCache.cacheDescriptor.get(); try { List<K> toWrite = request.stream().map(Map.Entry::getKey).collect(Collectors.toList()); Map<K, V> response = offHeapCache.persistentStore.get(cacheDescriptor.storeHandle(), toWrite); int sizeIncrease = Sets.difference(request, response.entrySet()).size(); offHeapCache.persistentStore.put(cacheDescriptor.storeHandle(), ImmutableMap.copyOf(request)); cacheDescriptor.currentSize().addAndGet(sizeIncrease); } catch (SafeIllegalArgumentException exception) { log.warn("Clear called concurrently, writing failed", exception); } return KeyedStream.of(request).map(value -> (Void) null).collectToMap(); }
Source:
<code>public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) { <START> if(!BiomeHelper.isBiomeHellish(world.getBiome(pos))) <END> { return 5; } return 0; }</code><technical_language>test if hive is in nether, nether hive is binnie forestry</technical_language>

Target:
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) { return 5; }
Source:
<code>public void updatePreferenceIntents(PreferenceGroup prefs, final String acccountType, Account account) { final PackageManager pm = mFragment.getActivity().getPackageManager(); for (int i = 0; i < prefs.getPreferenceCount(); ) { Preference pref = prefs.getPreference(i); if (pref instanceof PreferenceGroup) { updatePreferenceIntents((PreferenceGroup) pref, acccountType, account); } Intent intent = pref.getIntent(); if (intent != null) { <START> if (android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS.equals( <END> intent.getAction())) { pref.setOnPreferenceClickListener(new FragmentStarter( LocationSettings.class.getName(), R.string.location_settings_title)); } else { ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier()); if (ri == null) { prefs.removePreference(pref); continue; } intent.putExtra(ACCOUNT_KEY, account); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); pref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent prefIntent = preference.getIntent(); if (isSafeIntent(pm, prefIntent, acccountType)) { mFragment.getActivity().startActivityAsUser( prefIntent, mUserHandle); } else { Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent); } return true; } }); } } i++; } }</code><technical_language>TextUtils.equals() instead</technical_language>

Target:
public void updatePreferenceIntents(PreferenceGroup prefs, final String acccountType, Account account) { final PackageManager pm = mFragment.getActivity().getPackageManager(); for (int i = 0; i < prefs.getPreferenceCount(); ) { Preference pref = prefs.getPreference(i); if (pref instanceof PreferenceGroup) { updatePreferenceIntents((PreferenceGroup) pref, acccountType, account); } Intent intent = pref.getIntent(); if (intent != null) { if (TextUtils.equals(intent.getAction(), android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)) { pref.setOnPreferenceClickListener(new FragmentStarter( LocationSettings.class.getName(), R.string.location_settings_title)); } else { ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier()); if (ri == null) { prefs.removePreference(pref); continue; } intent.putExtra(ACCOUNT_KEY, account); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); pref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent prefIntent = preference.getIntent(); if (isSafeIntent(pm, prefIntent, acccountType)) { mFragment.getActivity().startActivityAsUser( prefIntent, mUserHandle); } else { Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent); } return true; } }); } } i++; } }
Source:
<code>public EventHubAsyncProducer createProducer(EventHubProducerOptions options) { Objects.requireNonNull(options); final EventHubProducerOptions clonedOptions = options.clone(); if (clonedOptions.retry() == null) { clonedOptions.retry(connectionOptions.retry()); } final String entityPath; final String linkName; if (ImplUtils.isNullOrEmpty(options.partitionId())) { entityPath = eventHubName; linkName = StringUtil.getRandomString("EC"); } else { entityPath = String.format(Locale.US, SENDER_ENTITY_PATH_FORMAT, eventHubName, options.partitionId()); linkName = StringUtil.getRandomString("PS"); } final Mono<AmqpSendLink> amqpLinkMono = connectionMono .flatMap(connection -> connection.createSession(entityPath)) .flatMap(session -> { logger.verbose("Creating producer for {}", entityPath); final RetryPolicy retryPolicy = RetryUtil.getRetryPolicy(clonedOptions.retry()); return session.createProducer(linkName, entityPath, clonedOptions.retry().tryTimeout(), retryPolicy) .cast(AmqpSendLink.class); }); <START> return new EventHubAsyncProducer(amqpLinkMono, clonedOptions, this.tracerProvider); <END> }</code><technical_language>need this</technical_language>

Target:
public EventHubAsyncProducer createProducer(EventHubProducerOptions options) { Objects.requireNonNull(options, "'options' cannot be null."); final EventHubProducerOptions clonedOptions = options.clone(); if (clonedOptions.retry() == null) { clonedOptions.retry(connectionOptions.retry()); } final String entityPath; final String linkName; if (ImplUtils.isNullOrEmpty(options.partitionId())) { entityPath = eventHubName; linkName = StringUtil.getRandomString("EC"); } else { entityPath = String.format(Locale.US, SENDER_ENTITY_PATH_FORMAT, eventHubName, options.partitionId()); linkName = StringUtil.getRandomString("PS"); } final Mono<AmqpSendLink> amqpLinkMono = connectionMono .flatMap(connection -> connection.createSession(entityPath)) .flatMap(session -> { logger.verbose("Creating producer for {}", entityPath); final RetryPolicy retryPolicy = RetryUtil.getRetryPolicy(clonedOptions.retry()); return session.createProducer(linkName, entityPath, clonedOptions.retry().tryTimeout(), retryPolicy) .cast(AmqpSendLink.class); }); return new EventHubAsyncProducer(amqpLinkMono, clonedOptions, tracerProvider); }
Source:
<code>public void testTuples() { Pair<String, Integer> pair = new Pair<>("A", 1); Triplet<String, Integer, Long> triplet = new Triplet<>("B", 2, Long.MAX_VALUE); Quartet<String, Integer, Long, Character> quartet = new Quartet<>("C", 3, Long.MIN_VALUE, 'c'); Quintet<String, Integer, Long, Character, BigInteger> quintet = new Quintet<>("D", 4, Long.valueOf("0"), 'd', BigInteger.ZERO); <START> assertEquals(pair.getA()+" should be A","A", pair.getA()); <END> assertEquals(triplet.getA()+" should be B" ,"B", triplet.getA()); assertEquals(quartet.getA()+" should be C","C", quartet.getA()); assertEquals(quintet.getA()+" should be D","D", quintet.getA()); assertEquals(pair.getB() +" should be 1",1, pair.getB().intValue()); assertEquals(triplet.getB() +" should be 2",2, triplet.getB().intValue()); assertEquals(quartet.getB() +" should be 3",3, quartet.getB().intValue()); assertEquals(quintet.getB() +" should be 4",4, quintet.getB().intValue()); assertEquals(triplet.getC() +" should be Long.MAX_VALUE",Long.MAX_VALUE, triplet.getC().longValue()); assertEquals(quartet.getC() +" should be Long.MIN_VALUE",Long.MIN_VALUE, quartet.getC().longValue()); assertEquals(quintet.getC() +" should be 0L",0L, quintet.getC().longValue()); assertEquals(quartet.getD() +" should be c",'c', quartet.getD().charValue()); assertEquals(quintet.getD() +" should be d",'d', quintet.getD().charValue()); assertEquals(quintet.getE()+" should be "+BigInteger.ZERO,BigInteger.ZERO, quintet.getE()); }</code><technical_language>This assertEquals("pair.getA() A", "A", pair.getA()); similar for others</technical_language>

Target:
public void testTuples() { Pair<String, Integer> pair = new Pair<>("A", 1); Triplet<String, Integer, Long> triplet = new Triplet<>("B", 2, Long.MAX_VALUE); Quartet<String, Integer, Long, Character> quartet = new Quartet<>("C", 3, Long.MIN_VALUE, 'c'); Quintet<String, Integer, Long, Character, BigInteger> quintet = new Quintet<>("D", 4, Long.valueOf("0"), 'd', BigInteger.ZERO); assertEquals("pair.getA() should be A", "A", pair.getA()); assertEquals("triplet.getA() should be B", "B", triplet.getA()); assertEquals("quartet.getA() should be C", "C", quartet.getA()); assertEquals("quintet.getA() should be D", "D", quintet.getA()); assertEquals("pair.getB().intValue() should be 1", 1, pair.getB().intValue()); assertEquals("triplet.getB().intValue() should be 2", 2, triplet.getB().intValue()); assertEquals("quartet.getB().intValue() should be 3", 3, quartet.getB().intValue()); assertEquals("quintet.getB().intValue() should be 4", 4, quintet.getB().intValue()); assertEquals("triplet.getC().longValue() should be Long.MAX_VALUE", Long.MAX_VALUE, triplet.getC().longValue()); assertEquals("quartet.getC().longValue() should be Long.MIN_VALUE", Long.MIN_VALUE, quartet.getC().longValue()); assertEquals("quintet.getC().longValue() should be 0L", 0L, quintet.getC().longValue()); assertEquals("quartet.getD().charValue() should be c", 'c', quartet.getD().charValue()); assertEquals("quintet.getD().charValue() should be d", 'd', quintet.getD().charValue()); assertEquals("quintet.getE() should be BigInteger.ZERO", BigInteger.ZERO, quintet.getE()); }
Source:
<code>public boolean process(Exchange exchange, AsyncCallback callback) { ExecutorService executorService = this.executor; if (executorService != null && this.isRunAllowed()) { executorService.execute(() -> this.getAsyncProcessor().process(exchange, doneSync -> { <START> if (exchange.getException() != null) { <END> LOG.warn("Error processing the exchange " + exchange + " from reactive-streams", exchange.getException()); } callback.done(doneSync); })); return false; } else { LOG.warn("Consumer not ready to process exchanges. The exchange will be discarded", exchange); callback.done(true); return true; } }</code><technical_language>want do WARN logs, Camels error handler deal this. If Camel error handler handle exception consumer error handler tend a fallback log a WARN: <LINK_0></technical_language>

Target:
public boolean process(Exchange exchange, AsyncCallback callback) { ExecutorService executorService = this.executor; if (executorService != null && this.isRunAllowed()) { executorService.execute(() -> this.getAsyncProcessor().process(exchange, doneSync -> { if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } callback.done(doneSync); })); return false; } else { LOG.warn("Consumer not ready to process exchanges. The exchange will be discarded", exchange); callback.done(true); return true; } }
Source:
<code>private synchronized void removeSubscription(String address) throws Exception { String internalAddress = MQTTUtil.convertMQTTAddressFilterToCore(address, session.getWildcardConfiguration()); SimpleString internalQueueName = getQueueNameForTopic(internalAddress); session.getSessionState().removeSubscription(address); Set<Consumer> queueConsumers = session.getServer().queueConsumersQuery(internalQueueName); consumers.remove(address); if (queueConsumers != null) { for (Consumer consumer : queueConsumers) { ((ServerConsumer) consumer).close(false); consumerQoSLevels.remove(((ServerConsumer) consumer).getID()); } <START> } <END> if (session.getServerSession().executeQueueQuery(internalQueueName).isExists()) { session.getServerSession().deleteQueue(internalQueueName); } }</code><technical_language>I this is wrong. check for consumers this Session. logic is closing consumer address. multiple connections a failure</technical_language>

Target:
private void removeSubscription(String address) throws Exception { String internalAddress = MQTTUtil.convertMQTTAddressFilterToCore(address, session.getWildcardConfiguration()); SimpleString internalQueueName = getQueueNameForTopic(internalAddress); session.getSessionState().removeSubscription(address); SimpleString sAddress = SimpleString.toSimpleString(internalAddress); AddressInfo addressInfo = session.getServerSession().getAddress(sAddress); if (addressInfo != null && addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST)) { ServerConsumer consumer = consumers.get(address); consumers.remove(address); if (consumer != null) { consumer.close(false); consumerQoSLevels.remove(consumer.getID()); } } else { consumers.remove(address); Queue queue = session.getServer().locateQueue(internalQueueName); Set<Consumer> queueConsumers; if (queue != null && (queueConsumers = (Set<Consumer>) queue.getConsumers()) != null) { for (Consumer consumer : queueConsumers) { ((ServerConsumer) consumer).close(false); consumerQoSLevels.remove(((ServerConsumer) consumer).getID()); } } } if (session.getServerSession().executeQueueQuery(internalQueueName).isExists()) { session.getServerSession().deleteQueue(internalQueueName); } }
Source:
<code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String fileName = request.getParameter("filename"); String contentType = request.getParameter("contenttype"); String content = request.getParameter("content"); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.setHeader("Cache-Control", "no-cache, must-revalidate"); <START> response.setHeader("Expires", "Sat, 26 Jul 1997 05:00:00 GMT"); END> response.getWriter().println(content); }</code><technical_language>I add cache=true/false a parameter</technical_language>

Target:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String fileName = request.getParameter("filename"); String contentType = request.getParameter("contenttype"); String content = request.getParameter("content"); Boolean cache = Boolean.parseBoolean(request.getParameter("cache")); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); if (!cache) { response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Expires", "Sat, 26 Jul 1997 05:00:00 GMT"); } response.getWriter().println(content); if (response.getWriter().checkError()) { throw new IOException("Error when writing to response stream"); } }
Source:
<code><START> private boolean isNotNormalizableDateValue(String property, String value) { <END> if (property == null || value == null) { LOGGER.trace("Property or value was null, ignoring normalization", property, value); return true; } Optional<AttributeDescriptor> optional = registry.lookup(property); if (!optional.isPresent()) { LOGGER.trace("No descriptor available for property [{}]", property); return true; } AttributeDescriptor descriptor = optional.get(); if (!AttributeType.AttributeFormat.DATE.equals(descriptor.getType().getAttributeFormat())) { LOGGER.trace( "Descriptor for property and value did not have an AttributeFormat of DATE", property, value); return true; } LOGGER.trace("Found date value for property [{}]", value, property); return false; }</code><technical_language>FYI, a robust date parser included in EndpointUtil of variability encountered in <LINK_0></technical_language>

Target:
private boolean isNotNormalizableDateValue(String property, String value) { Optional<AttributeDescriptor> optional = registry.lookup(property); if (!optional.isPresent()) { LOGGER.trace("No descriptor available for property [{}]", property); return true; } AttributeDescriptor descriptor = optional.get(); if (descriptor.getType().getAttributeFormat() != DATE) { LOGGER.trace( "Descriptor for property and value did not have an AttributeFormat of DATE", property, value); return true; } LOGGER.trace("Found date value for property [{}]", value, property); return false; }
Source:
<code><START> public <T> Optional<T> get(String id, Class<T> clazz, IndexCoordinates index) { <END> GetRequest request = requestFactory.getRequest(id, index); try { GetResponse response = client.get(request, RequestOptions.DEFAULT); return Optional.ofNullable(elasticsearchConverter.mapDocument(DocumentAdapters.from(response), clazz)); } catch (IOException e) { throw new ElasticsearchException("Error while getting for request: " + request.toString(), e); } }</code><technical_language>stick T instead of Optional<T>. A huge number of folks asked roll Optional change findById Optional loved much</technical_language>

Target:
public <T> T get(String id, Class<T> clazz, IndexCoordinates index) { GetRequest request = requestFactory.getRequest(id, index); try { GetResponse response = client.get(request, RequestOptions.DEFAULT); return elasticsearchConverter.mapDocument(DocumentAdapters.from(response), clazz); } catch (IOException e) { throw new ElasticsearchException("Error while getting for request: " + request.toString(), e); } }
Source:
<code>public Bitmap get() throws IOException { long started = System.nanoTime(); checkNotMain(); if (deferred) { throw new IllegalStateException("Fit cannot be used with get."); } if (!data.hasImage()) { return null; } Request request = createRequest(started); Action action = new GetAction(picasso, request); Result.Bitmap result = BitmapHunter.Companion.forRequest(picasso, picasso.dispatcher, picasso.cache, action).hunt(); if (result == null) { return null; <START> } <END> Bitmap bitmap = result.getBitmap(); if (shouldWriteToMemoryCache(request.memoryPolicy)) { picasso.cache.set(request.key, bitmap); } return bitmap; }</code><technical_language>revert; hunt() return non-nullable Bitmap</technical_language>

Target:
public Bitmap get() throws IOException { long started = System.nanoTime(); checkNotMain(); if (deferred) { throw new IllegalStateException("Fit cannot be used with get."); } if (!data.hasImage()) { return null; } Request request = createRequest(started); Action action = new GetAction(picasso, request); Result.Bitmap result = forRequest(picasso, picasso.dispatcher, picasso.cache, action).hunt(); if (result == null) { return null; } Bitmap bitmap = result.getBitmap(); if (shouldWriteToMemoryCache(request.memoryPolicy)) { picasso.cache.set(request.key, bitmap); } return bitmap; }
Source:
<code>public void testCoverageTimeSlicingTimeBefore() throws Exception { setupRasterDimension( getLayerId(WATTEMP), ResourceInfo.TIME, DimensionPresentation.LIST, null); final File xml = new File("./src/test/resources/trimming/requestGetCoverageTimeSlicingXML.xml"); String request = FileUtils.readFileToString(xml, "UTF-8"); request = request.replace("${coverageId}", "sf__watertemp"); <START> request = request.replace("${slicePoint}", "2008-10-31T00:00:00.000Z"); <END> checkWaterTempValue(request, 14.89799975766800344); }</code><technical_language>test results changing nearest is default before. tests a variant nearest match on, showing nearest match behavior, activated, results in output</technical_language>

Target:
public void testCoverageTimeSlicingTimeBefore() throws Exception { setupRasterDimension( getLayerId(WATTEMP), ResourceInfo.TIME, DimensionPresentation.LIST, null); final File xml = new File("./src/test/resources/trimming/requestGetCoverageTimeSlicingXML.xml"); String request = FileUtils.readFileToString(xml, "UTF-8"); request = request.replace("${coverageId}", "sf__watertemp"); request = request.replace("${slicePoint}", "2000-10-31T00:00:00.000Z"); checkWaterTempValue(request, null); try { setupNearestMatch(WATTEMP, ResourceInfo.TIME, true, "P8Y", true); checkWaterTempValue(request, 14.89799975766800344); } finally { setupNearestMatch(WATTEMP, ResourceInfo.TIME, false); } }
Source:
<code>public boolean removeObserver(Entity entity) { checkChunkLoaded(); chunkObserversDirtyQueueElement.add(); TickStage.checkStage(TickStage.FINALIZE); <START> if (entity instanceof SpoutPlayer && observers.remove((SpoutPlayer) entity)) { <END> observingPlayers.remove((SpoutPlayer) entity); Engine engine = Spout.getEngine(); if (engine.getPlatform() == Platform.CLIENT && ((SpoutClient) engine).getPlayer() == entity) { setIsInViewDistance(false); } } expiredObserversQueue.add((SpoutEntity) entity); if (!isObserved()) { addToRegionUnloadQueue(); } return true; }</code><technical_language>This logic is different. observers contains entities other players. new code account for that</technical_language>

Target:
public boolean removeObserver(Entity entity) { if (Spout.getPlatform() != Platform.SERVER) { throw new UnsupportedOperationException("Cannot remove observers when not in server mode!"); } TickStage.checkStage(TickStage.FINALIZE); checkChunkLoaded(); if (observers.remove((SpoutEntity) entity) && (entity instanceof SpoutPlayer)) { observingPlayers.remove((SpoutPlayer) entity); } expiredObserversQueue.add((SpoutEntity) entity); if (!isObserved()) { this.unloadQueueElement.add(); } return true; }
Source:
<code>public void testConvertEmbeddedSubprocessNode_SlaDueDate() { final String SLA_DUE_DATE = "12/25/1983"; SubProcess subProcess = bpmn2.createSubProcess(); subProcess.setId(UUID.randomUUID().toString()); CustomElement.slaDueDate.setValue(subProcess, SLA_DUE_DATE); Result<BpmnNode> result = tested.convertSubProcess(subProcess); BpmnNode node = result.value(); <START> EmbeddedSubprocess embeddedSubProcces = (EmbeddedSubprocess) node.value().getContent().getDefinition(); <END> assertNotNull(embeddedSubProcces); assertNotNull(embeddedSubProcces.getExecutionSet()); EmbeddedSubprocessExecutionSet executionSet = embeddedSubProcces.getExecutionSet(); SLADueDate slaDueDate = executionSet.getSlaDueDate(); assertNotNull(slaDueDate); assertTrue(slaDueDate.getValue().contains(SLA_DUE_DATE)); }</code><technical_language>suggestion EmbeddedSubprocess embeddedSubProcess = (EmbeddedSubprocess) node.value().getContent().getDefinition();</technical_language>

Target:
public void testConvertEmbeddedSubprocessNode_SlaDueDate() { SubProcess subProcess = bpmn2.createSubProcess(); CustomElement.slaDueDate.setValue(subProcess, SLA_DUE_DATE); Result<BpmnNode> result = tested.convertSubProcess(subProcess); BpmnNode node = result.value(); EmbeddedSubprocess embeddedSubprocess = (EmbeddedSubprocess) node.value().getContent().getDefinition(); assertNotNull(embeddedSubprocess); assertBaseSubprocessExecutionSet(embeddedSubprocess.getExecutionSet()); }