Bug 131710 - Undocumented behavior of com.sun.star.sdb.DatabaseContext implementation of com.sun.star.uno.XNamingService
Summary: Undocumented behavior of com.sun.star.sdb.DatabaseContext implementation of c...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.4.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks:
 
Reported: 2020-03-30 13:46 UTC by Oleg Shchelykalnov
Modified: 2020-11-12 04:52 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Shchelykalnov 2020-03-30 13:46:51 UTC
Documentation of the com.sun.star.uno.XNamingService declares registerObject method automatically revokes previously registered object. Instead DatabaseContext throws com.sun.star.container.ElementExistException with the name if object.

Same way XNamingService's revokeObject method declares to do nothing if no object was registered, but instead throws com.sun.star.container.NoSuchElementException.
Comment 1 Xisco Faulí 2020-03-31 12:27:31 UTC
@Stephan, I thought you might be interested in this issue
Comment 2 Xisco Faulí 2020-11-11 18:54:29 UTC
@Mike, could you please help with this issue ?
Comment 3 Mike Kaganski 2020-11-11 19:54:16 UTC
FTR: the definition of the interface behavior is given in udkapi/com/sun/star/uno/XNamingService.idl [1].

The implementation of DatabaseContext's registerObject is in dbaccess/source/core/dataaccess/databasecontext.cxx. After initial argument checks, it calls registerDatabaseLocation, which in turn calls DatabaseRegistrations::registerDatabaseLocation, and the latter calls impl_checkValidName_throw_must_not_exist.

So to conform to the documented behavior, DatabaseContext::registerObject should ensure to de-register existing registration for the name before trying to register.

Similar for revokeObject.

[1] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1uno_1_1XNamingService.html
Comment 4 Mike Kaganski 2020-11-12 04:23:43 UTC
By the way, OSDBCDriverManager::registerObject in connectivity/source/manager/mdrivermanager.cxx also throws in this case. Could be fixed in this easy hack.

The task includes checking commit history - if it contains hints why were the throws added; and also checking which places call these functions: should they be changed to account for the changed behaviour.