auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Future<R> queue() { final Observable<R> o = toObservable(); final Future<R> f = new Future<R>() { final Future<R> base = o.toBlocking().toFuture(); @Override public boolean cancel(boolean mayInterruptIfRunning) { if (base.isCancelled()) { return false; } <START> mayInterruptOnCancel.set(mayInterruptIfRunning); <END> return base.cancel(mayInterruptIfRunning); } @Override public boolean isCancelled() { return base.isCancelled(); } @Override public boolean isDone() { return base.isDone(); } @Override public R get() throws InterruptedException, ExecutionException { return base.get(); } @Override public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return base.get(timeout, unit); } }; if (f.isDone()) { try { f.get(); return f; } catch (Exception e) { RuntimeException re = decomposeException(e); if (re instanceof HystrixBadRequestException) { return f; } else if (re instanceof HystrixRuntimeException) { HystrixRuntimeException hre = (HystrixRuntimeException) re; if (hre.getFailureType() == FailureType.COMMAND_EXCEPTION || hre.getFailureType() == FailureType.TIMEOUT) { return f; } else { throw hre; } } else { throw re; } } } return f; }</code><technical_language>I valid transition is false -> true. If a user weird 2 futures out (f1 f2), calls f1.cancel(true); f2.cancel(false), unclear time mayInterruptOnCancel is checked. I want set true in case. do like: if (mayInterruptIfRunning) { mayInterruptOnCancel.set(true); }</technical_language>

Target:
public Future<R> queue() { final Future<R> delegate = toObservable().toBlocking().toFuture(); final Future<R> f = new Future<R>() { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (delegate.isCancelled()) { return false; } if (HystrixCommand.this.getProperties().executionIsolationThreadInterruptOnFutureCancel().get()) { interruptOnFutureCancel.compareAndSet(false, mayInterruptIfRunning); } final boolean res = delegate.cancel(interruptOnFutureCancel.get()); if (!isExecutionComplete() && interruptOnFutureCancel.get()) { final Thread t = executionThread.get(); if (t != null && !t.equals(Thread.currentThread())) { t.interrupt(); } } return res; } @Override public boolean isCancelled() { return delegate.isCancelled(); } @Override public boolean isDone() { return delegate.isDone(); } @Override public R get() throws InterruptedException, ExecutionException { return delegate.get(); } @Override public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return delegate.get(timeout, unit); } }; if (f.isDone()) { try { f.get(); return f; } catch (Exception e) { RuntimeException re = decomposeException(e); if (re instanceof HystrixBadRequestException) { return f; } else if (re instanceof HystrixRuntimeException) { HystrixRuntimeException hre = (HystrixRuntimeException) re; switch (hre.getFailureType()) { case COMMAND_EXCEPTION: case TIMEOUT: return f; default: throw hre; } } else { throw re; } } } return f; }
Source:
<code><START> public MeterResponseData dequeue(final String correlationUid) throws FunctionalException { <END> try { final MeterResponseData meterResponseData = this.meterResponseDataRepository .findSingleResultByCorrelationUid(correlationUid); if (meterResponseData == null) { throw new FunctionalException(FunctionalExceptionType.UNKNOWN_CORRELATION_UID, ComponentType.WS_SMART_METERING); } this.remove(meterResponseData); return meterResponseData; } catch (final FunctionalException e) { if (e.getExceptionType() == FunctionalExceptionType.UNKNOWN_CORRELATION_UID) { LOGGER.warn("No response data for correlation UID {}", correlationUid); } throw e; } }</code><technical_language>"dequeue" is choice of method name here. suggests queues, actions a repository, I "load" "find" describe happens</technical_language>

Target:
public MeterResponseData dequeue(final String correlationUid) throws FunctionalException { final MeterResponseData meterResponseData = this.meterResponseDataRepository .findSingleResultByCorrelationUid(correlationUid); if (meterResponseData == null) { LOGGER.warn("No response data for correlation UID {}", correlationUid); throw new FunctionalException(FunctionalExceptionType.UNKNOWN_CORRELATION_UID, ComponentType.WS_SMART_METERING); } this.remove(meterResponseData); return meterResponseData; }
Source:
<code>public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { BigDecimal result = null; for (int i=0; i<children.size(); i++) { Expression childExpr = children.get(i); <START> if (!childExpr.evaluate(tuple, ptr) || ptr.getLength() == 0) { <END> return false; } PDataType childType = children.get(i).getDataType(); BigDecimal bd= (BigDecimal)PDataType.DECIMAL.toObject(ptr, childType); if (result == null) { result = bd; maxLength = childExpr.getMaxLength(); scale = childExpr.getScale(); } else { result = result.add(bd); if (maxLength != null && scale != null && childExpr.getMaxLength() != null & childExpr.getScale() != null) { int desiredPrecision = NumberUtil.getDecimalPrecision(NumericOperators.ADD, maxLength, childExpr.getMaxLength(), scale, childExpr.getScale()); int desiredScale = NumberUtil.getDecimalScale(NumericOperators.ADD, maxLength, childExpr.getMaxLength(), scale, childExpr.getScale()); result = NumberUtil.setDecimalWidthAndScale(result, desiredPrecision, desiredScale); if (result == null) { return false; } maxLength = desiredPrecision; scale = desiredScale; } } } ptr.set(PDataType.DECIMAL.toBytes(result)); return true; }</code><technical_language>This wrong before. change to: if (!childExpr.evaluate(tuple, ptr)) { return false; } if (ptr.getLength() == 0) { return true; }</technical_language>

