harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulex Yang (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-828) [classlib][prefs] Preferences.nodeExists() throws IllegalArgumentException on a long path
Date Thu, 21 Dec 2006 11:17:24 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-828?page=all ]

Paulex Yang closed HARMONY-828.
-------------------------------


Sure, sorry for the delay. 

Verified by Anton.

> [classlib][prefs] Preferences.nodeExists() throws IllegalArgumentException on a long
path
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-828
>                 URL: http://issues.apache.org/jira/browse/HARMONY-828
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows XP Professional
>            Reporter: Anton Luht
>         Assigned To: Paulex Yang
>            Priority: Minor
>         Attachments: patch.txt
>
>
> Harmony: VM + classlib  revision 420760
> According to 1.5 specs method throws  IllegalArgumentException - if the path name is
invalid (i.e., it contains multiple consecutive slash characters, or ends with a slash character
and is more than one character long). 
> No limit for string length is specified.
> RI returns false in this case.
> import java.util.*;
> import java.util.prefs.*;
> public class test  {
>     public static void main (String[] args) { 
>         Preferences localPreferences = Preferences.userRoot();
>                 try {  
>                 String s ="ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd";
>                 System.out.println("len="+s.length());
>                         System.out.println("res="+localPreferences.nodeExists(s));
>                 } catch (BackingStoreException e) {
>                     e.printStackTrace();
>             }
>   } 
> } 
> Output on RI: 
> len=81
> res=false
> Output on Harmony:
> len=81
> java.lang.IllegalArgumentException: Name length is too long: ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
>         at java.util.prefs.AbstractPreferences.getNodeFromBackend(AbstractPreferences.java:613)
>         at java.util.prefs.AbstractPreferences.nodeImpl(AbstractPreferences.java:599)
>         at java.util.prefs.AbstractPreferences.nodeExists(AbstractPreferences.java:651)
>         at test.main(test.java:10)
> -----------
> The patch is quite simple:
> Index: modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
> ===================================================================
> --- modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
> (revision 420760)
> +++ modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
> (working copy)
> @@ -648,8 +648,12 @@
>                  startNode = this;
>              }
>          }
> -        Preferences result = startNode.nodeImpl(name, false);
> -        return null == result ? false : true;
> +        try {
> +          Preferences result = startNode.nodeImpl(name, false);
> +          return null == result ? false : true;
> +        } catch(IllegalArgumentException e) {
> +          return false;
> +        }
>      }
>      /*
> ------------------------
> Please note that this patch doesn't break the validation functionality, because try/catch
doesn't wrap validateName(...)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message