auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static @NonNull Iterable<ITmfEventAspect<?>> generateAspects(CustomTraceDefinition definition) { List<String> fieldNames = new ArrayList<>(); ImmutableList.Builder<ITmfEventAspect<?>> builder = new ImmutableList.Builder<>(); CustomExtraFieldsAspect extraAspect = null; for (OutputColumn output : definition.outputs) { if (output.tag.equals(Tag.TIMESTAMP) && (definition.timeStampOutputFormat == null || definition.timeStampOutputFormat.isEmpty())) { builder.add(TmfBaseAspects.getTimestampAspect()); fieldNames.add(output.name); } else if (output.tag.equals(Tag.EVENT_TYPE)) { builder.add(TmfBaseAspects.getEventTypeAspect()); fieldNames.add(output.name); } else if (output.tag.equals(Tag.EXTRA_FIELDS_NAME)) { continue; } else if (output.tag.equals(Tag.EXTRA_FIELDS_VALUE)) { <START> if (extraAspect == null) { <END> extraAspect = new CustomExtraFieldsAspect(); builder.add(extraAspect); } } else { builder.add(new TmfContentFieldAspect(output.name, output.name)); fieldNames.add(output.name); } } return builder.build(); }</code><technical_language>This is protection 'Extra fields value' in outputs list, I this is possible</technical_language>

Target:
public static @NonNull Iterable<ITmfEventAspect<?>> generateAspects(CustomTraceDefinition definition) { List<String> fieldNames = new ArrayList<>(); ImmutableList.Builder<ITmfEventAspect<?>> builder = new ImmutableList.Builder<>(); for (OutputColumn output : definition.outputs) { if (output.tag.equals(Tag.TIMESTAMP) && (definition.timeStampOutputFormat == null || definition.timeStampOutputFormat.isEmpty())) { builder.add(TmfBaseAspects.getTimestampAspect()); fieldNames.add(output.name); } else if (output.tag.equals(Tag.EVENT_TYPE)) { builder.add(TmfBaseAspects.getEventTypeAspect()); fieldNames.add(output.name); } else if (output.tag.equals(Tag.EXTRA_FIELDS_NAME)) { continue; } else if (output.tag.equals(Tag.EXTRA_FIELDS_VALUE)) { builder.add(new CustomExtraFieldsAspect()); } else { builder.add(new TmfContentFieldAspect(output.name, output.name)); fieldNames.add(output.name); } } return builder.build(); }
Source:
<code>void pause() throws InterruptedException { if (!paused.getAndSet(true)) { synchronized (lock) { logger.info("HardDelete thread has been paused "); <START> lock.notify(); <END> time.wait(lock, hardDeleterSleepTimeWhenCaughtUpMs); } } }</code><technical_language>this need done? If thread wakes in time, immediately pause variable pause right</technical_language>

Target:
void pause() throws InterruptedException, StoreException, IOException { hardDeleteLock.lock(); try { if (paused.compareAndSet(false, true)) { logger.info("HardDelete thread has been paused "); index.persistIndex(); pruneHardDeleteRecoveryRange(); persistCleanupToken(); } } finally { hardDeleteLock.unlock(); } }
Source:
<code>int getWorkersNeededToAssignTasks( final WorkerTaskRunnerConfig workerTaskRunnerConfig, final WorkerBehaviorConfig workerConfig, final Collection<Task> pendingTasks, final Collection<ImmutableWorkerInfo> workers ) { final Collection<ImmutableWorkerInfo> validWorkers = Collections2.filter( workers, ResourceManagementUtil.createValidWorkerPredicate(config) ); Map<String, ImmutableWorkerInfo> workersMap = Maps.newHashMap(); for (ImmutableWorkerInfo worker : validWorkers) { workersMap.put(worker.getWorker().getHost(), worker); } WorkerSelectStrategy workerSelectStrategy = workerConfig.getSelectStrategy(); int need = 0; int capacity = getExpectedWorkerCapacity(workers); for (Task task : pendingTasks) { Optional<ImmutableWorkerInfo> selectedWorker = workerSelectStrategy.findWorkerForTask( workerTaskRunnerConfig, ImmutableMap.copyOf(workersMap), task ); final ImmutableWorkerInfo workerRunningTask; if (selectedWorker.isPresent()) { workerRunningTask = selectedWorker.get(); } else { <START> workerRunningTask = createDummyWorker("http", "dummy" + need, capacity, workerTaskRunnerConfig.getMinWorkerVersion()); <END> need++; } workersMap.put(workerRunningTask.getWorker().getHost(), workerWithTask(workerRunningTask, task)); } return need; }</code><technical_language>hm, constants for "http" "https"</technical_language>

Target:
int getWorkersNeededToAssignTasks( final WorkerTaskRunnerConfig workerTaskRunnerConfig, final WorkerBehaviorConfig workerConfig, final Collection<Task> pendingTasks, final Collection<ImmutableWorkerInfo> workers ) { final Collection<ImmutableWorkerInfo> validWorkers = Collections2.filter( workers, ResourceManagementUtil.createValidWorkerPredicate(config) ); Map<String, ImmutableWorkerInfo> workersMap = Maps.newHashMap(); for (ImmutableWorkerInfo worker : validWorkers) { workersMap.put(worker.getWorker().getHost(), worker); } WorkerSelectStrategy workerSelectStrategy = workerConfig.getSelectStrategy(); int need = 0; int capacity = getExpectedWorkerCapacity(workers); for (Task task : pendingTasks) { Optional<ImmutableWorkerInfo> selectedWorker = workerSelectStrategy.findWorkerForTask( workerTaskRunnerConfig, ImmutableMap.copyOf(workersMap), task ); final ImmutableWorkerInfo workerRunningTask; if (selectedWorker.isPresent()) { workerRunningTask = selectedWorker.get(); } else { workerRunningTask = createDummyWorker(SCHEME, "dummy" + need, capacity, workerTaskRunnerConfig.getMinWorkerVersion()); need++; } workersMap.put(workerRunningTask.getWorker().getHost(), workerWithTask(workerRunningTask, task)); } return need; }
Source:
<code>public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); <START> if (!getParameters().getRunAsStateless()) { <END> for (DiskImage image : getVm().getDiskList()) { list.add(new QuotaStorageConsumptionParameter(image.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, image.getstorage_ids().get(0), image.getActualSize())); } } return list; }</code><technical_language>erased a lot of logic, please explain ? secondly, IIRC getParameters().getRunAsStateless() is Boolean a bug in REST null, please check for null</technical_language>