Target:
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { BigDecimal result = null; for (int i=0; i<children.size(); i++) { Expression childExpr = children.get(i); if (!childExpr.evaluate(tuple, ptr)) { return false; } if (ptr.getLength() == 0) { return true; } PDataType childType = children.get(i).getDataType(); BigDecimal bd= (BigDecimal)PDataType.DECIMAL.toObject(ptr, childType); if (result == null) { result = bd; } else { result = result.add(bd); } } if (maxLength != null && scale != null) { result = NumberUtil.setDecimalWidthAndScale(result, maxLength, scale); } if (result == null) { return false; } ptr.set(PDataType.DECIMAL.toBytes(result)); return true; }
Source:
<code>private static <T extends HasMetadata> Function<T, Boolean> waitUntilDeletedOrInterrupted(OkHttpClient client, Config config, ResourceHandler<HasMetadata, HasMetadataVisitiableBuilder> h, String namespaceToUse) { return m -> { try { <START> return h.waitUntilCondition(client, config, namespaceToUse, m, Objects::isNull, 30 , TimeUnit.SECONDS) == null; <END> } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("interrupted waiting for item to be deleted, assuming not deleted"); return false; } }; }</code><technical_language>sense declare 30 a static constant</technical_language>

Target:
private static <T extends HasMetadata> Function<T, Boolean> waitUntilDeletedOrInterrupted(OkHttpClient client, Config config, ResourceHandler<HasMetadata, HasMetadataVisitiableBuilder> h, String namespaceToUse) { return m -> { try { return h.waitUntilCondition(client, config, namespaceToUse, m, Objects::isNull, MAX_WAIT_SECONDS , TimeUnit.SECONDS) == null; } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("interrupted waiting for item to be deleted, assuming not deleted"); return false; } }; }
Source:
<code>private void delayFor3dsReady(ChargeEntity charge) { int totalTimeDelayedInMillis = 0; int delayInMillis = 200; while (totalTimeDelayedInMillis < stripeGatewayConfig.getNotification3dsWaitDelay()) { ChargeEntity chargeEntity = chargeService.findChargeById(charge.getExternalId()); if (ChargeStatus.fromString(chargeEntity.getStatus()) == AUTHORISATION_3DS_READY) { break; } logger.info("Frontend has not posted 3ds ready locking state for charge [{}]," + <START> " waiting for 200ms", charge.getExternalId()); <END> try { Thread.sleep(delayInMillis); } catch (InterruptedException e) { logger.error("Waiting for 3ds ready locking state failed, {}", kv("error", e.getMessage())); } totalTimeDelayedInMillis += delayInMillis; } }</code><technical_language>worth parameterising this delayInMillis get out of date</technical_language>

Target:
private void delayFor3dsReady(ChargeEntity charge) { int totalTimeDelayedInMillis = 0; int delayInMillis = 200; while (totalTimeDelayedInMillis < stripeGatewayConfig.getNotification3dsWaitDelay()) { ChargeEntity chargeEntity = chargeService.findChargeById(charge.getExternalId()); if (ChargeStatus.fromString(chargeEntity.getStatus()) == AUTHORISATION_3DS_READY) { break; } try { Thread.sleep(delayInMillis); } catch (InterruptedException e) { logger.error("Waiting for 3ds ready locking state failed, {}", kv("error", e.getMessage())); } totalTimeDelayedInMillis += delayInMillis; } logger.info("Total time waited for Frontend to update charge to 3ds ready - milliseconds," , kv(PAYMENT_EXTERNAL_ID, charge.getExternalId()), totalTimeDelayedInMillis); }
Source:
<code><START> public Set<Id> getEffectiveGroups() { <END> if (effectiveGroups == null) { effectiveGroups = new HashSet<Id>(); if (authGroupNames == null) { effectiveGroups.addAll(authConfig.getAnonymousGroups()); } else { effectiveGroups.addAll(authConfig.getRegisteredGroups()); for (String authGroupName : authGroupNames) { AccountGroup group = groupCache.lookup(authGroupName); if (group != null) { effectiveGroups.add(group.getId()); } } } } return effectiveGroups; }</code><technical_language>Set<AccountGroup.Id></technical_language>

Target:
public Set<AccountGroup.Id> getEffectiveGroups() { return Collections.unmodifiableSet(effectiveGroups); }
Source:
<code>private void finishInput() { if (lookupSourceFactoryDestroyed.isDone()) { close(); return; <START> } <END> LookupSourceSupplier partition = buildLookupSource(); if (spillEnabled) { operatorContext.setRevocableMemoryReservation(partition.get().getInMemorySizeInBytes()); } else { operatorContext.setMemoryReservation(partition.get().getInMemorySizeInBytes()); } lookupSourceNotNeeded = Optional.of(lookupSourceFactory.lendPartitionLookupSource(partitionIndex, partition)); state = State.LOOKUP_SOURCE_BUILT; }</code><technical_language>add a checkState of methods clear lines switch case</technical_language>

Target:
private void finishInput() { checkState(state == State.CONSUMING_INPUT); if (lookupSourceFactoryDestroyed.isDone()) { close(); return; } LookupSourceSupplier partition = buildLookupSource(); if (spillEnabled) { operatorContext.setRevocableMemoryReservation(partition.get().getInMemorySizeInBytes()); } else { operatorContext.setMemoryReservation(partition.get().getInMemorySizeInBytes()); } lookupSourceNotNeeded = Optional.of(lookupSourceFactory.lendPartitionLookupSource(partitionIndex, partition)); state = State.LOOKUP_SOURCE_BUILT; }
Source:
<code>public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException { if(attribute.valueAsInteger() == null) { <START> throw new WrongReferenceAttributeValueException(attribute, "account expiration time shouldn't be null"); <END> } }</code><technical_language>Add object facility please</technical_language>

Target:
public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongReferenceAttributeValueException { if(attribute.getValue() == null) { throw new WrongReferenceAttributeValueException(attribute, null, facility, null, "account expiration time shouldn't be null"); } }
Source:
<code>public Tuple next() { if ( hasNext ) { Tuple current = createTuple( entityMap, next ); next = next( iterator ); return current; } <START> return null; <END> }</code><technical_language>throw a NoSuchElementException instead</technical_language>

