Re: NullPointerException when connecting to a database which is shutting down
Fred Toussi via Hsqldb-user <[email protected]> Sun, 03 Sep 2017 15:34:38 +0100
| Newsgroups | gmane.comp.java.hsqldb.user |
|---|---|
| Message-ID | <1504449278.2155130.1093798000.1897D8BC@webmail.messagingengine.com> |
I have just checked the rest of the code related to shutdown. The
sessionManager.closeAllSessions() does not prevent new sessions to be
created after it is called, even it is synchronized. The creation of new
sessions needs to stop at the start of Database.close(), so I have added
a fail-safe check to the Database class: This will be committed after
running the stress tests.
synchronized Session connect(String username, String password,
String zoneString, int
timeZoneSeconds) {
if (getState() != DATABASE_ONLINE) {
throw Error.error(ErrorCode.X_08001);
}
Thanks for reporting.
Fred
On Sun, Sep 3, 2017, at 14:22, Fred Toussi via Hsqldb-user wrote:
> You need to run the latest version instead of looking at the code.
> Regarding your comment, only one session is allowed to close the
> database, therefore it doesn't matter if closeAllSessions() is
> synchronized or not. Code changes have also been made in other
> classes.>
> // Database.java
> public void close(int closemode) {
>
> HsqlException he = null;
>
> // multiple simultaneous close
> synchronized (this) {
> if (getState() != DATABASE_ONLINE) {
> return;
> }
>
> setState(DATABASE_CLOSING);
> }
>
> sessionManager.closeAllSessions();
>
> On Sun, Sep 3, 2017, at 10:51, Lucas Ventura Carro wrote:
>> 2017-09-01 13:39 GMT+02:00 Fred Toussi via Hsqldb-user <hsqldb-
>> [email protected]>:>>> __
>>> This was probably spotted and fixed in version 2.35 / 2.40 or even
>>> the snapshot released in July. Please check the code from SVN and
>>> see if it has been fixed.>>
>> No, don't seems to me as fixed: the Database.close() code looks the
>> same as 2.2.9, and SessionManager.closeAllSessions() still not
>> synchronized
>> (https://sourceforge.net/p/hsqldb/svn/HEAD/tree/base/trunk/src/org/hsqldb/SessionManager.java#l199)>>
>>
>> --
>> Lucas
>> ---------------------------------------------------------------------
>> --------->> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _________________________________________________
>> Hsqldb-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
>
> ----------------------------------------------------------------------
> --------> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _________________________________________________
> Hsqldb-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Hsqldb-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hsqldb-user