Target:
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); if (Boolean.TRUE.equals(getParameters().getRunAsStateless())) { for (DiskImage image : getVm().getDiskList()) { list.add(new QuotaStorageConsumptionParameter(image.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, image.getstorage_ids().get(0), image.getActualSize())); } } return list; }
Source:
<code>private Window find(T value) { retry: while (true) { Node previous = head; Node current = previous.next.getReference(); Node successor; while (true) { successor = current.next.getReference(); if (current.next.isMarked()) { if (!previous.next.compareAndSet(current, successor, false, false)) { <START> continue retry; <END> } current = successor; } else { if (current.value == null || current.value.compareTo(value) > 0) { return new Window(previous, current); } previous = current; current = successor; } } } }</code><technical_language>break</technical_language>

Target:
private Window find(T value) { while (true) { Node previous = head; Node current = previous.next.getReference(); Node successor; while (true) { if (current == null) { return new Window(previous, null); } successor = current.next.getReference(); if (current.next.isMarked()) { if (!previous.next.compareAndSet(current, successor, false, false)) { break; } current = successor; } else { if (current.value.compareTo(value) > 0) { return new Window(previous, current); } previous = current; current = successor; } } } }
Source:
<code>protected PlaceRequest getMainTabRequest() { <START> logger.info(this.getClass().toString() + " getMainTabRequest"); END> return PlaceRequestFactory.get(WebAdminApplicationPlaces.errataMainTabPlace); }</code><technical_language>this debug/trace, all</technical_language>

Target:
protected PlaceRequest getMainTabRequest() { return PlaceRequestFactory.get(WebAdminApplicationPlaces.errataMainTabPlace); }
Source:
<code>private ObjectName createObjectName(String cacheName, URI cacheManagerURI, String beanName) { <START> String cacheManagerName = sanitize(cacheManagerURI != null ? cacheManagerURI.toString() : "null"); <END> cacheName = sanitize(cacheName != null ? cacheName : "null"); try { return new ObjectName("javax.cache:type=" + beanName + ",CacheManager=" + cacheManagerName + ",Cache=" + cacheName); } catch (MalformedObjectNameException e) { throw new CacheException(e); } }</code><technical_language>I wondering. cache manager URI null? a precondition isn't</technical_language>

Target:
private ObjectName createObjectName(String cacheName, URI cacheManagerURI, String beanName) { String cacheManagerName = sanitize(cacheManagerURI.toString()); cacheName = sanitize(cacheName); try { return new ObjectName("javax.cache:type=" + beanName + ",CacheManager=" + cacheManagerName + ",Cache=" + cacheName); } catch (MalformedObjectNameException e) { throw new CacheException(e); } }
Source:
<code>public URI getUri() { <START> return getRequest().url().uri(); <END> }</code><technical_language>wasteful calling getRequest() in methods. Consider in original Request storing in a field mutable result of newBuilder()</technical_language>

Target:
public URI getUri() { return request.url().uri(); }
Source:
<code>public void testOneOfDisabled() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); <START> final Map<Resource, Set<Resource>> enumerations = new HashMap<>(); <END> enumerations.put(SUITS, CARD_SUIT_ENUMERATION); when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true); when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION); enumerations.put(RANKS, CARD_RANK_ENUMERATION); when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true); when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION); final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); final AccumuloRdfConfiguration disabledConf = conf.clone(); disabledConf.setInferOneOf(false); query.visit(new OneOfVisitor(disabledConf, inferenceEngine)); assertTrue(query.getArg() instanceof StatementPattern); final StatementPattern actualCardSuitSp = (StatementPattern) query.getArg(); final StatementPattern expectedCardSuitSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)); assertEquals(expectedCardSuitSp, actualCardSuitSp); }</code><technical_language>this is</technical_language>

Target:
public void testOneOfDisabled() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true); when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION); when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true); when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION); final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); final AccumuloRdfConfiguration disabledConf = conf.clone(); disabledConf.setInferOneOf(false); query.visit(new OneOfVisitor(disabledConf, inferenceEngine)); assertTrue(query.getArg() instanceof StatementPattern); final StatementPattern actualCardSuitSp = (StatementPattern) query.getArg(); final StatementPattern expectedCardSuitSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)); assertEquals(expectedCardSuitSp, actualCardSuitSp); }
Source:
<code>public List<ScriptSequenceAction> addActionToSequence(Sprite sprite, ScriptSequenceAction sequence) { Sprite backgroundSprite = ProjectManager.getInstance().getCurrentlyPlayingScene().getBackgroundSprite(); sequence.addAction(sprite.getActionFactory() .createSetLookByIndexAction(backgroundSprite, getFormulaWithBrickField(BrickField.LOOK_INDEX), wait)); <START> <END> return Collections.emptyList(); }</code><technical_language>backgroundSprite sprite returned getSprite()? :thinking:</technical_language>

Target:
public List<ScriptSequenceAction> addActionToSequence(Sprite sprite, ScriptSequenceAction sequence) { sequence.addAction(sprite.getActionFactory() .createSetLookByIndexAction(getSprite(), getFormulaWithBrickField(BrickField.LOOK_INDEX), wait)); return Collections.emptyList(); }
Source:
<code>public BindingElementTree BINDING_PROPERTY() { return b.<BindingElementTree>nonterminal() .is(b.firstOf( <START> REST_OBJECT_BINDING_ELEMENT(), <END> f.bindingProperty(PROPERTY_NAME(), b.token(JavaScriptPunctuator.COLON), BINDING_ELEMENT()), BINDING_ELEMENT())); }</code><technical_language>@vilchik-elena a bug in babel</technical_language>

