auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Object defaultWebFlux(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker, String methodName) throws Throwable { CircuitBreakerUtils.isCallPermitted(circuitBreaker); long start = System.nanoTime(); try { Object returnValue = proceedingJoinPoint.proceed(); if (returnValue instanceof Flux) { Flux fluxReturnValue = (Flux) returnValue; return fluxReturnValue.transform(CircuitBreakerOperator.of(circuitBreaker)); } else if (returnValue instanceof Mono) { <START> Mono fluxReturnValue = (Mono) returnValue; <END> return fluxReturnValue.transform(CircuitBreakerOperator.of(circuitBreaker)); } else { throw new IllegalArgumentException("Not Supported type for the circuit breaker in web flux :" + returnValue.getClass().getName()); } } catch (Throwable throwable) { long durationInNanos = System.nanoTime() - start; circuitBreaker.onError(durationInNanos, throwable); if (logger.isDebugEnabled()) { logger.debug("Invocation of method '" + methodName + "' failed!", throwable); } throw throwable; } }</code><technical_language>variable name flux is a mono</technical_language>

Target:
private Object defaultWebFlux(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker, String methodName) throws Throwable { CircuitBreakerUtils.isCallPermitted(circuitBreaker); long start = System.nanoTime(); try { Object returnValue = proceedingJoinPoint.proceed(); if (returnValue instanceof Flux) { Flux fluxReturnValue = (Flux) returnValue; return fluxReturnValue.transform(CircuitBreakerOperator.of(circuitBreaker)); } else if (returnValue instanceof Mono) { Mono monoReturnValue = (Mono) returnValue; return monoReturnValue.transform(CircuitBreakerOperator.of(circuitBreaker)); } else { throw new IllegalArgumentException("Not Supported type for the circuit breaker in web flux :" + returnValue.getClass().getName()); } } catch (Throwable throwable) { long durationInNanos = System.nanoTime() - start; circuitBreaker.onError(durationInNanos, throwable); if (logger.isDebugEnabled()) { logger.debug("Invocation of method '" + methodName + "' failed!", throwable); } throw throwable; } }
Source:
<code>public void taskCompletedComplete() { cTestEvent.cTasksCompleted = 20; <START> TestStrollEvent spy = Mockito.spy(cTestEvent); <END> Mockito.doNothing().when(spy).clearEvent(); spy.taskCompleted(); Mockito.verify(spy).clearEvent(); }</code><technical_language>cTestEvent a spy in constructor. wrote this code need spy more times</technical_language>

Target:
public void taskCompletedComplete() { cSpyEvent.cTasksCompleted = TestStrollEvent.MAX_TASKS; Mockito.doNothing().when(cSpyEvent).clearEvent(); cSpyEvent.taskCompleted(); Mockito.verify(cSpyEvent).clearEvent(); }
Source:
<code><START> public void authenticate() throws AccumuloSecurityException, AccumuloException { <END> if (context.getCredentials().getToken().isDestroyed()) throw new AccumuloSecurityException(context.getCredentials().getPrincipal(), SecurityErrorCode.TOKEN_EXPIRED); final String tokenClassName = context.getCredentials().getToken().getClass().getName(); if (!SYSTEM_TOKEN_NAME.equals(tokenClassName)) { ServerClient.executeVoid(context, iface -> { if (!iface.authenticate(Tracer.traceInfo(), context.rpcCreds())) throw new AccumuloSecurityException("Authentication failed, access denied", SecurityErrorCode.BAD_CREDENTIALS); }); } }</code><technical_language>Moving this out of constructor is good, I needs in public API. And, in fact, current implementation is bad for public API anyway, special handling for system users, inappropriate for public API. reason need of this code all, is retain existing behavior in ConnectorImpl... which, I tell, modified call this new method anyway. I prefer we: 1. this out of public API, 2. retain check constructing AccumuloClientImpl behalf of ConnectorImpl, else</technical_language>

Target:
void authenticate() throws AccumuloSecurityException, AccumuloException { if (context.getCredentials().getToken().isDestroyed()) throw new AccumuloSecurityException(context.getCredentials().getPrincipal(), SecurityErrorCode.TOKEN_EXPIRED); final String tokenClassName = context.getCredentials().getToken().getClass().getName(); if (!SYSTEM_TOKEN_NAME.equals(tokenClassName)) { ServerClient.executeVoid(context, iface -> { if (!iface.authenticate(Tracer.traceInfo(), context.rpcCreds())) throw new AccumuloSecurityException("Authentication failed, access denied", SecurityErrorCode.BAD_CREDENTIALS); }); } }
Source:
<code>void check(HttpServerExchange exchange, int contentLength, AttachmentContent attachment) throws InvalidContentLengthException, ContentTooLargeException { int max = attachment.getCachedTopic().getTopic().getMaxMessageSize(); long expected = exchange.getRequestContentLength(); if (expected != contentLength && !isChunked(exchange.getRequestHeaders(), expected)) { throw new InvalidContentLengthException(expected, contentLength); } else if (contentLength > max) { if (forceMaxMessageSizePerTopic) { throw new ContentTooLargeException(contentLength, max); } else { <START> logger.info("Content-Length is larger than max on this topic [length:{}, max:{}, topic: {}]", <END> contentLength, max, attachment.getCachedTopic().getQualifiedName()); } } }</code><technical_language>warn? want this warning for</technical_language>

Target:
void check(HttpServerExchange exchange, int contentLength, AttachmentContent attachment) throws InvalidContentLengthException, ContentTooLargeException { int max = attachment.getCachedTopic().getTopic().getMaxMessageSize(); long expected = exchange.getRequestContentLength(); if (expected != contentLength && !isChunked(exchange.getRequestHeaders(), expected)) { throw new InvalidContentLengthException(expected, contentLength); } else if (contentLength > max) { if (forceMaxMessageSizePerTopic) { throw new ContentTooLargeException(contentLength, max); } else { logger.warn("Content-Length is larger than max on this topic [length:{}, max:{}, topic: {}]", contentLength, max, attachment.getCachedTopic().getQualifiedName()); } } }
Source:
<code>int read() { <START> if (this.hasNext() == false) { <END> throw new IllegalStateException("This stream hasn't any other value, all values were already read."); } int value = this.interval[nextPos]; this.nextPos++; return value; }</code><technical_language>if (!this.hasNext())</technical_language>

