Issue 82876 - XPackageManager.addPackage(...) does not deal correctly with null in second String
Summary: XPackageManager.addPackage(...) does not deal correctly with null in second S...
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: jsc
QA Contact: issues@api
URL: http://api.openoffice.org/servlets/Re...
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-23 09:37 UTC by tobiaskrais
Modified: 2013-02-24 21:06 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description tobiaskrais 2007-10-23 09:37:37 UTC
I use the XPackageManager.addPackage() method. This method takes 4
arguments. The second is the "media-type of package, empty string if to
be detected". If I pass "null" for the second argument, the package is
installed without failures. But I cannot use my implemented protocol
handler! If I pass just an empty String (""), the package is also
installed (again, no failures while installing) and my protocol handler
works.
Solutions are:
1. Passing "null" should throw an exception and not install the extension
2. Passing "null" should have the same result as passing an empty string

I prefer solution 2, although I think this argument is not necessary at all,
because of the auto detection of the package type.
Comment 1 jsc 2007-10-23 12:54:04 UTC
jsc -> tobiaskrais: i tend to mark this issue as invalid because a null string
is no valid UNO string object in Java-UNO. But i would like to ask SB for his
opinion.

jsc -> sb: what do you think? The docu says it have to be an empty string. 
Comment 2 Stephan Bergmann 2007-10-30 15:03:27 UTC
If the issue is about Java UNO, yes, null is not a valid value here (see
<http://wiki.services.openoffice.org/wiki/Uno/Java/Specifications/Type_Mapping#Mapping_Types>).
 However, IIRC, both the Java URP bridge and the JNI bridge silently treat null
Strings the same as empty ones.
Comment 3 jsc 2007-11-05 07:48:44 UTC
any comments from your side Tobias? Otherwise i will mark it invalid and will
close it
Comment 4 tobiaskrais 2007-11-05 08:16:56 UTC
Yes, a comment from my side: I wasted some the, because I was not reading the
documentation very well. Maybe there are others like me...

My opinion is as sb wrote: if the null value is treated silently, it should work
correct or throw an exception. I think this is a very small fix at the beginning
of a method call like (Java):
-----%<-----
if(param == null) {
    param = "";
}
-----%<-----

I think: lets fix it.
Comment 5 jsc 2007-11-05 08:22:37 UTC
jsc -> jl: when you work on the code the next time can you please fix. Although
it's formal correct, the fix is simple and we can avoid confusion.
Comment 6 jsc 2007-11-05 08:48:27 UTC
back to me, sorry jl i didn't want confuse you. I talked with SB and he
convinced me that it doesn't make sense to fix it in the Package manager. SB
pointed out that the bridges silently treat null strings as empty ones. We will
check this again.

Comment 7 jsc 2007-11-05 08:48:54 UTC
back to me ...
Comment 8 jsc 2007-11-05 08:49:17 UTC
closed
Comment 9 Stephan Bergmann 2007-11-05 12:53:02 UTC
"SB pointed out that the bridges silently treat null strings as empty ones." 
For the records:  Just had a look at the code.  While using null strings as
arguments in UNO interface method calls is undefined behavior in Java UNO,
various scenarios do behave differently:

- The Java URP bridge silently treats null like ""
(jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java:1.19 l. 259).  The reason
is that this was the simplest way to support polymorphic structs.

- The JNI bridge throws a com.sun.star.uno.RuntimeException "[jni_uno bridge
error] Java calling UNO method createInstance: [map_to_uno():string] null-ref
given!" (bridges/source/jni_uno/jni_data.cxx:1.22 l. 407).

- Direct Java to Java calls simply pass the null (of course).

However, this differing behavior is covered by the specification and is IMO
acceptable.