greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

Blocker issue in Sonarqube #1097

Closed bj6785 closed 1 year ago

bj6785 commented 2 years ago

In AutoCreated file DaoMaster.java file, we can see the code:

public static DaoSession newDevSession(Context context, String name) {
   Database db = new DevOpenHelper(context, name).getWritableDb();
   DaoMaster daoMaster = new DaoMaster(db);
  return daoMaster.newSession();

}

the sonarqube show: Use try-with-resources or close this "DevOpenHelper" in a "finally" clause. Resources should be closed

greenrobot-team commented 2 years ago

The code is correct, the database should remain open. Otherwise the returned DaoSession would have no database to work with.

I suggest to ignore this message (maybe add a note).

greenrobot-team commented 1 year ago

Closing this issue due to inactivity. :zzz: Feel free to comment with more details or submit a new issue.