Twasi / twasi-core

Core application and backend of the Twasi chatbot for Twitch.
MIT License
19 stars 4 forks source link

If you leave the mongodb password empty the server will crash while startup #5

Closed FDR123 closed 6 years ago

FDR123 commented 6 years ago

NPE:

INFORMATION: LoggerImplFactory set to org.mongodb.morphia.logging.jdk.JDKLoggerFactory
Exception in thread "main" java.lang.NullPointerException
    at net.twasi.core.database.Database.connect(Database.java:43)
    at net.twasi.core.Main.main(Main.java:27)

example twasi.yml

database:
  type: MongoDB # Only type that is supported
  hostname: localhost
  port: 27017
  user: root
  password:
  database: twasidb
  port: 27017
Laraakaa commented 6 years ago

I think it's expected to connect to MongoDB using no authentication if there is no password specified.

However, is this solution not very consistent. If you don't use authentication, then you don't want to specify an user either.

So I think the best solution to this is to put user and password into another nested property.

twasi.yml with authentication will look like this:

database:
  type: MongoDB
  hostname: localhost
  port: 27017
  database: twasidb
  authentication:
    user: twasi
    password: mySecurePassword

And without like this:

database:
  type: MongoDB
  hostname: localhost
  port: 27017
  database: twasidb
  authentication: none