Target:
public Tuple next() { if ( hasNext ) { Tuple current = createTuple( entityMap, next ); next = next( iterator ); return current; } throw new NoSuchElementException(); }
Source:
<code>public Event createEvent(MessageDescription description) { <START> log.debug("Processing pubsub event with payload {}", description.getMessagePayload()); <END> try { description.setArtifacts(parseArtifacts(description.getMessagePayload())); } catch (FatalTemplateErrorsException e) { log.error("Template failed to process artifacts for message {}", description, e); } Event event = new Event(); Map<String, Object> content = new HashMap<>(); Metadata details = new Metadata(); try { event.setPayload(objectMapper.readValue(description.getMessagePayload(), Map.class)); } catch (IOException e) { log.warn("Could not parse message payload as JSON", e); } content.put("messageDescription", description); details.setType(PubsubEventHandler.PUBSUB_TRIGGER_TYPE); if (description.getMessageAttributes() != null) { details.setAttributes(description.getMessageAttributes()); } event.setContent(content); event.setDetails(details); return event; }</code><technical_language>While refactoring, hide this a debug log flag get hidden further? This log statement generates a ton of log messages, helpful working</technical_language>

Target:
public Event createEvent(MessageDescription description) { log.trace("Processing pubsub event with payload {}", description.getMessagePayload()); try { description.setArtifacts(parseArtifacts(description.getMessagePayload())); } catch (FatalTemplateErrorsException e) { log.error("Template failed to process artifacts for message {}", description, e); } Event event = new Event(); Map<String, Object> content = new HashMap<>(); Metadata details = new Metadata(); try { event.setPayload(objectMapper.readValue(description.getMessagePayload(), Map.class)); } catch (IOException e) { log.warn("Could not parse message payload as JSON", e); } content.put("messageDescription", description); details.setType(PubsubEventHandler.PUBSUB_TRIGGER_TYPE); if (description.getMessageAttributes() != null) { details.setAttributes(description.getMessageAttributes()); } event.setContent(content); event.setDetails(details); return event; }
Source:
<code>public void shouldIncludeMotoFlagWhenChargeIsMoto() { when(charge.isMoto()).thenReturn(true); StripePaymentIntentRequest stripePaymentIntentRequest = createStripePaymentIntentRequest(); String payload = stripePaymentIntentRequest.getGatewayOrder().getPayload(); <START> assertThat(payload, containsString("payment_method_options%5Bcard%5Bmoto%5D%5D=true")); <END> }</code><technical_language>put string a some http encoder hard code (e.g. %5B) here</technical_language>

Target:
public void shouldIncludeMotoFlagWhenChargeIsMoto() { when(charge.isMoto()).thenReturn(true); StripePaymentIntentRequest stripePaymentIntentRequest = createStripePaymentIntentRequest(); String payload = stripePaymentIntentRequest.getGatewayOrder().getPayload(); assertThat(payload, containsString(URLEncoder.encode("payment_method_options[card[moto]]", UTF_8) + "=true")); }
Source:
<code>public static Enum toEnum(final Ds3Type ds3Type) { <START> final EnumConverter converter = new EnumConverter(ds3Type); <END> return converter.convert(); }</code><technical_language>creating instance of class perform conversion? a static method. This creating unnecessary object</technical_language>

Target:
public static Enum toEnum(final Ds3Type ds3Type) { final ImmutableList<String> valuesList = EnumHelper.convertDs3EnumConstants(ds3Type.getEnumConstants()); return new Enum( ds3Type.getName(), valuesList); }
Source:
<code>private Map<String,String> transform(List<TParameterDTO> params){ Map<String,String> result = new HashMap<String,String>(); for(TParameterDTO param: params) { result.put(param.getName(), param.getValue()); } <START> return result; <END> }</code><technical_language>reframed Collectors.toMap(TParameterDTO::getName, TParameterDTO::getValue)</technical_language>

Target:
private Map<String, String> transform(List<TParameterDTO> params) { return params.stream().collect(Collectors.toMap(TParameterDTO::getName, TParameterDTO::getValue)); }
Source:
<code>private Map<String, DurableExecutorConfig> durableExecutorConfigs( List<DurableExecutorConfiguration> durableExecutors ) { return durableExecutors.stream() .map( durableExecutor -> { final var dec = new DurableExecutorConfig( durableExecutor.getName() ) .setPoolSize( durableExecutor.getPoolSize() ) .setCapacity( durableExecutor.getCapacity() ) .setDurability( durableExecutor.getDurability() ); <START> if ( durableExecutor.getSplitBrainProtectionName() != null && <END> !durableExecutor.getSplitBrainProtectionName().isBlank() ) { dec.setSplitBrainProtectionName( durableExecutor.getSplitBrainProtectionName() ); } return dec; } ) .collect( Collectors.toMap( DurableExecutorConfig::getName, Function.identity() ) ); }</code><technical_language>Super minor readability preference for StringUtils.isNotBlank( durableExecutor.getSplitBrainProtectionName() ) (and below)</technical_language>

Target:
private Map<String, DurableExecutorConfig> durableExecutorConfigs( List<DurableExecutorConfiguration> durableExecutors ) { return durableExecutors.stream() .map( durableExecutor -> { final var dec = new DurableExecutorConfig( durableExecutor.getName() ) .setPoolSize( durableExecutor.getPoolSize() ) .setCapacity( durableExecutor.getCapacity() ) .setDurability( durableExecutor.getDurability() ); if ( StringUtils.isNotBlank( durableExecutor.getSplitBrainProtectionName() ) ) { dec.setSplitBrainProtectionName( durableExecutor.getSplitBrainProtectionName() ); } return dec; } ) .collect( Collectors.toMap( DurableExecutorConfig::getName, Function.identity() ) ); }
Source:
<code>public void setUp() throws Exception { executeDataSet("logEntriesTestDataset.xml"); this.service = Context.getService(IdentifierSourceService.class); <START> <END> }</code><technical_language>remove empty new lines</technical_language>

