Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Actuator endpoint for topology description.
*
* @author Soby Chacko
* @author Ngoc Nhan
* @since 3.0.4
*/
@Endpoint(id = "kafkastreamstopology")
Expand All @@ -51,9 +52,8 @@ public KafkaStreamsTopologyEndpoint(KafkaStreamsRegistry kafkaStreamsRegistry) {
public List<String> kafkaStreamsTopologies() {
final List<StreamsBuilderFactoryBean> streamsBuilderFactoryBeans = this.kafkaStreamsRegistry.streamsBuilderFactoryBeans();
final List<String> descs = new ArrayList<>();
streamsBuilderFactoryBeans.stream()
.forEach(streamsBuilderFactoryBean ->
descs.add(Objects.requireNonNull(streamsBuilderFactoryBean.getTopology()).describe().toString()));
streamsBuilderFactoryBeans.forEach(streamsBuilderFactoryBean ->
descs.add(Objects.requireNonNull(streamsBuilderFactoryBean.getTopology()).describe().toString()));
return descs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.ResolvableType;
import org.springframework.core.type.StandardMethodMetadata;
import org.springframework.lang.NonNull;
import org.springframework.util.ClassUtils;

/**
* @author Soby Chacko
* @author James Forward
* @author Ngoc Nhan
*
* @since 2.2.0
*/
Expand Down Expand Up @@ -110,8 +110,7 @@ public void afterPropertiesSet() {
collect.removeIf(Pattern.compile(".*_registration").asPredicate());

onlySingleFunction = collect.size() == 1;
collect.stream()
.forEach(this::extractResolvableTypes);
collect.forEach(this::extractResolvableTypes);

kafkaStreamsOnlyResolvableTypes.keySet().forEach(k -> addResolvableTypeInfo(k, kafkaStreamsOnlyResolvableTypes.get(k)));
kafakStreamsOnlyMethods.keySet().forEach(k -> addResolvableTypeInfo(k, kafakStreamsOnlyMethods.get(k)));
Expand Down Expand Up @@ -304,7 +303,7 @@ private boolean isKafkaStreamsTypeFound(Method method) {
}

@Override
public void setBeanFactory(@NonNull BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
*
* @author Oleg Zhurakousky
* @author Soby Chacko
* @author Ngoc Nhan
*
*/
class ImplicitFunctionBindingTests {
Expand Down Expand Up @@ -175,13 +176,13 @@ void gh2658_WithMultipleDestinations(String destination) {
var multipleInput = ctrl.queryState("consumerMultiple-in-0");

assertThat(multipleInput).hasSize(destination.split(",").length);
multipleInput.stream().forEach(binding -> assertThat(binding.isRunning()).isTrue());
multipleInput.forEach(binding -> assertThat(binding.isRunning()).isTrue());

ctrl.changeState("consumerMultiple-in-0", State.STOPPED);
multipleInput.stream().forEach(binding -> assertThat(binding.isRunning()).isFalse());
multipleInput.forEach(binding -> assertThat(binding.isRunning()).isFalse());

ctrl.changeState("consumerMultiple-in-0", State.STARTED);
multipleInput.stream().forEach(binding -> assertThat(binding.isRunning()).isTrue());
multipleInput.forEach(binding -> assertThat(binding.isRunning()).isTrue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
* @author Artem Bilan
* @author Gary Russell
* @author Byungjun You
* @author Ngoc Nhan
* @since 1.1
*/
public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties, P extends ProducerProperties, PP extends ProvisioningProvider<C, P>>
Expand Down Expand Up @@ -272,11 +273,11 @@ private String resolveFromDefaultBinder() {
DefaultBinderTypeRegistry binderTypeRegistry =
AbstractMessageChannelBinder.this.getApplicationContext().getBean(DefaultBinderTypeRegistry.class);
Map<String, BinderType> binderTypes = binderTypeRegistry.getAll();
if (binderTypes.entrySet().size() > 1 && getBindingServiceProperties().getDefaultBinder() != null) {
if (binderTypes.size() > 1 && getBindingServiceProperties().getDefaultBinder() != null) {
return getBindingServiceProperties().getDefaultBinder();
}
Assert.isTrue(binderTypes.entrySet().size() <= 1, "More than one binder types found, but no binder specified on the binding");
return (binderTypes.entrySet().size() < 1) ? null : binderTypes.keySet().iterator().next();
Assert.isTrue(binderTypes.size() <= 1, "More than one binder types found, but no binder specified on the binding");
return binderTypes.isEmpty() ? null : binderTypes.keySet().iterator().next();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
* @author Byungjun You
* @author Omer Celik
* @author Sharang Gupta
* @author Ngoc Nhan
*/
public class DefaultBinderFactory implements BinderFactory, DisposableBean, ApplicationContextAware, SmartLifecycle {

Expand Down Expand Up @@ -318,7 +319,7 @@ else if (binderConfigurationEntry.getValue().isDefaultCandidate()) {
.put(bindingTargetType.getName(), configurationName);
}
else {
String countMsg = (candidatesForBindableType.size() == 0)
String countMsg = candidatesForBindableType.isEmpty()
? "are no binders" : "is more than one binder";
throw new IllegalStateException(
"A default binder has been requested, but there "
Expand Down Expand Up @@ -347,7 +348,7 @@ else if (binderConfigurationEntry.getValue().isDefaultCandidate()) {
private <T> void populateCandidatesForBindableType(Class<? extends T> bindingTargetType, List<String> candidatesForBindableType,
String defaultCandidateConfiguration) {
// Going by the convention of proper reactor based binders start with the key literal - reactor
boolean isCandidate = (FluxMessageChannel.class.isAssignableFrom(bindingTargetType) && defaultCandidateConfiguration.startsWith("reactor"))
boolean isCandidate = FluxMessageChannel.class.isAssignableFrom(bindingTargetType)
|| !defaultCandidateConfiguration.startsWith("reactor");
if (isCandidate) {
candidatesForBindableType.add(defaultCandidateConfiguration);
Expand Down Expand Up @@ -497,7 +498,7 @@ ConfigurableApplicationContext initializeBinderContextSimple(String configuratio
binderProducingContext.setParent(this.context);
}
else if (this.context != null) {
binderProducingContext.addApplicationListener(new ApplicationListener<ApplicationEvent>() {
binderProducingContext.addApplicationListener(new ApplicationListener<>() {
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (context != null) {
Expand Down Expand Up @@ -574,13 +575,13 @@ private void propagateSharedBeans(GenericApplicationContext toContext, GenericAp
Class<Object> beanType = this.loadClass(((String) className).trim());
if (beanType != null) {
Map<String, Object> beansOfType = fromContext.getBeansOfType(beanType);
beansOfType.entrySet().stream().forEach(entry -> {
Object bean = entry.getValue();
beansOfType.forEach((key, value) -> {
Object bean = value;
if (bean instanceof Converter) {
binderProducingConversionService.addConverter((Converter<?, ?>) bean);
}
else {
toContext.registerBean(entry.getKey() + "_child", beanType, () -> entry.getValue());
toContext.registerBean(key + "_child", beanType, () -> bean);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
*
* @author Oleg Zhurakousky
* @author Soby Chacko
* @author Ngoc Nhan
* @since 3.x
*/
public class BindingsLifecycleController implements ApplicationContextAware {
Expand Down Expand Up @@ -241,10 +242,10 @@ public void changeState(String bindingName, State state) {
var bindingList = BindingsLifecycleController.this.locateBinding(bindingName);
if (!bindingList.isEmpty()) {
switch (state) {
case STARTED -> bindingList.stream().forEach(Binding::start);
case STOPPED -> bindingList.stream().forEach(Binding::stop);
case PAUSED -> bindingList.stream().forEach(Binding::pause);
case RESUMED -> bindingList.stream().forEach(Binding::resume);
case STARTED -> bindingList.forEach(Binding::start);
case STOPPED -> bindingList.forEach(Binding::stop);
case PAUSED -> bindingList.forEach(Binding::pause);
case RESUMED -> bindingList.forEach(Binding::resume);
default -> {
}
}
Expand Down Expand Up @@ -284,9 +285,9 @@ private void defineBinding(BindableFunctionProxyFactory bindingProxyFactory) {
bindingProxyFactory.setApplicationContext(this.applicationContext);
bindingProxyFactory.afterPropertiesSet();

AbstractBindingLifecycle bindingLifecycle = (bindingProxyFactory.getInputs().size() > 0)
? this.applicationContext.getBean(InputBindingLifecycle.class)
: this.applicationContext.getBean(OutputBindingLifecycle.class);
AbstractBindingLifecycle bindingLifecycle = bindingProxyFactory.getInputs().isEmpty()
? this.applicationContext.getBean(OutputBindingLifecycle.class)
: this.applicationContext.getBean(InputBindingLifecycle.class);

bindingLifecycle.startBindable(bindingProxyFactory);
}
Expand Down
Loading