From eb3d159ddec76b869b872fead80ef994abb609e8 Mon Sep 17 00:00:00 2001 From: sokomishalov Date: Wed, 30 Oct 2019 12:16:16 +0300 Subject: [PATCH] upgrade spring boot to 2.2.0.RELEASE replaced Optional bean with ObjectProvider in autoconfiguration --- telegrambots-spring-boot-starter/pom.xml | 2 +- .../TelegramBotStarterConfiguration.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index c28a9bdf..565c59df 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -70,7 +70,7 @@ UTF-8 UTF-8 - 2.1.6.RELEASE + 2.2.0.RELEASE diff --git a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotStarterConfiguration.java b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotStarterConfiguration.java index 5fe34191..6aea31d0 100644 --- a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotStarterConfiguration.java +++ b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/TelegramBotStarterConfiguration.java @@ -2,8 +2,9 @@ package org.telegram.telegrambots.starter; import java.util.Collections; 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.ConditionalOnProperty; 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.generics.LongPollingBot; import org.telegram.telegrambots.meta.generics.WebhookBot; - /** * #TelegramBotsApi added to spring context as well */ @Configuration -@ConditionalOnProperty(prefix="telegrambots",name = "enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(prefix = "telegrambots", name = "enabled", havingValue = "true", matchIfMissing = true) public class TelegramBotStarterConfiguration { @Bean @@ -26,12 +26,12 @@ public class TelegramBotStarterConfiguration { } @Bean - @ConditionalOnMissingBean - public TelegramBotInitializer telegramBotInitializer(TelegramBotsApi telegramBotsApi, - Optional> longPollingBots, - Optional> webHookBots) { - return new TelegramBotInitializer(telegramBotsApi, - longPollingBots.orElseGet(Collections::emptyList), - webHookBots.orElseGet(Collections::emptyList)); + @ConditionalOnMissingBean + public TelegramBotInitializer telegramBotInitializer(TelegramBotsApi telegramBotsApi, + ObjectProvider> longPollingBots, + ObjectProvider> webHookBots) { + return new TelegramBotInitializer(telegramBotsApi, + longPollingBots.getIfAvailable(Collections::emptyList), + webHookBots.getIfAvailable(Collections::emptyList)); } }