Target:
public void setUp() throws Exception { executeDataSet("org/openmrs/module/idgen/include/TestData.xml"); }
Source:
<code>protected Objects.ToStringHelper string() { return Objects.toStringHelper(this) <START> .add("zoneName", name) <END> .add("zoneState", zoneState); }</code><technical_language>name zoneName</technical_language>

Target:
protected Objects.ToStringHelper string() { return Objects.toStringHelper(this) .add("name", name) .add("state", state); }
Source:
<code>private synchronized void flushInternal(boolean isClose) throws IOException { try { maybeThrowLastError(); } catch (IOException e) { if (isClose) { throw new IOException("Skipping final flush and write due to " + e, e); } else throw e; <START> } <END> writeCurrentBufferToService(); flushWrittenBytesToService(isClose); }</code><technical_language>Instead, I update AbfsOutputStream.close wrap exception, short of Java implementers fix this. :)</technical_language>

Target:
private synchronized void flushInternal(boolean isClose) throws IOException { maybeThrowLastError(); writeCurrentBufferToService(); flushWrittenBytesToService(isClose); }
Source:
<code>public void postUpdateCommand(Class<?> commandType, IEnabledTarget action) { boolean hasMultipleWindows = PlatformUI.getWorkbench().getWorkbenchWindowCount() >= 2; synchronized (fCommandUpdates) { <START> if (!hasMultipleWindows) { <END> Job.getJobManager().cancel(commandType); } List<IEnabledTarget> actions = fCommandUpdates.get(commandType); if (actions == null) { actions = new ArrayList<>(); fCommandUpdates.put(commandType, actions); } actions.add(action); } }</code><technical_language>I check fgServices.size(). change window count is 2 more fgServices.size() is 1 I understand save service. (sorry smart-ass again; happy if others want change change)</technical_language>

Target:
public void postUpdateCommand(Class<?> commandType, IEnabledTarget action) { boolean hasMultipleWindowServices = hasMultipleWindowServices(); synchronized (fCommandUpdates) { if (!hasMultipleWindowServices) { Job.getJobManager().cancel(commandType); } List<IEnabledTarget> actions = fCommandUpdates.get(commandType); if (actions == null) { actions = new ArrayList<>(); fCommandUpdates.put(commandType, actions); } actions.add(action); } }
Source:
<code>public boolean enableNetwork(int netId, boolean disableOthers) { enforceChangePermission(); <START> mLog.trace("enableNetwork uid=%").c(Binder.getCallingUid()).flush(); <END> if (mWifiStateMachineChannel != null) { return mWifiStateMachine.syncEnableNetwork(mWifiStateMachineChannel, netId, disableOthers); } else { Slog.e(TAG, "mWifiStateMachineChannel is not initialized"); return false; } }</code><technical_language>i if this is want do here, good log network id boolean too. if a network is enabled, is blame.. is disabled, rest disabled</technical_language>

Target:
public boolean enableNetwork(int netId, boolean disableOthers) { enforceChangePermission(); mLog.trace("enableNetwork uid=% disableOthers=%") .c(Binder.getCallingUid()) .c(disableOthers ? "true" : "false").flush(); if (mWifiStateMachineChannel != null) { return mWifiStateMachine.syncEnableNetwork(mWifiStateMachineChannel, netId, disableOthers); } else { Slog.e(TAG, "mWifiStateMachineChannel is not initialized"); return false; } }
Source:
<code><START> private CPPASTStructuredBindingDeclaration getStructuredBindingDeclaration() { <END> IASTNode definition = getDefinition(); if (definition != null) { IASTNode parent = definition.getParent(); if (parent instanceof CPPASTStructuredBindingDeclaration) { return (CPPASTStructuredBindingDeclaration) parent; } } return null; }</code><technical_language>Likewise, this method return interface type</technical_language>

Target:
private ICPPASTStructuredBindingDeclaration getStructuredBindingDeclaration() { IASTNode definition = getDefinition(); if (definition != null) { IASTNode parent = definition.getParent(); if (parent instanceof ICPPASTStructuredBindingDeclaration) { return (ICPPASTStructuredBindingDeclaration) parent; } } return null; }
Source:
<code>private MultiValueMap<String, String> buildFormParameters(OAuth2AuthorizationCodeGrantRequest authorizationCodeGrantRequest) { ClientRegistration clientRegistration = authorizationCodeGrantRequest.getClientRegistration(); OAuth2AuthorizationExchange authorizationExchange = authorizationCodeGrantRequest.getAuthorizationExchange(); MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>(); formParameters.add(OAuth2ParameterNames.GRANT_TYPE, authorizationCodeGrantRequest.getGrantType().getValue()); formParameters.add(OAuth2ParameterNames.CODE, authorizationExchange.getAuthorizationResponse().getCode()); formParameters.add(OAuth2ParameterNames.REDIRECT_URI, authorizationExchange.getAuthorizationRequest().getRedirectUri()); if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) { formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId()); formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret()); } else if (ClientAuthenticationMethod.NONE.equals(clientRegistration.getClientAuthenticationMethod())) { formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId()); formParameters.add(PkceParameterNames.CODE_VERIFIER, <START> (String) authorizationExchange.getAuthorizationRequest().getAttributes().get(PkceParameterNames.CODE_VERIFIER)); <END> } return formParameters; }</code><technical_language>getAuthorizationRequest().getAttribute(PkceParameterNames.CODE_VERIFIER)</technical_language>