Target:
int read() { if (!this.hasNext()) { throw new IllegalStateException("This stream hasn't any other value, all values were already read."); } int value = this.interval[nextPos]; this.nextPos++; return value; }
Source:
<code>private void validateDescriptors() { Map<String, List<AttributeDescriptor>> descriptorMap = new HashMap<>(); for (AttributeDescriptor descriptor : descriptors) { if (descriptor == null) { continue; } <START> descriptorMap.putIfAbsent(descriptor.getName(), new ArrayList<>()); <END> descriptorMap.get(descriptor.getName()).add(descriptor); } for (Map.Entry<String, List<AttributeDescriptor>> entry : descriptorMap.entrySet()) { if (entry.getValue().size() > 1) { LOGGER.warn( "Conflicting attribute definitions on for {}. Conflicting definitions: {}", name, entry.getKey(), entry.getValue()); } } }</code><technical_language>Instead of iterating this add map check for duplicates - check if exists do logger warn in this initial iteration</technical_language>

Target:
private void validateDescriptors() { Set<String> names = new HashSet<>(); descriptors .stream() .filter(Objects::nonNull) .forEach( attributeDescriptor -> { if (!names.contains(attributeDescriptor.getName())) { names.add(attributeDescriptor.getName()); } else { LOGGER.warn( "Conflicting attribute definitions on for {}.", name, attributeDescriptor.getName()); } }); }
Source:
<code>private boolean shouldPublishIndividualGaugeMetric(Gauge<T> constituentGauge) { T value = constituentGauge.getValue(); return lowerBoundSupplier.get() .map(lowerBound -> isAtLeastLowerBound(value, lowerBound)) .orElse(true); <START> } <END></code><technical_language>In case of duplicates, publishing more metrics</technical_language>

Target:
private boolean shouldPublishIndividualGaugeMetric(Gauge<T> constituentGauge) { return publishableGauges.get().contains(constituentGauge); }
Source:
<code>protected Object handleRequestMessage(Message<?> requestMessage) { <START> if (!this.initialized.getAndSet(true)) { <END> initialize(); } return exchanger.exchange(requestMessage); }</code><technical_language>AtomicBoolean work - get NPE next statement. need a synchronized block a double null check</technical_language>

Target:
protected Object handleRequestMessage(Message<?> requestMessage) { if (this.exchanger == null) { synchronized (this) { if (this.exchanger == null) { initialize(); } } } return this.exchanger.exchange(requestMessage); }
Source:
<code>public static void main(String[] args) throws IOException, InterruptedException { SamplesArguments parsedArguments = new SamplesArguments(args); client = new DigitalTwinsClientBuilder() .tokenCredential( new ClientSecretCredentialBuilder() .tenantId(parsedArguments.getTenantId()) .clientId(parsedArguments.getClientId()) .clientSecret(parsedArguments.getClientSecret()) .build() ) .endpoint(parsedArguments.getDigitalTwinUrl()) .httpLogOptions( new HttpLogOptions() <START> .setLogLevel(HttpLogDetailLevel.NONE)) <END> .buildAsyncClient(); deleteTwins(); createTwins(); }</code><technical_language>nit: get log level command line</technical_language>

Target:
public static void main(String[] args) throws IOException, InterruptedException { SamplesArguments parsedArguments = new SamplesArguments(args); client = new DigitalTwinsClientBuilder() .tokenCredential( new ClientSecretCredentialBuilder() .tenantId(parsedArguments.getTenantId()) .clientId(parsedArguments.getClientId()) .clientSecret(parsedArguments.getClientSecret()) .build() ) .endpoint(parsedArguments.getDigitalTwinEndpoint()) .httpLogOptions( new HttpLogOptions() .setLogLevel(parsedArguments.getHttpLogDetailLevel())) .buildAsyncClient(); deleteTwins(); createTwins(); }
Source:
<code>public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName) { if (credentialType != PasswordCredential.class) { return SupportLevel.UNSUPPORTED; } <START> if (algorithmName == null) { <END> return SupportLevel.SUPPORTED; } DirContext context = null; try { context = contextFactory.obtainDirContext(null); Attributes attributes = context.getAttributes(distinguishedName, new String[] { algorithmAttributeName, hashAttributeName, seedAttributeName, sequenceAttributeName }); Attribute algorithmAttribute = attributes.get(algorithmAttributeName); Attribute hashAttribute = attributes.get(hashAttributeName); Attribute seedAttribute = attributes.get(seedAttributeName); Attribute sequenceAttribute = attributes.get(sequenceAttributeName); if (algorithmAttribute != null && hashAttribute != null && seedAttribute != null && sequenceAttribute != null && algorithmAttribute.contains(algorithmName)) { return SupportLevel.SUPPORTED; } } catch (NamingException e) { } finally { contextFactory.returnContext(context); } return SupportLevel.UNSUPPORTED; }</code><technical_language>I this 'if' is correct - need verify this identity set of OTP attributes care algorithm is in use</technical_language>