Target:
public BindingElementTree BINDING_PROPERTY() { return b.<BindingElementTree>nonterminal() .is(b.firstOf( f.bindingProperty(PROPERTY_NAME(), b.token(JavaScriptPunctuator.COLON), BINDING_ELEMENT()), BINDING_ELEMENT())); }
Source:
<code>public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalArgumentException( "BatchPropertyBeanPostProcessor requires a ConfigurableListableBeanFactory"); } this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; <START> this.beanExpressionContext = new BeanExpressionContext(this.beanFactory, new StepScope()); <END> }</code><technical_language>is StepScope newed here? passing in existing (assuming pull instance beanFactory...)</technical_language>

Target:
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalArgumentException( "BatchPropertyBeanPostProcessor requires a ConfigurableListableBeanFactory"); } this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; this.beanExpressionContext = new BeanExpressionContext(this.beanFactory, this.beanFactory.getBean(StepScope.class)); }
Source:
<code><START> private int getMaxNumOfDayForMonth(int month, int year){ <END> int days = 0; switch (month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = 31; break; case 4: case 6: case 9: case 11: days = 30; break; case 2: if( ((year % 4) == 0 && (year % 100) != 0) || (year % 400) == 0){ days = 29; } else { days = 28; } break; default: days = 0; }; return days; }</code><technical_language>If Java built-in libraries for this, external library jodatime natty</technical_language>

Target:
private int getMaxNumOfDayForMonth(int month, int year){ DateTime dateTime = new DateTime(year, month, 1, 0, 0, 0, 000); return dateTime.dayOfMonth().getMaximumValue(); }
Source:
<code>private <T extends CatalogType> SpongeCatalogRegistry registerCallbackRegistry(Class<T> catalogClass, CatalogKey key, BiConsumer<ResourceLocation, T> callback) { checkNotNull(catalogClass); checkNotNull(key); <START> if (this.registries.get(key) != null) { <END> throw new DuplicateRegistrationException(String.format("Catalog '%s' already has a registry registered!", catalogClass)); } final CallbackRegistry<T> registry = new CallbackRegistry<T>(callback); this.registries.put(key, (Registry<CatalogType>) registry); this.registriesByType.put((Class<CatalogType>) catalogClass, (Registry<CatalogType>) registry); return this; }</code><technical_language>Replace get + put computeIfAbsent</technical_language>

Target:
private <T extends CatalogType> SpongeCatalogRegistry registerCallbackRegistry(Class<T> catalogClass, CatalogKey key, BiConsumer<ResourceLocation, T> callback) { checkNotNull(catalogClass); checkNotNull(key); final Registry<CatalogType> registry = this.registries.putIfAbsent(key, (Registry<CatalogType>) new CallbackRegistry<>(callback)); if (registry != null) { throw new DuplicateRegistrationException(String.format("Catalog '%s' already has a registry registered!", catalogClass)); } this.registriesByType.put((Class<CatalogType>) catalogClass, registry); return this; }
Source:
<code>public ArixmethesSlumberingIsle(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.KRAKEN); this.power = new MageInt(12); this.toughness = new MageInt(12); Effect effect = new AddCountersSourceEffect(CounterType.SLUMBER.createInstance(5)); <START> this.addAbility(new EntersBattlefieldAbility(effect, "with five slumber counters")); <END> this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect( new ArixmethesIsLandEffect(), new SourceHasCounterCondition(CounterType.SLUMBER, 1, Integer.MAX_VALUE), "As long as {this} has a slumber counter on it, it's a land"))); this.addAbility(new SpellCastControllerTriggeredAbility(new RemoveCounterSourceEffect(CounterType.SLUMBER.createInstance(1)), new FilterSpell("a spell"), true)); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new Mana(0, 1, 1, 0, 0, 0, 0, 0), new TapSourceCost())); }</code><technical_language>needs enter tapped,</technical_language>

Target:
public ArixmethesSlumberingIsle(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.KRAKEN); this.power = new MageInt(12); this.toughness = new MageInt(12); this.addAbility(new EntersBattlefieldTappedAbility()); Effect effect = new AddCountersSourceEffect(CounterType.SLUMBER.createInstance(5)); this.addAbility(new EntersBattlefieldAbility(effect, "with five slumber counters")); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect( new ArixmethesIsLandEffect(), new SourceHasCounterCondition(CounterType.SLUMBER, 1, Integer.MAX_VALUE), "As long as {this} has a slumber counter on it, it's a land"))); this.addAbility(new SpellCastControllerTriggeredAbility(new RemoveCounterSourceEffect(CounterType.SLUMBER.createInstance(1)), true)); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new Mana(0, 1, 1, 0, 0, 0, 0, 0), new TapSourceCost())); }
Source:
<code>public void shouldDeleteCondition() { Condition condition = dao.getConditionByUuid("2cc6880e-2a46-11e4-9038-a6c5e4d26fb7"); Condition deletedCondition = dao.deleteCondition(condition); <START> assertEquals(deletedCondition, null); <END> }</code><technical_language>this test passes</technical_language>

Target:
public void shouldDeleteCondition() { String uuid = "2cc6880e-2c46-15e4-9038-a6c5e4d22fb7"; Condition condition = dao.getConditionByUuid(uuid); Assert.assertNotNull(condition); dao.deleteCondition(condition); Assert.assertNull(dao.getConditionByUuid(uuid)); }
Source:
<code>protected void addQuestionText(final FormEntryPrompt p) { String markdownText = p.getMarkdownText(); String imageURI = p.getImageText(); String audioURI = p.getAudioText(); String videoURI = p.getSpecialFormQuestionText("video"); String qrCodeContent = p.getSpecialFormQuestionText("qrcode"); String bigImageURI = p.getSpecialFormQuestionText("big-image"); mQuestionText = new TextView(getContext()); mQuestionText.setId(38475483); if(markdownText != null){ mQuestionText.setText(MarkupUtil.styleSpannable(getContext(), markdownText)); mQuestionText.setMovementMethod(LinkMovementMethod.getInstance()); } else { mQuestionText.setText(p.getLongText()); <START> mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize); <END> mQuestionText.setTypeface(null, Typeface.BOLD); mQuestionText.setPadding(0, 0, 0, 7); } mQuestionText.setHorizontallyScrolling(false); if(p.getLongText()!= null){ if(p.getLongText().contains("\u260E")){ if(Linkify.addLinks(mQuestionText,Linkify.PHONE_NUMBERS)){ stripUnderlines(mQuestionText); } else{ System.out.println("this should be an error I'm thinking?"); } } } if (p.getLongText() == null) { mQuestionText.setVisibility(GONE); } MediaLayout mediaLayout = new MediaLayout(getContext()) { protected void onHelpPressed() { fireHelpText(p); } }; String helpText = p.getSpecialFormQuestionText("help"); if("help".equals(helpText)) { videoURI = helpText; } mediaLayout.setAVT(mQuestionText, audioURI, imageURI, videoURI, bigImageURI, qrCodeContent); addView(mediaLayout, mLayout); }</code><technical_language>default markdown text size match this? Is a case if not</technical_language>

