From 89bb62dfa515be149c63a2f8cae077522cf2c342 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Sat, 28 Sep 2024 11:31:29 +0300 Subject: [PATCH] backport fixes from spring-6 branch --- .../ru/org/linux/exception/ExceptionController.java | 5 +++-- .../ru/org/linux/search/SearchControlController.java | 4 +--- .../ru/org/linux/user/EditRegisterController.java | 4 ++-- .../ru/org/linux/user/ResetPasswordController.java | 3 +-- src/main/java/ru/org/linux/util/LorHttpUtils.java | 4 +--- .../ru/org/linux/comment/EditCommentController.scala | 2 +- src/main/scala/ru/org/linux/help/HelpController.scala | 4 ++-- .../ElasticsearchIndexServiceIntegrationSpec.scala | 11 ++++++----- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/java/ru/org/linux/exception/ExceptionController.java b/src/main/java/ru/org/linux/exception/ExceptionController.java index b5c3367906..c9e0608fba 100644 --- a/src/main/java/ru/org/linux/exception/ExceptionController.java +++ b/src/main/java/ru/org/linux/exception/ExceptionController.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2016 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,6 +20,7 @@ import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.RedirectView; +import javax.servlet.RequestDispatcher; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -34,7 +35,7 @@ public ModelAndView defaultExceptionHandler( HttpServletResponse response, Object handler ) { - Throwable ex = (Throwable) request.getAttribute("javax.servlet.error.exception"); + Throwable ex = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); if (ex == null) { return new ModelAndView(new RedirectView("/")); } diff --git a/src/main/java/ru/org/linux/search/SearchControlController.java b/src/main/java/ru/org/linux/search/SearchControlController.java index 935728714b..242c8cc788 100644 --- a/src/main/java/ru/org/linux/search/SearchControlController.java +++ b/src/main/java/ru/org/linux/search/SearchControlController.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2016 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,6 @@ package ru.org.linux.search; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Required; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -34,7 +33,6 @@ public class SearchControlController { private TopicDao messageDao; @Autowired - @Required public void setSearchQueueSender(SearchQueueSender searchQueueSender) { this.searchQueueSender = searchQueueSender; } diff --git a/src/main/java/ru/org/linux/user/EditRegisterController.java b/src/main/java/ru/org/linux/user/EditRegisterController.java index 405f906d81..5eded65a10 100644 --- a/src/main/java/ru/org/linux/user/EditRegisterController.java +++ b/src/main/java/ru/org/linux/user/EditRegisterController.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2023 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -76,7 +76,7 @@ public EditRegisterController(RememberMeServices rememberMeServices, @RequestMapping(method = RequestMethod.GET) public ModelAndView show( @ModelAttribute("form") EditRegisterRequest form, - @PathVariable String nick, + @PathVariable("nick") String nick, HttpServletResponse response ) { Template tmpl = Template.getTemplate(); diff --git a/src/main/java/ru/org/linux/user/ResetPasswordController.java b/src/main/java/ru/org/linux/user/ResetPasswordController.java index acee5cdc2d..2d94f866ab 100644 --- a/src/main/java/ru/org/linux/user/ResetPasswordController.java +++ b/src/main/java/ru/org/linux/user/ResetPasswordController.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2023 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; diff --git a/src/main/java/ru/org/linux/util/LorHttpUtils.java b/src/main/java/ru/org/linux/util/LorHttpUtils.java index 2d68d759e5..c9dd85c1fe 100644 --- a/src/main/java/ru/org/linux/util/LorHttpUtils.java +++ b/src/main/java/ru/org/linux/util/LorHttpUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2022 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,11 +18,9 @@ import com.google.common.base.Joiner; import com.google.common.net.HttpHeaders; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.Collections; -import java.util.Properties; public final class LorHttpUtils { private LorHttpUtils() { diff --git a/src/main/scala/ru/org/linux/comment/EditCommentController.scala b/src/main/scala/ru/org/linux/comment/EditCommentController.scala index 27e458041c..9934f8825a 100644 --- a/src/main/scala/ru/org/linux/comment/EditCommentController.scala +++ b/src/main/scala/ru/org/linux/comment/EditCommentController.scala @@ -23,7 +23,7 @@ import org.springframework.web.servlet.view.RedirectView import ru.org.linux.auth.AuthUtil.AuthorizedOnly import ru.org.linux.auth.{AuthUtil, IPBlockDao, IPBlockInfo} import ru.org.linux.csrf.CSRFNoAuto -import ru.org.linux.markup.{MarkupType, MessageTextService} +import ru.org.linux.markup.MessageTextService import ru.org.linux.search.SearchQueueSender import ru.org.linux.site.Template import ru.org.linux.spring.dao.{MessageText, MsgbaseDao} diff --git a/src/main/scala/ru/org/linux/help/HelpController.scala b/src/main/scala/ru/org/linux/help/HelpController.scala index aa8f68b84d..177ae40bac 100644 --- a/src/main/scala/ru/org/linux/help/HelpController.scala +++ b/src/main/scala/ru/org/linux/help/HelpController.scala @@ -1,5 +1,5 @@ /* - * Copyright 1998-2023 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,7 +26,7 @@ import org.springframework.web.servlet.ModelAndView import ru.org.linux.util.markdown.MarkdownFormatter import java.nio.charset.StandardCharsets -import scala.jdk.CollectionConverters._ +import scala.jdk.CollectionConverters.* @Controller class HelpController(renderService: MarkdownFormatter) extends StrictLogging { diff --git a/src/test/scala/ru/org/linux/search/ElasticsearchIndexServiceIntegrationSpec.scala b/src/test/scala/ru/org/linux/search/ElasticsearchIndexServiceIntegrationSpec.scala index 8bd03ab86c..e70033de45 100644 --- a/src/test/scala/ru/org/linux/search/ElasticsearchIndexServiceIntegrationSpec.scala +++ b/src/test/scala/ru/org/linux/search/ElasticsearchIndexServiceIntegrationSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 1998-2023 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -28,6 +28,7 @@ import org.testcontainers.utility.DockerImageName import ru.org.linux.AkkaConfiguration import ru.org.linux.auth.FloodProtector import ru.org.linux.search.ElasticsearchIndexService.MessageIndex +import ru.org.linux.spring.SiteConfig @ContextConfiguration(classes = Array(classOf[SearchIntegrationTestConfiguration], classOf[AkkaConfiguration])) @@ -57,11 +58,11 @@ class ElasticsearchIndexServiceIntegrationSpec extends SpecificationWithJUnit { basePackages = Array("ru.org.linux"), lazyInit = true, useDefaultFilters = false, + excludeFilters = Array( + new ComponentScan.Filter(`type` = FilterType.ASSIGNABLE_TYPE, value = Array(classOf[SiteConfig])) + ), includeFilters = Array( - new ComponentScan.Filter( - `type` = FilterType.ANNOTATION, - value = Array(classOf[Service], classOf[Repository]))) -) + new ComponentScan.Filter(`type` = FilterType.ANNOTATION, value = Array(classOf[Service], classOf[Repository])))) class SearchIntegrationTestConfiguration { @Bean(destroyMethod="close") def elasticClient: ElasticClient = {