Target:
private MultiValueMap<String, String> buildFormParameters(OAuth2AuthorizationCodeGrantRequest authorizationCodeGrantRequest) { ClientRegistration clientRegistration = authorizationCodeGrantRequest.getClientRegistration(); OAuth2AuthorizationExchange authorizationExchange = authorizationCodeGrantRequest.getAuthorizationExchange(); MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>(); formParameters.add(OAuth2ParameterNames.GRANT_TYPE, authorizationCodeGrantRequest.getGrantType().getValue()); formParameters.add(OAuth2ParameterNames.CODE, authorizationExchange.getAuthorizationResponse().getCode()); String redirectUri = authorizationExchange.getAuthorizationRequest().getRedirectUri(); String codeVerifier = authorizationExchange.getAuthorizationRequest().getAttribute(PkceParameterNames.CODE_VERIFIER); if (redirectUri != null) { formParameters.add(OAuth2ParameterNames.REDIRECT_URI, redirectUri); } if (!ClientAuthenticationMethod.BASIC.equals(clientRegistration.getClientAuthenticationMethod())) { formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId()); } if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) { formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret()); } if (codeVerifier != null) { formParameters.add(PkceParameterNames.CODE_VERIFIER, codeVerifier); } return formParameters; }
Source:
<code>public static boolean shouldCauseReequipAnimation(@Nonnull ItemStack from, @Nonnull ItemStack to, int slot) { <START> boolean fromInvalid = from.func_190926_b(), toInvalid = to.func_190926_b(); <END> if (fromInvalid && toInvalid) return false; if (fromInvalid || toInvalid) return true; boolean changed = false; if (slot != -1) { changed = slot != slotMainHand; slotMainHand = slot; } return from.getItem().shouldCauseReequipAnimation(from, to, changed); }</code><technical_language>Please create variables this yikes. line is good</technical_language>

Target:
public static boolean shouldCauseReequipAnimation(@Nonnull ItemStack from, @Nonnull ItemStack to, int slot) { boolean fromInvalid = from.func_190926_b(); boolean toInvalid = to.func_190926_b(); if (fromInvalid && toInvalid) return false; if (fromInvalid || toInvalid) return true; boolean changed = false; if (slot != -1) { changed = slot != slotMainHand; slotMainHand = slot; } return from.getItem().shouldCauseReequipAnimation(from, to, changed); }
Source:
<code>private static void deleteDir(HdfsContext context, HdfsEnvironment hdfsEnvironment, Path path, boolean recursive) { try { hdfsEnvironment.getFileSystem(context, path).delete(path, recursive); } catch (Exception e) { <START> Logger.get(GlueHiveMetastore.class).warn(e, "Failed to delete path: " + path.toString()); <END> } }</code><technical_language>Declare logger top of class: java private static final Logger log = Logger.get(GlueHiveMetastore.class); (you inline Logger.get() pattern in some tests, normal way)</technical_language>

Target:
private static void deleteDir(HdfsContext context, HdfsEnvironment hdfsEnvironment, Path path, boolean recursive) { try { hdfsEnvironment.getFileSystem(context, path).delete(path, recursive); } catch (Exception e) { log.warn(e, "Failed to delete path: " + path.toString()); } }
Source:
<code>public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { clear(); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } <START> if (value instanceof JSeparator) { return (JSeparator)value; } <END> if (value instanceof String) { append((String)value); return this; } if (!(value instanceof ThemeEditorStyle)) { return null; } ThemeEditorStyle style = (ThemeEditorStyle)value; ThemeEditorStyle parent = style.getParent(); String styleName = style.getSimpleName(); String parentName = parent != null ? parent.getSimpleName() : null; if (!isSelected && style.isProjectStyle() && parentName != null && styleName.startsWith(parentName)) { append(parentName, SimpleTextAttributes.GRAY_ATTRIBUTES); append(".", SimpleTextAttributes.GRAY_ATTRIBUTES); append(styleName.substring(parentName.length() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES); } else { append(styleName, SimpleTextAttributes.REGULAR_ATTRIBUTES); } return this; }</code><technical_language>Nit: if I understand correctly, this condition moved "isSelected" check avoid configuring component is in end</technical_language>

Target:
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof JSeparator) { return (JSeparator)value; } clear(); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } if (value instanceof String) { append((String)value); return this; } if (!(value instanceof ThemeEditorStyle)) { return null; } ThemeEditorStyle style = (ThemeEditorStyle)value; ThemeEditorStyle parent = style.getParent(); String styleName = style.getSimpleName(); String parentName = parent != null ? parent.getSimpleName() : null; if (!isSelected && style.isProjectStyle() && parentName != null && styleName.startsWith(parentName)) { append(parentName, SimpleTextAttributes.GRAY_ATTRIBUTES); append(".", SimpleTextAttributes.GRAY_ATTRIBUTES); append(styleName.substring(parentName.length() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES); } else { append(styleName, SimpleTextAttributes.REGULAR_ATTRIBUTES); } return this; }
Source:
<code>public static GroupTypeDescription getGroupTypeDescription(Object actual) { Class<?> c = actual.getClass(); <START> if (Thread.currentThread().getStackTrace()[5].getClassName().contains("Spliterators")) <END> return new GroupTypeDescription("spliterator characteristics", "characteristics"); if (actual instanceof Map) return new GroupTypeDescription("map", "map entries"); if (c.isArray() && c.getComponentType().isPrimitive()) return new GroupTypeDescription("array " + c.getSimpleName(), c.getComponentType().getSimpleName()); if (c.isArray()) return new GroupTypeDescription("array " + c.getSimpleName(), "elements"); return new GroupTypeDescription(c.getSimpleName(), "elements"); }</code><technical_language>5 here? extract a constant avoid a magic number</technical_language>

