Skip to content

Commit 1698f9d

Browse files
authored
Merge pull request eugenp#5583 from simbo1905/master
use of static variables is concurrency problem
2 parents ee6162e + 5d4d8ff commit 1698f9d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BookController.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@
2121
@Controller
2222
public class BookController {
2323

24-
private static int currentPage = 1;
25-
private static int pageSize = 5;
26-
2724
@Autowired
2825
private BookService bookService;
29-
26+
3027
@RequestMapping(value = "/listBooks", method = RequestMethod.GET)
3128
public String listBooks(Model model, @RequestParam("page") Optional<Integer> page, @RequestParam("size") Optional<Integer> size) {
32-
page.ifPresent(p -> currentPage = p);
33-
size.ifPresent(s -> pageSize = s);
29+
final int currentPage = page.orElse(1);
30+
final int pageSize = size.orElse(5);
3431

3532
Page<Book> bookPage = bookService.findPaginated(PageRequest.of(currentPage - 1, pageSize));
3633

0 commit comments

Comments
 (0)