Scanner n'est jamais fermée

Je suis en train de travailler sur un jeu et je suis tombé sur un petit problème avec mon scanner.
J'ai une fuite de ressources scanner jamais fermé.

Mais je pensais que mon scanner travaillait avant sans la fermer.
Mais maintenant, il n'est pas. Quelqu'un peut m'aider ici?

import java.util.Scanner;

public class Main {

    public static final boolean CHEAT = true;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int amountOfPlayers;
        do {
            System.out.print("Select the amount of players (1/2): ");
            while (!scanner.hasNextInt()) {
                System.out.println("That's not a number!");
                scanner.next(); //this is important!
        }

        amountOfPlayers = scanner.nextInt();
        while ((amountOfPlayers <= 0) || (amountOfPlayers > 2));
        System.out.println("You've selected " + amountOfPlayers+" player(s)."); 
    }
}
  • Comment pouvez-vous dire que votre scanner ne fonctionne plus? Ce comportement voyez-vous?