Target:
public SupportLevel getCredentialAcquireSupport(final Class<? extends Credential> credentialType, final String algorithmName) { if (credentialType != PasswordCredential.class) { return SupportLevel.UNSUPPORTED; } DirContext context = null; try { context = contextFactory.obtainDirContext(null); Attributes attributes = context.getAttributes(distinguishedName, new String[] { algorithmAttributeName, hashAttributeName, seedAttributeName, sequenceAttributeName }); Attribute algorithmAttribute = attributes.get(algorithmAttributeName); Attribute hashAttribute = attributes.get(hashAttributeName); Attribute seedAttribute = attributes.get(seedAttributeName); Attribute sequenceAttribute = attributes.get(sequenceAttributeName); if (algorithmAttribute != null && hashAttribute != null && seedAttribute != null && sequenceAttribute != null && (algorithmName == null || algorithmAttribute.contains(algorithmName))) { return SupportLevel.SUPPORTED; } } catch (NamingException e) { } finally { contextFactory.returnContext(context); } return SupportLevel.UNSUPPORTED; }
Source:
<code>public static CompletionStage<Void> writeTo(final InputStream in, final AsyncOutputStream out) { byte[] buf = new byte[2048]; int read; try { while ((read = in.read(buf)) != -1) { out.asyncWrite(buf, 0, read); <START> buf = new byte[2048]; <END> } } catch (IOException e) { return completedException(e); } return CompletableFuture.completedFuture(null); }</code><technical_language>wrong here, this keeping allocating new byte arrays? a single re-used</technical_language>

Target:
public static CompletionStage<Void> writeTo(final InputStream in, final AsyncOutputStream out) { byte[] buf = new byte[2048]; int read; try { while ((read = in.read(buf)) != -1) { out.asyncWrite(buf, 0, read); } } catch (IOException e) { return completedException(e); } return CompletableFuture.completedFuture(null); }
Source:
<code>private Pool findPool(String poolId) { <START> Pool pool = poolManager.find(poolId); <END> if (pool == null) { throw new BadRequestException(i18n.tr("Pool with id {0} could not be found.", poolId)); } return pool; }</code><technical_language>need check, this fail in poolId is null empty. If need wrap this (and other lookups in similar methods) in a null empty check</technical_language>

Target:
private Pool findPool(String poolId) { Pool pool; if (poolId != null && !poolId.isEmpty()) { pool = poolManager.find(poolId); } else { throw new BadRequestException(i18n.tr("Pool id is null or empty.")); } if (pool == null) { throw new BadRequestException(i18n.tr("Pool with id {0} could not be found.", poolId)); } return pool; }
Source:
<code>public int[] getAcceptableTokens() { return new int[] { TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.PACKAGE_DEF, TokenTypes.ENUM_CONSTANT_DEF, TokenTypes.ENUM_DEF, <START> TokenTypes.METHOD_DEF, <END> TokenTypes.CTOR_DEF, TokenTypes.VARIABLE_DEF, TokenTypes.PARAMETER_DEF, TokenTypes.ANNOTATION_DEF, TokenTypes.TYPECAST, TokenTypes.LITERAL_THROWS, TokenTypes.IMPLEMENTS_CLAUSE, TokenTypes.TYPE_ARGUMENT, TokenTypes.LITERAL_NEW, TokenTypes.DOT, TokenTypes.ANNOTATION_FIELD_DEF, }; }</code><technical_language>@pbludov @romani reasons default</technical_language>

Target:
public int[] getAcceptableTokens() { return new int[] { TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.PACKAGE_DEF, TokenTypes.ENUM_CONSTANT_DEF, TokenTypes.ENUM_DEF, TokenTypes.METHOD_DEF, TokenTypes.CTOR_DEF, TokenTypes.VARIABLE_DEF, TokenTypes.PARAMETER_DEF, TokenTypes.ANNOTATION_DEF, TokenTypes.ANNOTATION_FIELD_DEF, }; }
Source:
<code><START> public void tearDown() throws Exception { <END> LogReaderService logReaderService = appContext.get(LogReaderService.class); logReaderService.removeLogListener(listener); if (wb != null) { wb.close(); } appContext.dispose(); }</code><technical_language>I "throws Exception" is unnecessary</technical_language>

Target:
public void tearDown() { LogReaderService logReaderService = appContext.get(LogReaderService.class); logReaderService.removeLogListener(listener); if (wb != null) { wb.close(); } appContext.dispose(); }
Source:
<code><START> private void handleRepeatedInvocation() { <END> if (fContentAssistant.isRepeatedInvocationMode()) { fComputedProposals= computeProposals(fFilterOffset); setProposals(fComputedProposals, false); } }</code><technical_language>Please do reduce visibility of existing fields part of this change, reasons investigate separately reducing visibility</technical_language>

Target:
void handleRepeatedInvocation() { if (fContentAssistant.isRepeatedInvocationMode()) { fComputedProposals= computeProposals(fFilterOffset); setProposals(fComputedProposals, false); } }
Source:
<code>public void testRegistrationAndDiscoveryServices() throws Exception { EurekaClient eurekaClient = EurekaClientBuilder.newBuilder() .withReadServerResolver(ServerResolvers.just("localhost", writeServerResource.getDiscoveryPort())) .withWriteServerResolver(ServerResolvers.just("localhost", writeServerResource.getRegistrationPort())) .build(); InstanceInfo instanceInfo = SampleInstanceInfo.DiscoveryServer.build(); RegistrationRequest request = eurekaClient.connect(Observable.just(instanceInfo)); request.subscribe(); <START> request.getInitObservable().toBlocking().lastOrDefault(null); <END> List<ChangeNotification<InstanceInfo>> notifications = eurekaClient .forInterest(Interests.forFullRegistry()) .take(2) .toList() .toBlocking().single(); assertThat(notifications.size(), is(equalTo(2))); eurekaClient.shutdown(); }</code><technical_language>This repetitive statements. care registration ignore lifecycle. more handy if RegistrationRequest observable is for registration, while is registrationRequest.lifecycle() if cares it</technical_language>