Target:
protected void addQuestionText(final FormEntryPrompt p) { String imageURI = p.getImageText(); String audioURI = p.getAudioText(); String videoURI = p.getSpecialFormQuestionText("video"); String qrCodeContent = p.getSpecialFormQuestionText("qrcode"); String markdownText = p.getMarkdownText(); String bigImageURI = p.getSpecialFormQuestionText("big-image"); mQuestionText = new TextView(getContext()); mQuestionText.setId(38475483); if(markdownText != null){ mQuestionText.setText(forceMarkdown(markdownText)); mQuestionText.setMovementMethod(LinkMovementMethod.getInstance()); mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize); mQuestionText.setHorizontallyScrolling(false); } else { mQuestionText.setText(p.getLongText()); mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize); mQuestionText.setTypeface(null, Typeface.BOLD); mQuestionText.setPadding(0, 0, 0, 7); } if(p.getLongText()!= null){ if(p.getLongText().contains("\u260E")){ if(Linkify.addLinks(mQuestionText,Linkify.PHONE_NUMBERS)){ stripUnderlines(mQuestionText); } else{ System.out.println("this should be an error I'm thinking?"); } } } mQuestionText.setHorizontallyScrolling(false); if (p.getLongText() == null) { mQuestionText.setVisibility(GONE); } MediaLayout mediaLayout = new MediaLayout(getContext()); mediaLayout.setAVT(mQuestionText, audioURI, imageURI, videoURI, bigImageURI, qrCodeContent); addView(mediaLayout, mLayout); }
Source:
<code>private void record(TimingContext timingContext, Exchange ex) { Set<Timed> annotations = timedAnnotationProvider.getTimedAnnotations(ex); Timer.Sample timerSample = timingContext.getTimerSample(); Supplier<Iterable<Tag>> tags = () -> { Iterable<Tag> defaultTags = this.tagsProvider.getTags(ex); List<Tag> additionalTags = new ArrayList<>(); tagsCustomizers .forEach(tagsCustomizer -> tagsCustomizer.getAdditionalTags(ex).forEach(additionalTags::add)); <START> return Iterables.concat(defaultTags, additionalTags); <END> }; if (annotations.isEmpty()) { if (this.autoTimeRequests) { stop(timerSample, tags, Timer.builder(this.metricName)); } } else { for (Timed annotation : annotations) { stop(timerSample, tags, Timer.builder(annotation, this.metricName)); } } }</code><technical_language>Bringing Guava for Iterables much, please rewrite standard library? Fe: return () -> Stream.concat( StreamSupport.stream(defaultTags.spliterator(), false), StreamSupport.stream(additionalTags.spliterator(), false)) .iterator();</technical_language>

Target:
private void record(TimingContext timingContext, Exchange ex) { Set<Timed> annotations = timedAnnotationProvider.getTimedAnnotations(ex); Timer.Sample timerSample = timingContext.getTimerSample(); Supplier<Iterable<Tag>> tags = () -> getAllTags(ex); if (annotations.isEmpty()) { if (this.autoTimeRequests) { stop(timerSample, tags, Timer.builder(this.metricName)); } } else { for (Timed annotation : annotations) { stop(timerSample, tags, Timer.builder(annotation, this.metricName)); } } }
Source:
<code><START> private boolean deleteConfigObject(long uuid, String comment, IArtifactType type) { <END> boolean toReturn = false; ArtifactReadable toDelete = atsServer.getArtifactByUuid(uuid); if (toDelete != null) { if (!toDelete.getArtifactType().equals(type)) { throw new OseeCoreException("Artifact type does not match for %s", comment); } TransactionBuilder transaction = atsServer.getOrcsApi().getTransactionFactory().createTransaction(AtsUtilCore.getAtsBranch(), toDelete, comment); transaction.deleteArtifact(toDelete); transaction.commit(); toReturn = true; } return toReturn; }</code><technical_language>need boolean if throwing exceptions input is invalid</technical_language>

Target:
private void deleteConfigObject(long uuid, String comment, IArtifactType type) { ArtifactReadable toDelete = atsServer.getArtifactByUuid(uuid); if (toDelete == null) { throw new OseeCoreException("No object found for uuid %d", uuid); } if (!toDelete.getArtifactType().equals(type)) { throw new OseeCoreException("Artifact type does not match for %s", comment); } TransactionBuilder transaction = atsServer.getOrcsApi().getTransactionFactory().createTransaction(AtsUtilCore.getAtsBranch(), toDelete, comment); transaction.deleteArtifact(toDelete); transaction.commit(); }
Source:
<code>public boolean addBatch(String autocompleteSection, String... items) throws ConstructorException { ConstructorItem[] citems = new ConstructorItem[items.length]; for (int i = 0; i < items.length; i++) citems[i] = new ConstructorItem(items[i]); <START> return addOrUpdateBatch(autocompleteSection, citems); <END> }</code><technical_language>This addBatch, right</technical_language>

