auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void destroyCreatedChannel(Binding binding) { MessageChannel channel = binding.getChannel(); if ("producer".equals(binding.getType()) && this.createdChannels.contains(channel)) { this.createdChannels.remove(channel); BeanFactory beanFactory = this.applicationContext.getBeanFactory(); if (beanFactory instanceof DefaultListableBeanFactory) { String name = ((NamedComponent) channel).getComponentName(); ((DefaultListableBeanFactory) beanFactory).destroySingleton(name); if (logger.isDebugEnabled()) { logger.debug("Removed channel:" + name); } } } }

Target:
protected void destroyCreatedChannel(Binding binding) { MessageChannel channel = binding.getChannel(); if (Binding.PRODUCER.equals(binding.getType()) && this.createdChannels.contains(channel)) { this.createdChannels.remove(channel); BeanFactory beanFactory = this.applicationContext.getBeanFactory(); if (beanFactory instanceof DefaultListableBeanFactory) { String name = ((NamedComponent) channel).getComponentName(); ((DefaultListableBeanFactory) beanFactory).destroySingleton(name); if (logger.isDebugEnabled()) { logger.debug("Removed channel:" + name); } } } }
Source:
long getTokenCount() { return tokens.get(); }

Target:
protected long getTokenCount() { return tokens.get(); }
Source:
public void populateDAG(DAG dag, Configuration conf) { RandomNumberGenerator rand = dag.addOperator("rand", RandomNumberGenerator.class); StdoutOperator stdout = dag.addOperator("stdout", new StdoutOperator()); dag.addModule("testModule", com.example.mydtapp.TestModule.class); dag.addStream("data", rand.out, stdout.in).setLocality(Locality.CONTAINER_LOCAL); }

Target:
public void populateDAG(DAG dag, Configuration conf) { RandomNumberGenerator rand = dag.addOperator("rand", RandomNumberGenerator.class); StdoutOperator stdout = dag.addOperator("stdout", new StdoutOperator()); Module testModule = dag.addModule("testModule", com.example.mydtapp.TestModule.class); dag.addStream("data", rand.out, stdout.in).setLocality(Locality.CONTAINER_LOCAL); }
Source:
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)) { if (extraAspect == null) { extraAspect = new CustomExtraFieldsAspect(); builder.add(extraAspect); } } else { builder.add(new TmfContentFieldAspect(output.name, output.name)); fieldNames.add(output.name); } } return builder.build(); }

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:
void pause() throws InterruptedException { if (!paused.getAndSet(true)) { synchronized (lock) { logger.info("HardDelete thread has been paused "); lock.notify(); time.wait(lock, hardDeleterSleepTimeWhenCaughtUpMs); } } }

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:
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("http", "dummy" + need, capacity, workerTaskRunnerConfig.getMinWorkerVersion()); need++; } workersMap.put(workerRunningTask.getWorker().getHost(), workerWithTask(workerRunningTask, task)); } return need; }

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:
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); if (!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; }

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:
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)) { continue retry; } current = successor; } else { if (current.value == null || current.value.compareTo(value) > 0) { return new Window(previous, current); } previous = current; current = successor; } } } }

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:
protected PlaceRequest getMainTabRequest() { logger.info(this.getClass().toString() + " getMainTabRequest"); return PlaceRequestFactory.get(WebAdminApplicationPlaces.errataMainTabPlace); }

Target:
protected PlaceRequest getMainTabRequest() { return PlaceRequestFactory.get(WebAdminApplicationPlaces.errataMainTabPlace); }
Source:
private ObjectName createObjectName(String cacheName, URI cacheManagerURI, String beanName) { String cacheManagerName = sanitize(cacheManagerURI != null ? cacheManagerURI.toString() : "null"); 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); } }

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:
public URI getUri() { return getRequest().url().uri(); }

Target:
public URI getUri() { return request.url().uri(); }
Source:
public void testOneOfDisabled() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Map<Resource, Set<Resource>> enumerations = new HashMap<>(); 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); }

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:
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)); return Collections.emptyList(); }