Target:
public void testRegistrationAndDiscoveryServices() throws Exception { EurekaClient eurekaClient = EurekaClientBuilder.newBuilder() .withReadServerResolver(ServerResolvers.just("localhost", writeServerResource.getDiscoveryPort())) .withWriteServerResolver(ServerResolvers.just("localhost", writeServerResource.getRegistrationPort())) .build(); InstanceInfo instanceInfo = SampleInstanceInfo.DiscoveryServer.build(); RegistrationObservable request = eurekaClient.register(Observable.just(instanceInfo)); request.subscribe(); request.initialRegistrationResult().toBlocking().lastOrDefault(null); List<ChangeNotification<InstanceInfo>> notifications = eurekaClient .forInterest(Interests.forFullRegistry()) .take(2) .toList() .toBlocking().single(); assertThat(notifications.size(), is(equalTo(2))); eurekaClient.shutdown(); }
Source:
<code>private String createProcessorId(Config config) { ApplicationConfig appConfig = new ApplicationConfig(config); if (appConfig.getProcessorId() != null) { return appConfig.getProcessorId(); <START> } else if (!StringUtils.isEmpty(appConfig.getAppProcessorIdGeneratorClass())) { <END> ProcessorIdGenerator idGenerator = ClassLoaderHelper.fromClassName(appConfig.getAppProcessorIdGeneratorClass(), ProcessorIdGenerator.class); return idGenerator.generateProcessorId(config); } else { throw new ConfigException(String .format("Expected either %s or %s to be configured", ApplicationConfig.PROCESSOR_ID, ApplicationConfig.APP_PROCESSOR_ID_GENERATOR_CLASS)); } }</code><technical_language>replace isEmpty w/ isBlank values " " accepted? btw, commons isNotEmpty, isNotBlank. IMO, more readable explicit</technical_language>

Target:
private String createProcessorId(Config config) { ApplicationConfig appConfig = new ApplicationConfig(config); if (appConfig.getProcessorId() != null) { return appConfig.getProcessorId(); } else if (StringUtils.isNotBlank(appConfig.getAppProcessorIdGeneratorClass())) { ProcessorIdGenerator idGenerator = ClassLoaderHelper.fromClassName(appConfig.getAppProcessorIdGeneratorClass(), ProcessorIdGenerator.class); return idGenerator.generateProcessorId(config); } else { throw new ConfigException(String .format("Expected either %s or %s to be configured", ApplicationConfig.PROCESSOR_ID, ApplicationConfig.APP_PROCESSOR_ID_GENERATOR_CLASS)); } }
Source:
<code>protected void run() throws Exception { CheckoutCommand command = new Git(db).checkout(); command.setCreateBranch(createBranch); command.setName(name); command.setForce(force); try { String oldBranch = db.getBranch(); Ref ref = command.call(); <START> if (Repository.shortenRefName(ref.getName()).equals(oldBranch)) <END> out.println(MessageFormat.format(CLIText.get().alreadyOnBranch, name)); if (createBranch) out.println(MessageFormat.format( CLIText.get().switchedToNewBranch, Repository.shortenRefName(ref.getName()))); else out.println(MessageFormat.format( CLIText.get().switchedToBranch, Repository.shortenRefName(ref.getName()))); } catch (RefNotFoundException e) { throw die(MessageFormat.format(CLIText.get().pathspecDidNotMatch, name)); } catch (RefAlreadyExistsException e) { throw die(MessageFormat.format( CLIText.get().checkoutBranchAlreadyExists, name)); } }</code><technical_language>method return early output is 'b2' Switched branch 'b2' native git 'b2'</technical_language>

Target:
protected void run() throws Exception { if (createBranch) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) throw die(CLIText.get().onBranchToBeBorn); } CheckoutCommand command = new Git(db).checkout(); command.setCreateBranch(createBranch); command.setName(name); command.setForce(force); try { String oldBranch = db.getBranch(); Ref ref = command.call(); if (Repository.shortenRefName(ref.getName()).equals(oldBranch)) { out.println(MessageFormat.format(CLIText.get().alreadyOnBranch, name)); return; } if (createBranch) out.println(MessageFormat.format( CLIText.get().switchedToNewBranch, Repository.shortenRefName(ref.getName()))); else out.println(MessageFormat.format( CLIText.get().switchedToBranch, Repository.shortenRefName(ref.getName()))); } catch (RefNotFoundException e) { throw die(MessageFormat.format(CLIText.get().pathspecDidNotMatch, name)); } catch (RefAlreadyExistsException e) { throw die(MessageFormat.format( CLIText.get().checkoutBranchAlreadyExists, name)); } }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); <START> speakerName = getIntent().getStringExtra(Speaker.Companion.getSPEAKER()); <END> setSupportActionBar(toolbar); if(getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); collapsingToolbarLayout.setTitle(" "); appBarLayout.addOnOffsetChangedListener(this); speakerDetailsViewModel = ViewModelProviders.of(this).get(SpeakerDetailsViewModel.class); DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics(); float width = displayMetrics.widthPixels / displayMetrics.density; int spanCount = (int) (width / 250.00); sessionRecyclerView.setHasFixedSize(true); gridLayoutManager = new GridLayoutManager(this, spanCount); sessionRecyclerView.setLayoutManager(gridLayoutManager); sessionsListAdapter = new SessionsListAdapter(this, sessions, spearkerWiseSessionList); sessionsListAdapter.setOnBookmarkSelectedListener(this); sessionsListAdapter.setHandleItemClickListener(this); sessionRecyclerView.setNestedScrollingEnabled(false); sessionRecyclerView.setAdapter(sessionsListAdapter); sessionRecyclerView.setItemAnimator(new DefaultItemAnimator()); handleVisibility(); }</code><technical_language>Companion</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); speakerName = getIntent().getStringExtra(Speaker.SPEAKER); setSupportActionBar(toolbar); if(getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); collapsingToolbarLayout.setTitle(" "); appBarLayout.addOnOffsetChangedListener(this); speakerDetailsViewModel = ViewModelProviders.of(this).get(SpeakerDetailsViewModel.class); DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics(); float width = displayMetrics.widthPixels / displayMetrics.density; int spanCount = (int) (width / 250.00); sessionRecyclerView.setHasFixedSize(true); gridLayoutManager = new GridLayoutManager(this, spanCount); sessionRecyclerView.setLayoutManager(gridLayoutManager); sessionsListAdapter = new SessionsListAdapter(this, sessions, spearkerWiseSessionList); sessionsListAdapter.setOnBookmarkSelectedListener(this); sessionsListAdapter.setHandleItemClickListener(this); sessionRecyclerView.setNestedScrollingEnabled(false); sessionRecyclerView.setAdapter(sessionsListAdapter); sessionRecyclerView.setItemAnimator(new DefaultItemAnimator()); handleVisibility(); }
Source:
<code>private Property resolveApiAnnotated(ModelConverterContext context, Property property, Annotation[] annotations, ApiModelProperty mp, JavaType propType) { String or = mp.dataType(); JavaType innerJavaType = null; <START> LOGGER.debug("overriding datatype from " + propType + " to " + or); <END> if (or.toLowerCase().startsWith("list[")) { String innerType = or.substring(5, or.length() - 1); ArrayProperty p = new ArrayProperty(); Property primitiveProperty = PrimitiveType.createProperty(innerType); if (primitiveProperty != null) { p.setItems(primitiveProperty); } else { innerJavaType = getInnerType(innerType); p.setItems(context.resolveProperty(innerJavaType, annotations)); } property = p; } else if (or.toLowerCase().startsWith("map[")) { int pos = or.indexOf(","); if (pos > 0) { String innerType = or.substring(pos + 1, or.length() - 1); MapProperty p = new MapProperty(); Property primitiveProperty = PrimitiveType.createProperty(innerType); if (primitiveProperty != null) { p.setAdditionalProperties(primitiveProperty); } else { innerJavaType = getInnerType(innerType); p.setAdditionalProperties(context.resolveProperty(innerJavaType, annotations)); } property = p; } } else { Property primitiveProperty = PrimitiveType.createProperty(or); if (primitiveProperty != null) { property = primitiveProperty; } else { innerJavaType = getInnerType(or); property = context.resolveProperty(innerJavaType, annotations); } } if (innerJavaType != null) { context.resolve(innerJavaType); } return property; }</code><technical_language>Curly brace expansion</technical_language>

