Bizarre Java error / error: stack overflow, null pointers and double locking

I really don't know how to correctly explain this error ...

It started when I added this method to my controller class:

public void loadPlayerComboBox() {
    try{
        final PreparedStatement collectPlayerNames = 
                ConnectionManager.getConnection().prepareStatement("SELECT "+PLAYER_NAME+"  FROM PLAYERS");
        final ResultSet playerNameResults = collectPlayerNames.executeQuery();
        while(playerNameResults.next()){
            IViewManager.Util.getInstance().getMyContainerPane().getMyPlayerManagerPane().getPlayerNameList()
            .add(playerNameResults.getString(PLAYER_NAME));
        }
    }catch(final SQLException e){
        System.out.println("SQLException. Reason: " + e.getMessage());
    }
}

And I confirmed that without this method (which is called by the class when the program starts), I have no error.

My mistake? When I get out of the eclipse, the program starts loading the top panel of the frame, but there is no actual content.

enter image description here

In addition, there is a strange trivial box, which, I believe, is caused by the launch of several processes.

, , , getInstance() . - , . .log, , . , . ViewManager:

static class Util {
    static private IViewManager viewManager = null;
    static public synchronized IViewManager getInstance() {
            if (viewManager == null) {
                    viewManager = new ViewManager();
            }
            return viewManager;
    }
}

:

public ViewManager(){
    super("Tony Larp DB Manager");
    this.setVisible(true);
    this.setDefaultCloseOperation(3);
    myContainerPane = new ContainerPane();
    myContentMenu = new ContentMenu();
    IController.Util.getInstance();
    IPlayerCharacterManager.Util.getInstance();
    this.setJMenuBar(myContentMenu);
    this.getContentPane().add(myContainerPane);
    this.pack();        
}

IController.Util.getInstance() , , , , . IViewManager.getInstance() , , .

, IViewManager.Util.getInstance() , IController.Util.getInstance() . .

​​? ?

+5
2

, - . , ( , ).

, . . , .

0

, : : -/

. , , . . , .

. :

, , . " ", . , ..

static class Util {
    public static final IViewManager viewManager = new ViewManager();
}

ViewManager ( ).

... .Util.getInstance(). Util.viewManager.

. . ViewManager . . . , combobox. SQL. MyPlayerManagerPane. .

, , - GameRepository? . GameRepository , :

...
ComboBoxModel playersModel = createPlayersModel(gameRepository.getPlayers());
playersCombobox.setModel(playersModel);
...

. . - , .

, ; -)

+1

All Articles