Target:
public boolean addBatch(String autocompleteSection, String... items) throws ConstructorException { ConstructorItem[] citems = new ConstructorItem[items.length]; for (int i = 0; i < items.length; i++) citems[i] = new ConstructorItem(items[i]); return addBatch(autocompleteSection, citems); }
Source:
<code>private boolean insertHasDoNotSet(ExecutableElement v, boolean explicitSet) { Insert annotation = v.getAnnotation(Insert.class); if (annotation != null) { if (explicitSet) { return annotation.nullSavingStrategy() == NullSavingStrategy.DO_NOT_SET && nullSavingStrategyExplicitlySet(v, Insert.class); } else { return annotation.nullSavingStrategy() == NullSavingStrategy.DO_NOT_SET; } <START> } else { <END> return false; } }</code><technical_language>here, HasSetToNullExplicitly methods factored a common method</technical_language>

Target:
private boolean insertHasDoNotSet(ExecutableElement v, boolean explicitSet) { return hasDoNotSet(Insert.class, Insert::nullSavingStrategy, v, explicitSet); }
Source:
<code>private List<Flight> searchByDate(SearchParams searchParams) { try { allFlights = dao.getAllFlights(); } catch (SQLException e) { <START> e.printStackTrace(); <END> } searchParams.setSearchYear(Integer.parseInt(searchParams.getDate().substring(0, 4))); searchParams.setSearchMonth(Integer.parseInt(searchParams.getDate().substring(4, 6))); searchParams.setSearchDay(Integer.parseInt(searchParams.getDate().substring(6, 8))); for(int i=0; i < allFlights.size(); i++ ) { searchParams.setSearchDate(allFlights.get(i).getDate()); searchParams.setSearchYear(Integer.parseInt(searchParams.getSearchDate().substring(0, 4))); searchParams.setSearchMonth(Integer.parseInt(searchParams.getSearchDate().substring(4, 6))); searchParams.setSearchDay(Integer.parseInt(searchParams.getSearchDate().substring(6, 8))); if(searchParams.getSearchYear() == searchParams.getYear()){ if(searchParams.getSearchMonth() == searchParams.getMonth()){ if(searchParams.getSearchDay() == searchParams.getDay()){ searchFlights.add(allFlights.get(i)); } } } } return searchFlights; }</code><technical_language>do more print stack trace if this fails. Returning null wrong. Also, System.out.println() a useful message good output wrong</technical_language>

Target:
private List<Flight> searchByDate(SearchParams searchParams) throws ParseException { try { allFlights = dao.getAllFlights(); } catch (SQLException e) { e.printStackTrace(); } searchParams.setSearchYear(Integer.parseInt(searchParams.getDate().substring(0, 4))); searchParams.setSearchMonth(Integer.parseInt(searchParams.getDate().substring(4, 6))); searchParams.setSearchDay(Integer.parseInt(searchParams.getDate().substring(6, 8))); for(int i=0; i < allFlights.size(); i++ ) { searchParams.setSearchDate(allFlights.get(i).getDate()); searchParams.setSearchYear(Integer.parseInt(searchParams.getSearchDate().substring(0, 4))); searchParams.setSearchMonth(Integer.parseInt(searchParams.getSearchDate().substring(4, 6))); searchParams.setSearchDay(Integer.parseInt(searchParams.getSearchDate().substring(6, 8))); if(searchParams.getSearchYear() == searchParams.getYear()){ if(searchParams.getSearchMonth() == searchParams.getMonth()){ if(searchParams.getSearchDay() == searchParams.getDay()){ searchFlights.add(allFlights.get(i)); } } } } return searchFlights; }
Source:
<code>public void testStartpointSpecificOffsetVisitorShouldUpdateTheFetchOffsetInConsumer() { <START> final Integer testPartitionId = 0; <END> final String offset = "0"; final TopicPartition testTopicPartition = new TopicPartition(TEST_STREAM, testPartitionId); final Partition testPartition = new Partition(testPartitionId); final SystemStreamPartition testSystemStreamPartition = new SystemStreamPartition(TEST_SYSTEM, TEST_STREAM, testPartition); final KafkaConsumer consumer = Mockito.mock(KafkaConsumer.class); KafkaStartpointRegistrationHandler kafkaStartpointRegistrationHandler = new KafkaSystemConsumer.KafkaStartpointRegistrationHandler(consumer); final StartpointSpecific testStartpointSpecific = new StartpointSpecific(offset); Mockito.doNothing().when(consumer).seek(testTopicPartition, Long.valueOf(offset)); kafkaStartpointRegistrationHandler.visit(testSystemStreamPartition, testStartpointSpecific); Mockito.verify(consumer).seek(testTopicPartition, Long.valueOf(offset)); }</code><technical_language>extract some of dummy variables static variables in test class, shared other visitor tests</technical_language>

Target:
public void testStartpointSpecificOffsetVisitorShouldUpdateTheFetchOffsetInConsumer() { final KafkaConsumer consumer = Mockito.mock(KafkaConsumer.class); final KafkaConsumerProxy kafkaConsumerProxy = Mockito.mock(KafkaConsumerProxy.class); final KafkaStartpointRegistrationHandler kafkaStartpointRegistrationHandler = new KafkaStartpointRegistrationHandler(consumer, kafkaConsumerProxy); final StartpointSpecific testStartpointSpecific = new StartpointSpecific(TEST_OFFSET); Mockito.doNothing().when(consumer).seek(TEST_TOPIC_PARTITION, Long.valueOf(TEST_OFFSET)); Mockito.when(consumer.position(TEST_TOPIC_PARTITION)).thenReturn(Long.valueOf(TEST_OFFSET)); kafkaStartpointRegistrationHandler.visit(TEST_SYSTEM_STREAM_PARTITION, testStartpointSpecific); Mockito.verify(consumer).seek(TEST_TOPIC_PARTITION, Long.valueOf(TEST_OFFSET)); Mockito.verify(kafkaConsumerProxy).addTopicPartition(TEST_SYSTEM_STREAM_PARTITION, Long.valueOf(TEST_OFFSET)); }
Source:
<code>public static IInputValidator getRefNameInputValidator( final Repository repo, final String refPrefix, final boolean errorOnEmptyName) { return new IInputValidator() { @Override public String isValid(String newText) { IStatus validationStatus = validateNewRefName(newText, repo, refPrefix, errorOnEmptyName); if (validationStatus.isOK()) { return null; } if (validationStatus.getException() != null) { <START> Activator.logError(validationStatus.getMessage(), validationStatus.getException()); <END> } return validationStatus.getMessage(); } }; }</code><technical_language>a Status here. add a new Activator.handleIssue(IStatus status, boolean show) call Activator.handleIssue(validationStatus, false);</technical_language>