Target:
private Property resolveApiAnnotated(ModelConverterContext context, Property property, Annotation[] annotations, ApiModelProperty mp, JavaType propType) { String or = mp.dataType(); JavaType innerJavaType = null; log.debug("overriding datatype from to {}", propType, or); if (or.toLowerCase().startsWith("list[")) { String innerType = or.substring(5, or.length() - 1); ArrayProperty p = new ArrayProperty(); Property primitiveProperty = PrimitiveType.createProperty(innerType); if (primitiveProperty != null) { p.setItems(primitiveProperty); } else { innerJavaType = getInnerType(innerType); p.setItems(context.resolveProperty(innerJavaType, annotations)); } property = p; } else if (or.toLowerCase().startsWith("map[")) { int pos = or.indexOf(","); if (pos > 0) { String innerType = or.substring(pos + 1, or.length() - 1); MapProperty p = new MapProperty(); Property primitiveProperty = PrimitiveType.createProperty(innerType); if (primitiveProperty != null) { p.setAdditionalProperties(primitiveProperty); } else { innerJavaType = getInnerType(innerType); p.setAdditionalProperties(context.resolveProperty(innerJavaType, annotations)); } property = p; } } else { Property primitiveProperty = PrimitiveType.createProperty(or); if (primitiveProperty != null) { property = primitiveProperty; } else { innerJavaType = getInnerType(or); property = context.resolveProperty(innerJavaType, annotations); } } if (innerJavaType != null) { context.resolve(innerJavaType); } return property; }
Source:
<code>public void recognizeCustomFormLabeledDataWithNullModelId(HttpClient httpClient, FormRecognizerServiceVersion serviceVersion) { client = getFormRecognizerAsyncClient(httpClient, serviceVersion); customFormDataRunner(data -> beginTrainingLabeledRunner((trainingFilesUrl, useTrainingLabels) -> { <START> SyncPoller<OperationResult, CustomFormModel> syncPoller = <END> getFormTrainingAsyncClient(httpClient, serviceVersion).beginTraining(trainingFilesUrl, useTrainingLabels).getSyncPoller(); syncPoller.waitForCompletion(); Exception ex = assertThrows(RuntimeException.class, () -> client.beginRecognizeCustomForms(toFluxByteBuffer(data), null, CUSTOM_FORM_FILE_LENGTH, FormContentType.APPLICATION_PDF, true, null) .getSyncPoller()); assertEquals(EXPECTED_MODEL_ID_IS_REQUIRED_EXCEPTION_MESSAGE, ex.getMessage()); })); }</code><technical_language>need train if test is check for null model Id</technical_language>

Target:
public void recognizeCustomFormLabeledDataWithNullModelId(HttpClient httpClient, FormRecognizerServiceVersion serviceVersion) { client = getFormRecognizerAsyncClient(httpClient, serviceVersion); customFormDataRunner((data, dataLength) -> { Exception ex = assertThrows(RuntimeException.class, () -> client.beginRecognizeCustomForms( new RecognizeCustomFormsOptions(toFluxByteBuffer(data), dataLength, null).setFormContentType(FormContentType.APPLICATION_PDF).setIncludeTextContent(true) .setPollInterval(durationTestMode)).getSyncPoller()); assertEquals(EXPECTED_MODEL_ID_IS_REQUIRED_EXCEPTION_MESSAGE, ex.getMessage()); }); }
Source:
<code>public ResourceTypeHelper() { mMimeMatcher = new MimeMatcher<Page.ResourceType>(); mMimeMatcher.addRule("text/css", Page.ResourceType.STYLESHEET); mMimeMatcher.addRule("image/*", Page.ResourceType.IMAGE); mMimeMatcher.addRule("application/x-javascript", Page.ResourceType.SCRIPT); mMimeMatcher.addRule("text/javascript", Page.ResourceType.XHR); mMimeMatcher.addRule("application/json", Page.ResourceType.XHR); mMimeMatcher.addRule( DownloadingAsyncPrettyPrinterFactory.PrettyPrinterDisplayType.JSON.getDisplayType(), Page.ResourceType.XHR); mMimeMatcher.addRule("text/*", Page.ResourceType.DOCUMENT); mMimeMatcher.addRule( <START> DownloadingAsyncPrettyPrinterFactory.PrettyPrinterDisplayType.HTML.getDisplayType(), <END> Page.ResourceType.DOCUMENT); mMimeMatcher.addRule( DownloadingAsyncPrettyPrinterFactory.PrettyPrinterDisplayType.TEXT.getDisplayType(), Page.ResourceType.DOCUMENT); mMimeMatcher.addRule("*", Page.ResourceType.OTHER); }</code><technical_language>_VERY_ bad collusion unrelated types! careful mix abstractions folks surprised unrelated layers suddenly mixing together. In this case, want adapter simply convert PrettyPrinterDisplayType values Page.ResourceType. ResourceTypeHelper explicitly designed convert MIME types Page.ResourceType. recommend putting this adapter in PrettyPrinterDisplayType itself, a getResourceType method instead of getDisplayType method today</technical_language>