Target:
public List<ScriptSequenceAction> addActionToSequence(Sprite sprite, ScriptSequenceAction sequence) { sequence.addAction(sprite.getActionFactory() .createSetLookByIndexAction(getSprite(), getFormulaWithBrickField(BrickField.LOOK_INDEX), wait)); return Collections.emptyList(); }
Source:
public BindingElementTree BINDING_PROPERTY() { return b.<BindingElementTree>nonterminal() .is(b.firstOf( REST_OBJECT_BINDING_ELEMENT(), f.bindingProperty(PROPERTY_NAME(), b.token(JavaScriptPunctuator.COLON), BINDING_ELEMENT()), BINDING_ELEMENT())); }

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:
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, new StepScope()); }

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:
private int getMaxNumOfDayForMonth(int month, int year){ 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; }

Target:
private int getMaxNumOfDayForMonth(int month, int year){ DateTime dateTime = new DateTime(year, month, 1, 0, 0, 0, 000); return dateTime.dayOfMonth().getMaximumValue(); }
Source:
private <T extends CatalogType> SpongeCatalogRegistry registerCallbackRegistry(Class<T> catalogClass, CatalogKey key, BiConsumer<ResourceLocation, T> callback) { checkNotNull(catalogClass); checkNotNull(key); if (this.registries.get(key) != null) { 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; }

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:
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)); 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)), new FilterSpell("a spell"), true)); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new Mana(0, 1, 1, 0, 0, 0, 0, 0), new TapSourceCost())); }

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:
public void shouldDeleteCondition() { Condition condition = dao.getConditionByUuid("2cc6880e-2a46-11e4-9038-a6c5e4d26fb7"); Condition deletedCondition = dao.deleteCondition(condition); assertEquals(deletedCondition, null); }

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:
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()); mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize); 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); }

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:
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)); return Iterables.concat(defaultTags, additionalTags); }; 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)); } } }

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:
private boolean deleteConfigObject(long uuid, String comment, IArtifactType type) { 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; }

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:
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 addOrUpdateBatch(autocompleteSection, citems); }

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:
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; } } else { return false; } }

Target:
private boolean insertHasDoNotSet(ExecutableElement v, boolean explicitSet) { return hasDoNotSet(Insert.class, Insert::nullSavingStrategy, v, explicitSet); }
Source:
private List<Flight> searchByDate(SearchParams searchParams) { 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; }

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:
public void testStartpointSpecificOffsetVisitorShouldUpdateTheFetchOffsetInConsumer() { final Integer testPartitionId = 0; 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)); }

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:
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.logError(validationStatus.getMessage(), validationStatus.getException()); } return validationStatus.getMessage(); } }; }

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:
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 { return new LocationImpl(removePrefixUri(l), lineNumber, null); } }

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:
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); } CloseableHttpClient httpClient = HttpClients.custom() .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); } }

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:
protected ResourceCollection assertFilesystemOnly(ResourceCollection rc) { if (rc != null && !rc.isFilesystemOnly()) { throw new BuildException("%s allows only filesystem resources.", getDataTypeName()); } return rc; }

Target:
protected ResourceCollection assertFilesystemOnly(ResourceCollection rc) { if (rc != null && !(rc.isFilesystemOnly())) { throw new BuildException("%s allows only filesystem resources.", getDataTypeName()); } return rc; }
Source:
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { Hashtable<String, String> parameters = (Hashtable<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); }

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:
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); builder = new StreamsBuilder(); builder.stream("source"); prepareStreams(); }

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:
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 == 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(); } }; } }

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:
public Response createInsertion(@PathParam("programUuid") long programUuid, JaxNewInsertion newInsertion) throws Exception { ArtifactReadable programArt = atsServer.getQuery().andUuid(programUuid).getResults().getExactlyOne(); 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); }

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:
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(); assertFalse(pubkey2.isPubKeyOnly()); DeterministicKey pubkey3 = HDKeyDerivation.deriveChildKey(pubkey2, ChildNumber.ZERO); assertFalse(pubkey3.isPubKeyOnly()); assertEquals(key3.getPubKeyPoint(), pubkey3.getPubKeyPoint()); }

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:
public void truncateTables(Set<TableReference> tableRefs) { List<Future> futures = Lists.newArrayListWithCapacity(tableRefs.size()); tableRefs.forEach(tableRef -> futures.add(ddlExecutor.submit(() -> runDdl(tableRef, table -> { table.truncate(); return null; })))); waitOnDdlOperations(futures); }