Target:
public static GroupTypeDescription getGroupTypeDescription(Object actual) { Class<?> c = actual.getClass(); if (Thread.currentThread().getStackTrace()[SPLITERATORS_CLASS_STACK_TRACE_NUM].getClassName().contains("Spliterators")) return new GroupTypeDescription("spliterator characteristics", "characteristics"); if (actual instanceof Map) return new GroupTypeDescription("map", "map entries"); if (c.isArray() && c.getComponentType().isPrimitive() || actual instanceof String[]) return new GroupTypeDescription("array " + c.getSimpleName(), c.getComponentType().getSimpleName()); if (c.isArray()) return new GroupTypeDescription("array " + c.getSimpleName(), "elements"); return new GroupTypeDescription(c.getSimpleName(), "elements"); }
Source:
<code>public DSpaceCommandLineParameter(String parameter) { <START> this(StringUtils.substringBefore(parameter, " "), StringUtils.substringAfter(parameter, " ")); <END> }</code><technical_language>This logic potentially fragile. if accidentally types in *two spaces*, e.g. -c[space][space]test. Also, investigated is a potentially tools/API in Apache Commons CLI do this parameter parsing for (instead of string parsing)? If CLI API directly, rewriting ourselves</technical_language>

Target:
protected DSpaceCommandLineParameter(String parameter) { this(StringUtils.substringBefore(parameter, " "), StringUtils.substringAfter(parameter, " ")); }
Source:
<code>public void shouldUseAddedServiceCallListenerToInjectedStandaloneClientFactory() { <START> TestService testService = standaloneFactory.getServiceProxy(TestService.class, null); <END> ServiceCallListener listener = mock(ServiceCallListener.class); ((RatelServiceCallPublisher) standaloneFactory).addRatelServiceCallListener(listener); ProcessContext.getInstance().setProcessIdentifier("123"); TestServiceCallListener serverSideListener = startedApp.getBean(TestServiceCallListener.class); final String result = testService.hello(); assertThat(result).isEqualTo("success"); verify(listener, times(1)).remoteServiceCalled(any(RemoteServiceCallEvent.class)); verify(listener, times(1)).remoteServiceResponded(any(RemoteServiceResponseEvent.class)); verify(listener, times(0)).serviceInstanceCalled(any(ServiceInstanceCallEvent.class)); verify(listener, times(0)).serviceInstanceResponded(any(ServiceInstanceResponseEvent.class)); assertRecordedProcessId(serverSideListener.getServiceCallEvent(), "123"); assertRecordedProcessId(serverSideListener.getServiceResponseEvent(), "123"); }</code><technical_language>test case new way</technical_language>

Target:
public void shouldUseAddedServiceCallListenerToInjectedStandaloneClientFactory() { TestService testService = standaloneFactory.getServiceProxy(TestService.class); ServiceCallListener listener = mock(ServiceCallListener.class); ((RatelServiceCallPublisher) standaloneFactory).addRatelServiceCallListener(listener); ProcessContext.getInstance().setProcessIdentifier("123"); TestServiceCallListener serverSideListener = startedApp.getBean(TestServiceCallListener.class); final String result = testService.hello(); assertThat(result).isEqualTo("success"); verify(listener, times(1)).remoteServiceCalled(any(RemoteServiceCallEvent.class)); verify(listener, times(1)).remoteServiceResponded(any(RemoteServiceResponseEvent.class)); verify(listener, times(0)).serviceInstanceCalled(any(ServiceInstanceCallEvent.class)); verify(listener, times(0)).serviceInstanceResponded(any(ServiceInstanceResponseEvent.class)); assertRecordedProcessId(serverSideListener.getServiceCallEvent(), "123"); assertRecordedProcessId(serverSideListener.getServiceResponseEvent(), "123"); }
Source:
<code>protected Boolean asBooleanEmpty(String value) { value = value.trim(); if (StringUtils.isEmpty(value)) { return null; <START> } <END> if (value.equalsIgnoreCase("t") || value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("y")) { return true; } try { double numValue = Double.parseDouble(value); if (numValue > 0) { return true; } } catch (final NumberFormatException ex) { LOGGER.error("Could not parse " + value + " as an integer"); } return false; }</code><technical_language>this return false? I thought theory blank counts false, in general</technical_language>

Target:
protected Boolean asBooleanEmpty(String value) { value = value.trim(); if (StringUtils.isEmpty(value)) { return null; } return parseBoolean(value); }
Source:
<code>public void getSetBits(int[] offsets, int numOffsets, int offsetBase, int numBits, boolean[] vector) throws IOException { if (offsets[0] == offsetBase && offsets[numOffsets - 1] == offsetBase + numOffsets - 1) { getSetBits(numOffsets, vector); if (numBits > offsets[numOffsets - offsetBase - 1] + 1) { skip(numBits - offsets[numOffsets - 1] - offsetBase - 1); <START> } <END> return; } int position = 0; for (int i = 0; i < numOffsets; i++) { int target = offsets[i] - offsetBase; if (target > position) { skip(target - position); position = target; } vector[i] = nextBit(); position++; } if (numBits > offsets[numOffsets - 1] - offsetBase) { skip(offsets[numOffsets - 1] - offsetBase - position); } }</code><technical_language>this calculation work? strange mix numOffsets offsetBase in a single calculation. this simplified to: if (numBits > numOffsets) { skip(numBits - numOffsets); }</technical_language>