Target:
public ResourceTypeHelper() { mMimeMatcher = new MimeMatcher<Page.ResourceType>(); mMimeMatcher.addRule("text/css", Page.ResourceType.STYLESHEET); mMimeMatcher.addRule("image/*", Page.ResourceType.IMAGE); mMimeMatcher.addRule("application/x-javascript", Page.ResourceType.SCRIPT); mMimeMatcher.addRule("text/javascript", Page.ResourceType.XHR); mMimeMatcher.addRule("application/json", Page.ResourceType.XHR); mMimeMatcher.addRule("text/*", Page.ResourceType.DOCUMENT); mMimeMatcher.addRule("*", Page.ResourceType.OTHER); }
Source:
<code><START> public void visitClass(ClassTree tree) { <END> for (AnnotationTree annotationTree : Iterables.filter(tree.modifiers().annotations(), ANNOTATION_TREE_PREDICATE)) { if (ClassParserUtils.is(annotationTree, Connector.class)) { verifyConnector(tree, (IdentifierTree) annotationTree.annotationType()); } } super.visitClass(tree); }</code><technical_language>This needs undone, next class a separate one</technical_language>

Target:
public final void visitClass(ClassTree tree) { for (AnnotationTree annotationTree : Iterables.filter(tree.modifiers().annotations(), ANNOTATION_TREE_PREDICATE)) { if (ClassParserUtils.is(annotationTree, Connector.class)) { verifyConnector(tree, (IdentifierTree) annotationTree.annotationType()); } } super.visitClass(tree); }
Source:
<code>public void testNoChannelId() { final Intent intent = new Intent(); intent.putExtra("mp_message", "MESSAGE"); Notification notification = mpPushSpy.createNotification(intent); <START> verify(builderSpy).setChannelId(anyString()); <END> assertEquals(notification.getChannelId(), MixpanelPushNotification.NotificationData.DEFAULT_CHANNEL_ID); }</code><technical_language>more specific verify setChannelId(MixpanelPushNotification.NotificationData.DEFAULT_CHANNEL_ID)</technical_language>

Target:
public void testNoChannelId() { final Intent intent = new Intent(); intent.putExtra("mp_message", "MESSAGE"); Notification notification = mpPushSpy.createNotification(intent); verify(builderSpy).setChannelId(MixpanelPushNotification.NotificationData.DEFAULT_CHANNEL_ID); assertEquals(notification.getChannelId(), MixpanelPushNotification.NotificationData.DEFAULT_CHANNEL_ID); }
Source:
<code>public Map<Integer, ?> getValues() { <START> return Collections.unmodifiableMap(instances); <END> }</code><technical_language>This changed, this is for compatibility. getInstances added for this purpose. (maybe end remove it, I prefer if for now)</technical_language>

Target:
public Map<Integer, ?> getValues() { Map<Integer, Object> val = new HashMap<>(); for (Entry<Integer, LwM2mResourceInstance> entry : instances.entrySet()) { val.put(entry.getKey(), entry.getValue().getValue()); } return Collections.unmodifiableMap(val); }
Source:
<code>public void testMethodInvalidInboundName() throws Exception { try { SpringApplication.run(TestMethodInvalidInboundName.class, "--server.port=0"); fail("Exception expected on using invalid inbound name"); <START> } <END> catch (Exception e) { assertThat(e.getCause()).isInstanceOf(IllegalStateException.class); assertThat(e.getCause()).hasMessageContaining(INVALID_BOUND_TARGET_NAME); } }</code><technical_language>do need this change</technical_language>

Target:
public void testMethodInvalidInboundName() throws Exception { try { SpringApplication.run(TestMethodInvalidInboundName.class, "--server.port=0"); fail("Exception expected on using invalid inbound name"); } catch (BeanCreationException e) { assertThat(e.getCause()).isInstanceOf(IllegalArgumentException.class); assertThat(e.getCause()).hasMessageContaining(StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS); } }
Source:
<code>public void should_use_infopath_if_location_param_is_not_defined() throws Exception { <START> when(req.getMethod()).thenReturn("GET"); <END> when(req.getParameter("location")).thenReturn(null); when(req.getPathInfo()).thenReturn("/bonita.css"); final String resourceLocation = resourceLocationReader.getResourceLocationFromRequest(req); verify(req, times(1)).getPathInfo(); assertThat(resourceLocation).isEqualTo("bonita.css"); }</code><technical_language>I need stub</technical_language>

Target:
public void should_use_infopath_if_location_param_is_not_defined() throws Exception { when(req.getParameter("location")).thenReturn(null); when(req.getPathInfo()).thenReturn("/bonita.css"); final String resourceLocation = resourceLocationReader.getResourceLocationFromRequest(req); verify(req, times(1)).getPathInfo(); assertThat(resourceLocation).isEqualTo("bonita.css"); }
Source:
<code>public static int determineModularClasspathProperty(IClasspathEntry entry) { return Arrays.stream(entry.getExtraAttributes()) <START> .anyMatch(p -> p.getName().equals(IClasspathAttribute.MODULE) && p.getValue().equals("true")) <END> ? IRuntimeClasspathEntry.MODULE_PATH : IRuntimeClasspathEntry.CLASS_PATH; }</code><technical_language>"true".equals(p.getValue()) if getValue() yield null</technical_language>

