Merge pull request #687 from SokoMishaLov/starter-upgrade-2.2.0

upgrade spring boot to 2.2.1.RELEASE, replaced Optional bean with ObjectProvider in autoconfiguration
This commit is contained in:
Ruben Bermudez 2020-04-26 00:51:49 +01:00 committed by GitHub
commit 52d69853e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -70,7 +70,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<spring-boot.version>2.2.1.RELEASE</spring-boot.version>
</properties> </properties>
<dependencies> <dependencies>

View File

@ -2,8 +2,9 @@ package org.telegram.telegrambots.starter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -11,12 +12,11 @@ import org.springframework.context.annotation.Configuration;
import org.telegram.telegrambots.meta.TelegramBotsApi; import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.generics.LongPollingBot; import org.telegram.telegrambots.meta.generics.LongPollingBot;
import org.telegram.telegrambots.meta.generics.WebhookBot; import org.telegram.telegrambots.meta.generics.WebhookBot;
/** /**
* #TelegramBotsApi added to spring context as well * #TelegramBotsApi added to spring context as well
*/ */
@Configuration @Configuration
@ConditionalOnProperty(prefix="telegrambots",name = "enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(prefix = "telegrambots", name = "enabled", havingValue = "true", matchIfMissing = true)
public class TelegramBotStarterConfiguration { public class TelegramBotStarterConfiguration {
@Bean @Bean
@ -26,12 +26,12 @@ public class TelegramBotStarterConfiguration {
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public TelegramBotInitializer telegramBotInitializer(TelegramBotsApi telegramBotsApi, public TelegramBotInitializer telegramBotInitializer(TelegramBotsApi telegramBotsApi,
Optional<List<LongPollingBot>> longPollingBots, ObjectProvider<List<LongPollingBot>> longPollingBots,
Optional<List<WebhookBot>> webHookBots) { ObjectProvider<List<WebhookBot>> webHookBots) {
return new TelegramBotInitializer(telegramBotsApi, return new TelegramBotInitializer(telegramBotsApi,
longPollingBots.orElseGet(Collections::emptyList), longPollingBots.getIfAvailable(Collections::emptyList),
webHookBots.orElseGet(Collections::emptyList)); webHookBots.getIfAvailable(Collections::emptyList));
} }
} }