Target:
public static IInputValidator getRefNameInputValidator( final Repository repo, final String refPrefix, final boolean errorOnEmptyName) { return new IInputValidator() { @Override public String isValid(String newText) { IStatus validationStatus = validateNewRefName(newText, repo, refPrefix, errorOnEmptyName); if (validationStatus.isOK()) { return null; } if (validationStatus.getException() != null) { Activator.handleStatus(validationStatus, false); } return validationStatus.getMessage(); } }; }
Source:
<code>public Location findResourcesByFqn(String fqn, int lineNumber) { Type type = new TypeToken<List<String>>() {}.getType(); List<String> location = doGetList( Commands.FIND_RESOURCES_BY_FQN, ImmutableList.of(fqn, String.valueOf(lineNumber)), type); if (location.isEmpty()) { throw new RuntimeException("Type with fully qualified name: " + fqn + " was not found"); } String l = location.get(0); if (l.startsWith("jdt:/")) { return new LocationImpl(l, lineNumber, true, l, null); } else { <START> return new LocationImpl(removePrefixUri(l), lineNumber, null); <END> } }</code><technical_language>call "removePrefixURI" uri, a no-op for uri's do start workspace location</technical_language>

Target:
public Location findResourcesByFqn(String fqn, int lineNumber) { Type type = new TypeToken<List<String>>() {}.getType(); List<String> location = doGetList( Commands.FIND_RESOURCES_BY_FQN, ImmutableList.of(fqn, String.valueOf(lineNumber)), type); if (location.isEmpty()) { throw new RuntimeException("Type with fully qualified name: " + fqn + " was not found"); } String l = location.get(0); if (l.startsWith("jdt:/")) { return new LocationImpl(removePrefixUri(l), lineNumber, true, l, null); } else { return new LocationImpl(removePrefixUri(l), lineNumber, null); } }
Source:
<code>private static void sendQueryRequest(String xqFile, QueryRequest request, VXQuery cli) { URI uri = null; try { uri = RestUtils.buildQueryURI(request, cli.restIpAddress, cli.restPort); } catch (URISyntaxException e) { System.err.println(String.format("Unable to build URI to call REST API for query: %s", request.getStatement())); cli.onQueryFailure(xqFile, null); } <START> CloseableHttpClient httpClient = HttpClients.custom() <END> .setConnectionTimeToLive(20, TimeUnit.SECONDS) .build(); try { HttpGet httpGet = new HttpGet(uri); httpGet.setHeader(HttpHeaders.ACCEPT, CONTENT_TYPE_JSON); try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { HttpEntity entity = httpResponse.getEntity(); String response = RestUtils.readEntity(entity); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { cli.onQuerySubmitSuccess(xqFile, request, RestUtils.mapEntity(response, QueryResponse.class, CONTENT_TYPE_JSON)); } else { cli.onQueryFailure(xqFile, RestUtils.mapEntity(response, ErrorResponse.class, CONTENT_TYPE_JSON)); } } catch (IOException e) { System.err.println("Error occurred when reading entity: " + e.getMessage()); cli.onQueryFailure(xqFile, null); } catch (JAXBException e) { System.err.println("Error occurred when mapping query response: " + e.getMessage()); cli.onQueryFailure(xqFile, null); } } finally { HttpClientUtils.closeQuietly(httpClient); } }</code><technical_language>This file formatted AsterixDB standard. website for developer code formatting details</technical_language>

Target:
private static void sendQueryRequest(String xqFile, QueryRequest request, VXQuery cli) { URI uri = null; try { uri = RestUtils.buildQueryURI(request, cli.restIpAddress, cli.restPort); } catch (URISyntaxException e) { System.err.println( String.format("Unable to build URI to call REST API for query: %s", request.getStatement())); cli.onFailure(xqFile, null); } CloseableHttpClient httpClient = HttpClients.custom().build(); try { HttpGet httpGet = new HttpGet(uri); httpGet.setHeader(HttpHeaders.ACCEPT, CONTENT_TYPE_JSON); try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { HttpEntity entity = httpResponse.getEntity(); String response = RestUtils.readEntity(entity); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { cli.onSuccess(xqFile, request, RestUtils.mapEntity(response, SyncQueryResponse.class, CONTENT_TYPE_JSON)); } else { cli.onFailure(xqFile, RestUtils.mapEntity(response, ErrorResponse.class, CONTENT_TYPE_JSON)); } } catch (IOException e) { System.err.println("Error occurred when reading entity: " + e.getMessage()); cli.onFailure(xqFile, null); } catch (JAXBException e) { System.err.println("Error occurred when mapping query response: " + e.getMessage()); cli.onFailure(xqFile, null); } } finally { HttpClientUtils.closeQuietly(httpClient); } }
Source:
<code>protected ResourceCollection assertFilesystemOnly(ResourceCollection rc) { <START> if (rc != null && !rc.isFilesystemOnly()) { <END> throw new BuildException("%s allows only filesystem resources.", getDataTypeName()); } return rc; }</code><technical_language>please style changes separate PRs (or create all)</technical_language>

Target:
protected ResourceCollection assertFilesystemOnly(ResourceCollection rc) { if (rc != null && !(rc.isFilesystemOnly())) { throw new BuildException("%s allows only filesystem resources.", getDataTypeName()); } return rc; }
Source:
<code>public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { <START> Hashtable<String, String> parameters = (Hashtable<String, String>) data; <END> String profilingType = parameters .get(ProviderProfileConstants.INIT_DATA_TYPE_KEY); String profilingTypeName = parameters .get(ProviderProfileConstants.INIT_DATA_NAME_KEY); if (profilingType == null) { profilingType = ""; } if (profilingTypeName == null) { profilingTypeName = ""; } setProfilingType(profilingType); setProfilingTypeName(profilingTypeName); }</code><technical_language>data is a HashTable, cast a Map require</technical_language>