Target:
public static int determineModularClasspathProperty(IClasspathEntry entry) { return Arrays.stream(entry.getExtraAttributes()) .anyMatch(p -> p.getName().equals(IClasspathAttribute.MODULE) && "true".equals(p.getValue())) ? IRuntimeClasspathEntry.MODULE_PATH : IRuntimeClasspathEntry.CLASS_PATH; }
Source:
<code>public void setMainTabSelectedItem(VDS selectedItem) { hostInterfaceForm = new HostInterfaceForm(getDetailModel()); contentPanel.remove(contentPanel.getWidgetCount() - 1); contentPanel.add(hostInterfaceForm); <START> contentPanel.getParent().getElement().getStyle().setOverflowX(Overflow.AUTO); <END> }</code><technical_language>This work if put in constructor initWidget(), it? invoked selection of a main tab item</technical_language>

Target:
public void setMainTabSelectedItem(VDS selectedItem) { hostInterfaceForm = new HostInterfaceForm(getDetailModel()); contentPanel.remove(contentPanel.getWidgetCount() - 1); contentPanel.add(hostInterfaceForm); if (contentPanel.getParent() != null) { contentPanel.getParent().getElement().getStyle().setOverflowX(Overflow.AUTO); } }
Source:
<code>protected boolean delete(XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki(); XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); String sindex = request.getParameter(RECYCLED_DOCUMENT_ID_PARAM); String emptyBin = request.getParameter(EMPTY_RECYCLE_BIN); <START> if ("1".equals(emptyBin)) { <END> return deleteAllFromRecycleBin(context); } else if (sindex != null && xwiki.hasRecycleBin(context)) { deleteFromRecycleBin(Long.parseLong(sindex), context); return true; } else if (doc.isNew()) { sendRedirect(response, Utils.getRedirect("view", context)); return true; } else { return deleteToRecycleBin(context); } }</code><technical_language>Is a more generic do that? emptybin=true work right</technical_language>

Target:
protected boolean delete(XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki(); XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); String sindex = request.getParameter(RECYCLED_DOCUMENT_ID_PARAM); String emptyBin = request.getParameter(EMPTY_RECYCLE_BIN); if ("true".equals(emptyBin)) { return deleteAllFromRecycleBin(context); } else if (sindex != null && xwiki.hasRecycleBin(context)) { deleteFromRecycleBin(Long.parseLong(sindex), context); return true; } else if (doc.isNew()) { sendRedirect(response, Utils.getRedirect("view", context)); return true; } else { return deleteToRecycleBin(context); } }
Source:
<code>public void testListenInvalidPort() throws Exception { server.close(); try(ServerSocket occupied = new ServerSocket(0)){ occupied.setReuseAddress(false); server = vertx.createHttpServer(new HttpServerOptions().setPort(occupied.getLocalPort())); server.requestHandler(noOpHandler()).listen(onFailure(server -> testComplete())); await(); <START> } <END> }</code><technical_language>occupied server socket closed in a finally block surrounding this</technical_language>