Target:
public void getSetBits(int[] offsets, int numOffsets, int offsetBase, int numBits, boolean[] vector) throws IOException { if (offsets[0] == offsetBase && offsets[numOffsets - 1] == offsetBase + numOffsets - 1) { getSetBits(numOffsets, vector); if (numBits > numOffsets) { skip(numBits - numOffsets); } return; } int previousOffset = offsetBase; for (int i = 0; i < numOffsets; i++) { int delta = offsets[i] - previousOffset; if (delta > 0) { skip(delta); previousOffset += delta; } vector[i] = nextBit(); previousOffset++; } if (numBits > previousOffset - offsetBase) { skip(numBits - (previousOffset - offsetBase)); } }
Source:
<code><START> private HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> createRequest() throws HandlerRequestException { Map<String, String> pathParamaters = new HashMap<>(); pathParamaters.put(TaskManagerIdPathParameter.KEY, taskManagerId.toString()); <END> return new HandlerRequest<>( EmptyRequestBody.getInstance(), new TaskManagerFileMessageParameters(), pathParamaters, Collections.emptyMap() ); }</code><technical_language>suggestion private static HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> createRequest() throws HandlerRequestException { Map<String, String> pathParamaters = new HashMap<>(); pathParamaters.put(TaskManagerIdPathParameter.KEY, TASK_MANAGER_ID.toString());</technical_language>

Target:
private static HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> createRequest() throws HandlerRequestException { Map<String, String> pathParameters = new HashMap<>(); pathParameters.put(TaskManagerIdPathParameter.KEY, TASK_MANAGER_ID.toString()); return new HandlerRequest<>( EmptyRequestBody.getInstance(), new TaskManagerFileMessageParameters(), pathParameters, Collections.emptyMap() ); }
Source:
<code>public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DimensionSelectorHavingSpec that = (DimensionSelectorHavingSpec) o; <START> if (value != null && that.value != null) { <END> return value.equals(that.value); } if (value == null && that.value == null) { return true; } return false; }</code><technical_language>equals check dimension</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DimensionSelectorHavingSpec that = (DimensionSelectorHavingSpec) o; boolean valEquals = false; boolean dimEquals = false; if (value != null && that.value != null) { valEquals = value.equals(that.value); } else if (value == null && that.value == null) { valEquals = true; } if (dimension != null && that.dimension != null) { dimEquals = dimension.equals(that.dimension); } else if (dimension == null && that.dimension == null) { dimEquals = true; } return (valEquals && dimEquals); }
Source:
<code>public void activate(String username) { ClientResource clientResource = sendActivationRequest(username); <START> closeRestletConnection(clientResource); <END> }</code><technical_language>this in finally</technical_language>

Target:
public void activate(String username) { ClientResource clientResource = null; try { clientResource = sendActivationRequest(username); } finally { if (clientResource != null) closeRestletConnection(clientResource); } }
Source:
<code><START> private static void cachePut(final CacheKey key, final boolean value) { <END> final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get(); if (cache != null) { cache.put(key, value); SecuredItemImpl.CACHE.set(cache); } }</code><technical_language>Again, this change modifies is semantic meaning</technical_language>

Target:
private void cachePut(final CacheKey key, final boolean value) { final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get(); if (cache != null) { cache.put(key, value); SecuredItemImpl.CACHE.set(cache); } }
Source:
<code>public void requestTicketOfTypeObjects() { User user = persistUser(); TicketType type = ticketTypeRepository.findByName(TEST_TICKET).get(); Ticket ticketToPersist = new Ticket(user, type); TicketOption pickupOption = ticketOptionRepository.findByName(PICKUP_SERVICE_OPTION).get(); ticketToPersist.addOption(pickupOption); TicketOption chMemberOption = ticketOptionRepository.findByName(CH_MEMBER_OPTION).get(); ticketToPersist.addOption(chMemberOption); List<TicketOption> options = Arrays.asList(pickupOption, chMemberOption); Set<TicketOption> optionSet = new HashSet<>(options); <START> testEntityManager.persist(ticketToPersist); <END> Ticket ticket = ticketService.requestTicketOfType(user, type, options); assertEquals(user, ticket.getOwner()); assertEquals(optionSet, ticket.getEnabledOptions()); assertEquals(type, ticket.getType()); }</code><technical_language>persisting a ticket requesting a new next action? persist action needed right? This applies for other tests</technical_language>

Target:
public void requestTicketOfTypeObjects() { User user = persistUser(); TicketType type = ticketTypeRepository.findByName(TEST_TICKET) .orElseThrow(() -> new TicketTypeNotFoundException(TEST_TICKET)); TicketOption pickupOption = ticketOptionRepository.findByName(PICKUP_SERVICE_OPTION) .orElseThrow(TicketOptionNotFoundException::new); TicketOption chMemberOption = ticketOptionRepository.findByName(CH_MEMBER_OPTION).orElseThrow(TicketOptionNotFoundException::new); List<TicketOption> optionsList = Arrays.asList(chMemberOption, pickupOption); Ticket ticket = ticketService.requestTicketOfType(user, type, optionsList); assertEquals(user, ticket.getOwner()); assertThat(ticket.getEnabledOptions()).containsAll(Arrays.asList(pickupOption, chMemberOption)); assertEquals(type, ticket.getType()); }
Source:
<code>public OpenShiftClientFactory( @Nullable @Named("che.infra.openshift.master_url") String masterUrl, @Nullable @Named("che.infra.openshift.username") String username, @Nullable @Named("che.infra.openshift.password") String password, @Nullable @Named("che.infra.openshift.oauth_token") String oauthToken, @Nullable @Named("che.infra.openshift.trust_certs") Boolean doTrustCerts) { OpenShiftConfigBuilder configBuilder = new OpenShiftConfigBuilder(); if (!isNullOrEmpty(masterUrl)) { configBuilder.withMasterUrl(masterUrl); } if (!isNullOrEmpty(username)) { configBuilder.withUsername(username); } if (!isNullOrEmpty(password)) { configBuilder.withPassword(password); } if (!isNullOrEmpty(oauthToken)) { configBuilder.withOauthToken(oauthToken); } if (doTrustCerts != null) { configBuilder.withTrustCerts(doTrustCerts); } <START> this.client = new DefaultOpenShiftClient(configBuilder.build()); <END> }</code><technical_language>Consider adding a decorator eliminate risk of calling close client</technical_language>