Target:
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { Map<String, String> parameters = (Map<String, String>) data; String profilingType = parameters .get(ProviderProfileConstants.INIT_DATA_TYPE_KEY); String profilingTypeName = parameters .get(ProviderProfileConstants.INIT_DATA_NAME_KEY); if (profilingType == null) { profilingType = ""; } if (profilingTypeName == null) { profilingTypeName = ""; } setProfilingType(profilingType); setProfilingTypeName(profilingTypeName); }
Source:
<code>public void before() throws Exception { time = new MockTime(); supplier = new MockClientSupplier(); supplier.setCluster(Cluster.bootstrap(singletonList(new InetSocketAddress("localhost", 9999)))); streamsStateListener = new StateListenerStub(); threadStatelistenerCapture = EasyMock.newCapture(); metricsReportersCapture = EasyMock.newCapture(); props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, APPLICATION_ID); props.put(StreamsConfig.CLIENT_ID_CONFIG, CLIENT_ID); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:2018"); props.put(StreamsConfig.METRIC_REPORTER_CLASSES_CONFIG, MockMetricsReporter.class.getName()); props.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getPath()); props.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, NUM_THREADS); <START> builder = new StreamsBuilder(); builder.stream("source"); <END> prepareStreams(); }</code><technical_language>create a method getBuilderWithSource() call inline instead of creating a new mutable field for tests rely on</technical_language>

Target:
public void before() throws Exception { time = new MockTime(); supplier = new MockClientSupplier(); supplier.setCluster(Cluster.bootstrap(singletonList(new InetSocketAddress("localhost", 9999)))); streamsStateListener = new StateListenerStub(); threadStatelistenerCapture = EasyMock.newCapture(); metricsReportersCapture = EasyMock.newCapture(); props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, APPLICATION_ID); props.put(StreamsConfig.CLIENT_ID_CONFIG, CLIENT_ID); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:2018"); props.put(StreamsConfig.METRIC_REPORTER_CLASSES_CONFIG, MockMetricsReporter.class.getName()); props.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getPath()); props.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, NUM_THREADS); prepareStreams(); }
Source:
<code>private void renderRadio(int row, List<Short> columns, LabelAndValues lv) { String id = lv.info.name(); Short dv = normalizeDefaultValue(lv.info.defaultValue(), lv.permitted); labelHelpColumn = 1 + columns.size(); labelsTable.setText(row, 0, id); CellFormatter fmt = labelsTable.getCellFormatter(); fmt.setStyleName(row, 0, style.label_name()); fmt.setStyleName(row, labelHelpColumn, style.label_help()); ApprovalInfo self = Gerrit.isSignedIn() ? lv.info.for_user(Gerrit.getUserAccount().getId().get()) : null; final LabelRadioGroup group = new LabelRadioGroup(row, id, lv.permitted.size()); for (int i = 0; i < columns.size(); i++) { Short v = columns.get(i); if (lv.permitted.contains(v)) { String text = lv.info.value_text(LabelValue.formatValue(v)); LabelRadioButton b = new LabelRadioButton(group, text, v); if ((self != null && v == self.value()) || (self == null && <START> v == dv)) <END> { b.setValue(true); group.select(b); in.label(group.label, v); labelsTable.setText(row, labelHelpColumn, b.text); } group.buttons.add(b); labelsTable.setWidget(row, 1 + i, b); } } if (CODE_REVIEW.equalsIgnoreCase(id) && !group.buttons.isEmpty()) { lgtm = new Runnable() { @Override public void run() { group.selectMax(); } }; } }</code><technical_language>Do compare Short Short ==. code reads ambiguous I implemented unboxing Short comparing primitives. Short is a reference type equal</technical_language>

Target:
private void renderRadio(int row, List<Short> columns, LabelAndValues lv) { String id = lv.info.name(); Short dv = normalizeDefaultValue(lv.info.defaultValue(), lv.permitted); labelHelpColumn = 1 + columns.size(); labelsTable.setText(row, 0, id); CellFormatter fmt = labelsTable.getCellFormatter(); fmt.setStyleName(row, 0, style.label_name()); fmt.setStyleName(row, labelHelpColumn, style.label_help()); ApprovalInfo self = Gerrit.isSignedIn() ? lv.info.for_user(Gerrit.getUserAccount().getId().get()) : null; final LabelRadioGroup group = new LabelRadioGroup(row, id, lv.permitted.size()); for (int i = 0; i < columns.size(); i++) { Short v = columns.get(i); if (lv.permitted.contains(v)) { String text = lv.info.value_text(LabelValue.formatValue(v)); LabelRadioButton b = new LabelRadioButton(group, text, v); if ((self != null && v == self.value()) || (self == null && v.equals(dv))) { b.setValue(true); group.select(b); in.label(group.label, v); labelsTable.setText(row, labelHelpColumn, b.text); } group.buttons.add(b); labelsTable.setWidget(row, 1 + i, b); } } if (CODE_REVIEW.equalsIgnoreCase(id) && !group.buttons.isEmpty()) { lgtm = new Runnable() { @Override public void run() { group.selectMax(); } }; } }
Source:
<code>public Response createInsertion(@PathParam("programUuid") long programUuid, JaxNewInsertion newInsertion) throws Exception { ArtifactReadable programArt = atsServer.getQuery().andUuid(programUuid).getResults().getExactlyOne(); <START> if (!programArt.getArtifactType().equals(AtsArtifactTypes.Program)) { <END> throw new OseeCoreException("Given uuid not program type"); } ResultSet results = atsServer.getQuery().andUuid(newInsertion.getUuid()).getResults(); if (results.size() != 0) { throw new OseeStateException("Insertion with id %d already exists", newInsertion.getUuid()); } IAtsInsertion created = atsServer.getConfigItemFactory().createInsertion(programArt, newInsertion); return getResponse(created); }</code><technical_language>need handle case programArt == null</technical_language>