Target:
public void testListenInvalidPort() throws Exception { server.close(); ServerSocket occupied = null; try{ occupied = new ServerSocket(0); occupied.setReuseAddress(false); server = vertx.createHttpServer(new HttpServerOptions().setPort(occupied.getLocalPort())); server.requestHandler(noOpHandler()).listen(onFailure(server -> testComplete())); await(); }finally { if( occupied != null ) { occupied.close(); } } }
Source:
<code>public void processWesCommands(final List<String> args) { if (args.isEmpty() || containsHelpRequest(args)) { launchHelp(); } else { this.wesUri = optVal(args, "--wes-url", null); this.wesAuth = optVal(args, "--wes-auth", null); if (args.contains("launch")) { out("Launching workflow using WES"); args.remove(0); launch(args); } else { WorkflowExecutionServiceApi clientWorkflowExecutionServiceApi = getWorkflowExecutionServiceApi(getWesUri(), getWesAuth()); <START> if (args.contains("status")) { <END> String workflowId = reqVal(args, "--id"); out("Getting status of WES workflow"); if (args.contains("--verbose")) { try { RunLog response = clientWorkflowExecutionServiceApi.getRunLog(workflowId); out("Verbose run status is: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { e.printStackTrace(); } } else { try { RunStatus response = clientWorkflowExecutionServiceApi.getRunStatus(workflowId); out("Brief run status is: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { e.printStackTrace(); } } } else if (args.contains("cancel")) { out("Canceling WES workflow"); String workflowId = reqVal(args, "--id"); try { RunId response = clientWorkflowExecutionServiceApi.cancelRun(workflowId); out("Cancelled run with id: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { e.printStackTrace(); } } } } }</code><technical_language>This break if args status, user call cancel for example. check a specific index of args, based expected subcommand (ex. status) be</technical_language>

Target:
public void processWesCommands(final List<String> args) { if (args.isEmpty() || containsHelpRequest(args)) { launchHelp(); } else { this.wesUri = optVal(args, "--wes-url", null); this.wesAuth = optVal(args, "--wes-auth", null); if (args.get(0).equals("launch")) { out("Launching workflow using WES"); args.remove(0); launch(args); } else { WorkflowExecutionServiceApi clientWorkflowExecutionServiceApi = getWorkflowExecutionServiceApi(getWesUri(), getWesAuth()); if (args.get(0).equals("status")) { String workflowId = reqVal(args, "--id"); out("Getting status of WES workflow"); if (args.contains("--verbose")) { try { RunLog response = clientWorkflowExecutionServiceApi.getRunLog(workflowId); out("Verbose run status is: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { LOG.error("Error getting verbose WES run status", e); } } else { try { RunStatus response = clientWorkflowExecutionServiceApi.getRunStatus(workflowId); out("Brief run status is: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { LOG.error("Error getting brief WES run status", e); } } } else if (args.get(0).equals("cancel")) { out("Canceling WES workflow"); String workflowId = reqVal(args, "--id"); try { RunId response = clientWorkflowExecutionServiceApi.cancelRun(workflowId); out("Cancelled run with id: " + response.toString()); } catch (io.swagger.wes.client.ApiException e) { LOG.error("Error canceling WES run", e); } } } } }
Source:
<code>private static String jobRefToUId(final JobRef<?> ref) { return String.format( <START> "repoType-%s--orgId-%s--jobId-%s", <END> ref.getRepositoryType().getCanonicalName(), ref.getOrganization().getId(), ref.getJobId()); }</code><technical_language>discussed; character length limits string returned? Also, wrong here, structured strings. is a fully qualified class name uuids. is opportunity for a simpler format; e.g. "%s|%s|%s"</technical_language>

Target:
private static String jobRefToUId(final JobRef<?> ref) { return String.join( "_", ref.getRepositoryType().getCanonicalName(), ref.getOrganization().getId().toString(), ref.getJobId().toString()); }
Source:
<code>private boolean findChildren(CalledFunction node, int depth, ITmfStateSystem ss, int maxQuark, IProgressMonitor monitor) { fStore.add(node); long curTime = node.getStart(); long limit = node.getEnd(); ITmfStateInterval interval = null; while (curTime < limit) { if (monitor.isCanceled()) { return false; } try { if (depth + <START> 1 <END> < fCurrentQuarks.size()) { interval = ss.querySingleState(curTime, fCurrentQuarks.get(depth + 1)); } else { return true; } } catch (StateSystemDisposedException e) { Activator.getInstance().logError(Messages.QueringStateSystemError, e); return false; } ITmfStateValue stateValue = interval.getStateValue(); if (!stateValue.isNull()) { long intervalStart = interval.getStartTime(); long intervalEnd = interval.getEndTime(); CalledFunction segment = new CalledFunction(intervalStart, intervalEnd + 1, stateValue.unboxLong(), node.getDepth() + 1); findChildren(segment, depth + 1, ss, maxQuark, monitor); node.addChild(segment); curTime = interval.getEndTime() + 1; } else { curTime = interval.getEndTime() + 1; } } return true; }</code><technical_language>this 1 mean, in a final int a more insightful name? do think</technical_language>

Target:
private boolean findChildren(CalledFunction node, int depth, ITmfStateSystem ss, int maxQuark, IProgressMonitor monitor) { fStore.add(node); long curTime = node.getStart(); long limit = node.getEnd(); ITmfStateInterval interval = null; while (curTime < limit) { if (monitor.isCanceled()) { return false; } try { if (depth + 1 < fCurrentQuarks.size()) { interval = ss.querySingleState(curTime, fCurrentQuarks.get(depth + 1)); } else { return true; } } catch (StateSystemDisposedException e) { Activator.getInstance().logError(Messages.QueringStateSystemError, e); return false; } ITmfStateValue stateValue = interval.getStateValue(); if (!stateValue.isNull()) { long intervalStart = interval.getStartTime(); long intervalEnd = interval.getEndTime(); if (intervalStart < node.getStart() || intervalEnd > limit) { return true; } CalledFunction segment = new CalledFunction(intervalStart, intervalEnd + 1, stateValue.unboxLong(), node.getDepth() + 1); findChildren(segment, depth + 1, ss, maxQuark, monitor); node.addChild(segment); } curTime = interval.getEndTime() + 1; } return true; }
Source:
<code>public Object getReplacementValue(Object initialValue) { Object replacementValue = ""; if (initialValue != null) { if (initialValue instanceof Cohort) { replacementValue = new Integer(((Cohort) initialValue).size()); } else if (initialValue instanceof IndicatorResult) { replacementValue =((IndicatorResult) initialValue).getValue(); <START> } <END> else { replacementValue = initialValue; } } return replacementValue; }</code><technical_language>concern this change is a breaking change for currently relying existing behavior. is case</technical_language>

Target:
public Object getReplacementValue(Object initialValue) { Object replacementValue = ""; if (initialValue != null) { if (initialValue instanceof Cohort) { replacementValue = new Integer(((Cohort) initialValue).size()); } else if (initialValue instanceof IndicatorResult) { IndicatorResult ir = (IndicatorResult) initialValue; replacementValue = ir.getValue(); } else { replacementValue = initialValue; } } return replacementValue; }
Source:
<code>@Test public void startActivityWithIntent() throws Exception { assertTrue(((Predicate<AndroidDriver>) driver -> { final Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity"); activity.setIntentAction("android.intent.action.SEND"); activity.setIntentCategory("android.intent.category.DEFAULT"); activity.setIntentFlags("0x4000000"); activity.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\""); driver.startActivity(activity); <START> return true; <END> }).test(driver)); }</code><technical_language>is construction _assertTrue_ _return true_ necessary</technical_language>

Target:
@Test public void startActivityWithIntent() throws Exception { Predicate<AndroidDriver> predicate = driver -> { Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity") .setIntentAction("android.intent.action.SEND") .setIntentCategory("android.intent.category.DEFAULT") .setIntentFlags("0x4000000") .setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\""); driver.startActivity(activity); return true; }; assertTrue(predicate.test(driver)); }
Source:
<code>public DialogBox createNoProjectsDialog(boolean showDialog) { final NoProjectDialogBox dialogBox = new NoProjectDialogBox(); <START> dialogBox.show(); <END> return dialogBox; }</code><technical_language>moment this results in dialog showing unconditionally. wrap this in a check showDialog code</technical_language>

Target:
public DialogBox createNoProjectsDialog(boolean showDialog) { final NoProjectDialogBox dialogBox = new NoProjectDialogBox(); if (showDialog) { dialogBox.show(); } return dialogBox; }