United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6889916 IntegrationService association API should check arguments
6889916 : IntegrationService association API should check arguments

Details
Type:
Bug
Submit Date:
2009-10-09
Status:
Closed
Updated Date:
2010-09-16
Project Name:
JDK
Resolved Date:
2010-01-13
Component:
deploy
OS:
generic
Sub-Component:
webstart
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u18
Fixed Versions:
6u18

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:

Sub Tasks

Description
requestAssociation with null file extension throws NPE 
java.lang.NullPointerException
	at com.sun.jnlp.IntegrationServiceImpl.requestAssociation(Unknown Source)

Since file extensions are optional parameter we may need to allow this or should throw IllegalArgumentException rather than throwing Null Pointer Exception. 

Example:
                IntegrationService is   = (IntegrationService)
                        ServiceManager.lookup("javax.jnlp.IntegrationService");
                String mime = "abc/xyz";
                boolean result = is.requestAssociation(mime,null);
Grouped 3 other CRs into this one, as it is really only one problem.
RequestAssociation with invalid mime returns true.

I am requesting Invalid MIME (Mime syntax is [any char]+/[any char]+). RequestAssociation is returning true. 

I think it should return false here. I understand we are not checking the syntax of mime type.(and expecting user will know this ) But I think it should be nice to check these to make the api more robust. 
Example:
                IntegrationService is   = (IntegrationService)
                        ServiceManager.lookup("javax.jnlp.IntegrationService");
                String mime = "abc";
                String [] exts = {".abc"};
                boolean result = is.requestAssociation(mime,exts);
*** (#1 of 1): 2009-10-09 09:05:21 MESZ ###@###.###
hasAssociation with empty file extension string {""} throws StringIndexOutOfBoundsException java
null file extension throws  NullPointerException. 
This is same as requestAssociation needs to change to either illegalArgumentException.

Suppose we have assocition like this 
    <association>
      <mime-type="application-x/swingset2-file"/>
    </association> 
If want to check  hasAssocition("application-x/swingset2-file",null or {""}) ? 
Is <extensions> are mandatory ?
*** (#1 of 1): 2009-10-09 06:36:52 MESZ ###@###.###
requestAssociation with empty file extension string {""} throws StringIndexOutOfBoundsException
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(Unknown Source)
	at com.sun.deploy.association.utility.AppUtility.addDotToFileExtension(Unknown Source)
	at com.sun.deploy.association.Association.addFileExtension(Unknown Source)
	at com.sun.jnlp.IntegrationServiceImpl.hasAssociation(Unknown Source)

Here again we may need throw either IllegalArgumentException or  should not create any association with file extension should not throw this Runtime Exception.
                IntegrationService is   = (IntegrationService)
                        ServiceManager.lookup("javax.jnlp.IntegrationService");
                String mime = "abc/xyz";
                String [] exts = {""};
                boolean result = is.requestAssociation(mime,exts);
*** (#1 of 1): 2009-10-09 06:25:37 MESZ ###@###.###
*** Last Edit: 2009-10-09 06:29:08 MESZ ###@###.###

                                    

Comments
EVALUATION

Added argument checking. Mimetype and extensions check now also throws IllegalArgumentException.
                                     
2009-10-16



Hardware and Software, Engineered to Work Together