Target:
public OpenShiftClientFactory( @Nullable @Named("che.infra.openshift.master_url") String masterUrl, @Nullable @Named("che.infra.openshift.username") String username, @Nullable @Named("che.infra.openshift.password") String password, @Nullable @Named("che.infra.openshift.oauth_token") String oauthToken, @Nullable @Named("che.infra.openshift.trust_certs") Boolean doTrustCerts) { OpenShiftConfigBuilder configBuilder = new OpenShiftConfigBuilder(); if (!isNullOrEmpty(masterUrl)) { configBuilder.withMasterUrl(masterUrl); } if (!isNullOrEmpty(username)) { configBuilder.withUsername(username); } if (!isNullOrEmpty(password)) { configBuilder.withPassword(password); } if (!isNullOrEmpty(oauthToken)) { configBuilder.withOauthToken(oauthToken); } if (doTrustCerts != null) { configBuilder.withTrustCerts(doTrustCerts); } this.client = new UnclosableOpenShiftClient(configBuilder.build()); }
Source:
<code>public boolean unlinkChildren(int[] IDs) { if (children.length == 0) return (IDs.length == 0); int size = children.length; for (int i = 0; i < IDs.length; i++) { int index = findChild(IDs[i]); if (index != -1) { children[i] = -1; size--; } } if (size == 0) { children = EMPTY_ARRAY; return true; } int[] result = new int[size]; int pos = 0; for (int <START> element : <END> children) { if (element == -1) continue; result[pos] = element; pos++; } return true; }</code><technical_language>rename child</technical_language>

Target:
public boolean unlinkChildren(int[] IDs) { if (children.length == 0) return (IDs.length == 0); int size = children.length; for (int i = 0; i < IDs.length; i++) { int index = findChild(IDs[i]); if (index != -1) { children[i] = -1; size--; } } if (size == 0) { children = EMPTY_ARRAY; return true; } int[] result = new int[size]; int pos = 0; for (int child : children) { if (child == -1) continue; result[pos] = child; pos++; } return true; }
Source:
<code>private void splitSegment(PlatformOutboundInstruction platformOutboundInstruction) { EventProcessorSegmentReference splitSegment = platformOutboundInstruction.getSplitEventProcessorSegment(); int segmentId = splitSegment.getSegmentIdentifier(); String processorName = splitSegment.getProcessorName(); try { <START> eventProcessorController.splitSegment(processorName, segmentId); <END> resultPublisher.publishSuccessFor(platformOutboundInstruction.getInstructionId()); } catch (Exception e) { logger.error("Failed to split segment for processor [{}]", segmentId, processorName, e); resultPublisher.publishFailureFor(platformOutboundInstruction.getInstructionId(), e); } }</code><technical_language>EventProcessorController#splitSegment(String, int) method returns a boolean states operation successful TrackingEventProcessor. valuable this result publish a success failure</technical_language>

Target:
private void splitSegment(PlatformOutboundInstruction platformOutboundInstruction) { EventProcessorSegmentReference splitSegment = platformOutboundInstruction.getSplitEventProcessorSegment(); int segmentId = splitSegment.getSegmentIdentifier(); String processorName = splitSegment.getProcessorName(); String errorMessage = format("Failed to split segment [%s] for processor [%s]", segmentId, processorName); try { if (!eventProcessorController.splitSegment(processorName, segmentId)) { throw new RuntimeException(errorMessage); } resultPublisher.publishSuccessFor(platformOutboundInstruction.getInstructionId()); } catch (Exception e) { logger.error(errorMessage, e); resultPublisher.publishFailureFor(platformOutboundInstruction.getInstructionId(), e); } }
Source:
<code>protected String getSuiteFilter(Class<?> klass) throws Exception { String suiteFilter = System.getProperty(SUITE_FILTER_OVERRIDE_VARIABLE_NAME); if (StringUtils.isEmpty(suiteFilter)) { <START> SuiteFilter suiteFilterAnnotation = klass.getAnnotation(SuiteFilter.class); <END> if (suiteFilterAnnotation == null) { return null; } suiteFilter = suiteFilterAnnotation.value(); } return suiteFilter; }</code><technical_language>is in this block (inside this if) superclass' behavior? If please replace super. getSuiteFilter(klass)</technical_language>

Target:
protected String getSuiteFilter(Class<?> klass) throws Exception { String suiteFilter = System.getProperty(SUITE_FILTER_OVERRIDE_VARIABLE_NAME); if (StringUtils.isEmpty(suiteFilter)) { SuiteFilter suiteFilterAnnotation = klass.getAnnotation(SuiteFilter.class); return suiteFilterAnnotation == null?null:suiteFilterAnnotation.value(); } return suiteFilter; }
Source:
<code>public static List<Question> getSurveyXQuestion(final List<Response> surveyXResponses, final List<Question> surveyXQuestions) { if (surveyXResponses.size() == surveyXQuestions.size()) { return Lists.newArrayList(); } final List<Integer> responded_question_ids = getRespondedQuestionIds(surveyXResponses); final List<Integer> responded_response_ids = getRespondedResponseIds(surveyXResponses); final List<Question> availableQuestions = Lists.newArrayList(); <START> for (Question question : surveyXQuestions) { <END> if (!Collections.disjoint(responded_question_ids, Lists.newArrayList(question.id))) { continue; } if (!question.dependencyResponse.isEmpty() && Collections.disjoint(responded_response_ids, question.dependencyResponse)) { continue; } availableQuestions.add(question); } return availableQuestions; }</code><technical_language>final</technical_language>

Target:
public static List<Question> getSurveyXQuestion(final List<Response> surveyXResponses, final List<Question> surveyXQuestions) { if (surveyXResponses.size() == surveyXQuestions.size()) { return Lists.newArrayList(); } final List<Integer> responded_question_ids = getRespondedQuestionIds(surveyXResponses); final List<Integer> responded_response_ids = getRespondedResponseIds(surveyXResponses); final List<Question> availableQuestions = Lists.newArrayList(); for (final Question question : surveyXQuestions) { if (!Collections.disjoint(responded_question_ids, Lists.newArrayList(question.id))) { continue; } if (!question.dependencyResponse.isEmpty() && Collections.disjoint(responded_response_ids, question.dependencyResponse)) { continue; } availableQuestions.add(question); } return availableQuestions; }