Target:
public void truncateTables(Set<TableReference> tableRefs) { runOnTables(tableRefs, table -> table.truncate()); }
Source:
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); System.out.println("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); } }

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); } }
Source:
void getProgressAndPingTaskNode(RunningTaskData taskData) { if (!jobs.canPingTask(taskData) || taskData.isRestarting() || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) { return; } InternalTask task = taskData.getTask(); try { int progress = taskData.getLauncher().getProgress(); taskData.resetFirstTaskLauncherFailureTime(); if (progress != task.getProgress()) { task.setProgress(progress); listener.taskStateUpdated(taskData.getUser(), new NotificationData<>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo()))); } } catch (Throwable t) { if (taskData.getFirstTaskLauncherFailureTime() < 0) { taskData.setFirstTaskLauncherFailureTime(System.currentTimeMillis()); } if (tlogger.isDebugEnabled()) { tlogger.debug(task.getId(), "TaskLauncher is not accessible since " + new Date(taskData.getFirstTaskLauncherFailureTime()) + ", checking if the node can be reached.", t); } pingTaskNodeAndInitiateRestart(task); } }

Target:
void getProgressAndPingTaskNode(RunningTaskData taskData) { if (!jobs.canPingTask(taskData) || taskData.isRestarting() || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) { return; } InternalTask task = taskData.getTask(); try { int progress = taskData.getLauncher().getProgress(); taskData.resetTaskLauncherFailure(); if (progress != task.getProgress()) { task.setProgress(progress); listener.taskStateUpdated(taskData.getUser(), new NotificationData<>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo()))); } } catch (Throwable t) { taskData.setTaskLauncherFailure(); if (tlogger.isDebugEnabled()) { tlogger.debug(task.getId(), "TaskLauncher is not accessible for " + taskData.getTaskLauncherFailurePeriod() + " ms, checking if the node can be reached.", t); } pingTaskNodeAndInitiateRestart(task); } }
Source:
public void function_with_tuple_param() { FunctionDef functionTree = functionTreesByName.get("func_with_tuple_param"); Map<String, Symbol> symbolByName = getSymbolByName(functionTree); assertThat(symbolByName).hasSize(4); for (Map.Entry<String, Symbol> stringSymbolEntry : symbolByName.entrySet()) { System.out.println(stringSymbolEntry.getKey()+"-"+stringSymbolEntry.getValue().name()); } }

Target:
public void function_with_tuple_param() { FunctionDef functionTree = functionTreesByName.get("func_with_tuple_param"); Map<String, Symbol> symbolByName = getSymbolByName(functionTree); assertThat(symbolByName).hasSize(4); }
Source:
private <K, V> V loadValue(Cache<K, V> cache, K key, Supplier<V> valueSupplier) { if (replay) { if (cache.asMap().containsKey(key)) { return cache.asMap().get(key); } return valueSupplier.get(); } V value = valueSupplier.get(); cache.put(key, value); return value; }

Target:
private <K, V> V loadValue(Cache<K, V> cache, K key, Supplier<V> valueSupplier) { if (replay) { return Optional.ofNullable(cache.getIfPresent(key)) .orElseThrow(() -> new PrestoException(NOT_FOUND, "Missing entry found for key: " + key)); } V value = valueSupplier.get(); cache.put(key, value); return value; }