Target:
public Response createInsertion(@PathParam("programUuid") long programUuid, JaxNewInsertion newInsertion) throws Exception { ArtifactReadable programArt = atsServer.getArtifactByUuid(programUuid); if (programArt == null) { throw new OseeCoreException("Given uuid not found"); } if (!programArt.getArtifactType().equals(AtsArtifactTypes.Program)) { throw new OseeCoreException("Given uuid not program type"); } ResultSet<?> results = atsServer.getQuery().andUuid(newInsertion.getUuid()).getResults(); if (results.size() != 0) { throw new OseeStateException("Insertion with id %d already exists", newInsertion.getUuid()); } IAtsInsertion created = atsServer.getConfigItemFactory().createInsertion(programArt, newInsertion); return getResponse(created); }
Source:
<code>public void pubOnlyDerivation() throws Exception { DeterministicKey key1 = HDKeyDerivation.createMasterPrivateKey("satoshi lives!".getBytes()); assertFalse(key1.isPubKeyOnly()); DeterministicKey key2 = HDKeyDerivation.deriveChildKey(key1, ChildNumber.ZERO_HARDENED); assertFalse(key2.isPubKeyOnly()); DeterministicKey key3 = HDKeyDerivation.deriveChildKey(key2, ChildNumber.ZERO); assertFalse(key3.isPubKeyOnly()); DeterministicKey pubkey2 = key2.getPubOnly(); <START> assertFalse(pubkey2.isPubKeyOnly()); <END> DeterministicKey pubkey3 = HDKeyDerivation.deriveChildKey(pubkey2, ChildNumber.ZERO); assertFalse(pubkey3.isPubKeyOnly()); assertEquals(key3.getPubKeyPoint(), pubkey3.getPubKeyPoint()); }</code><technical_language>Surely lines some naming conceptual confusion? call a method called getPubOnly return for isPubKeyOnly is false</technical_language>

Target:
public void pubOnlyDerivation() throws Exception { DeterministicKey key1 = HDKeyDerivation.createMasterPrivateKey("satoshi lives!".getBytes()); assertFalse(key1.isPubKeyOnly()); DeterministicKey key2 = HDKeyDerivation.deriveChildKey(key1, ChildNumber.ZERO_HARDENED); assertFalse(key2.isPubKeyOnly()); DeterministicKey key3 = HDKeyDerivation.deriveChildKey(key2, ChildNumber.ZERO); assertFalse(key3.isPubKeyOnly()); DeterministicKey pubkey2 = key2.getPubOnly(); assertTrue(pubkey2.isPubKeyOnly()); DeterministicKey pubkey3 = HDKeyDerivation.deriveChildKey(pubkey2, ChildNumber.ZERO); assertTrue(pubkey3.isPubKeyOnly()); assertEquals(key3.getPubKeyPoint(), pubkey3.getPubKeyPoint()); }
Source:
<code>public void truncateTables(Set<TableReference> tableRefs) { List<Future> futures = Lists.newArrayListWithCapacity(tableRefs.size()); <START> tableRefs.forEach(tableRef -> futures.add(ddlExecutor.submit(() -> <END> runDdl(tableRef, table -> { table.truncate(); return null; })))); waitOnDdlOperations(futures); }</code><technical_language>able extract a method takes a Collection a lambda concurrent operations waitOnDdlOperations</technical_language>

Target:
public void truncateTables(Set<TableReference> tableRefs) { runOnTables(tableRefs, table -> table.truncate()); }
Source:
<code>public void receiveUntilTimeoutMultipleTimes() throws IOException { this.consumer.close(); this.consumer = null; final int numberOfEvents = 15; final int numberOfEvents2 = 3; final String partitionId = "1"; final List<EventData> events = getEventsAsList(numberOfEvents, TestUtils.MESSAGE_TRACKING_ID); final List<EventData> events2 = getEventsAsList(numberOfEvents2, TestUtils.MESSAGE_TRACKING_ID); final EventHubConsumer consumer = client.createConsumer(DEFAULT_CONSUMER_GROUP_NAME, partitionId, EventPosition.fromEnqueuedTime(Instant.now())); final EventHubProducer producer = client.createProducer(new EventHubProducerOptions().setPartitionId(partitionId)); try { producer.send(events); final IterableStream<EventData> receive = consumer.receive(100, Duration.ofSeconds(3)); System.out.println("Sending second batch."); producer.send(events2); <START> System.out.println("Receiving second batch."); <END> final IterableStream<EventData> receive2 = consumer.receive(100, Duration.ofSeconds(5)); final List<EventData> asList = receive.stream().collect(Collectors.toList()); Assert.assertEquals(numberOfEvents, asList.size()); final List<EventData> asList2 = receive2.stream().collect(Collectors.toList()); Assert.assertEquals(numberOfEvents2, asList2.size()); } finally { dispose(consumer, producer); } }</code><technical_language>logger instead</technical_language>

Target:
public void receiveUntilTimeoutMultipleTimes() { final int numberOfEvents = 15; final int numberOfEvents2 = 3; final String partitionId = "1"; final List<EventData> events = getEventsAsList(numberOfEvents); final List<EventData> events2 = getEventsAsList(numberOfEvents2); final EventHubConsumer consumer = client.createConsumer(DEFAULT_CONSUMER_GROUP_NAME, partitionId, EventPosition.fromEnqueuedTime(Instant.now())); final EventHubProducer producer = client.createProducer(new EventHubProducerOptions().setPartitionId(partitionId)); try { producer.send(events); final IterableStream<EventData> receive = consumer.receive(100, Duration.ofSeconds(3)); logger.info("Sending second batch."); producer.send(events2); logger.info("Receiving second batch."); final IterableStream<EventData> receive2 = consumer.receive(100, Duration.ofSeconds(5)); final List<EventData> asList = receive.stream().collect(Collectors.toList()); Assert.assertEquals(numberOfEvents, asList.size()); final List<EventData> asList2 = receive2.stream().collect(Collectors.toList()); Assert.assertEquals(numberOfEvents2, asList2.size()); } finally { dispose(consumer, producer); } }