You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Anton Luht (JIRA)" <ji...@apache.org> on 2006/12/16 09:24:23 UTC

[jira] Commented: (HARMONY-828) Preferences.nodeExists() throws IllegalArgumentException on a long path

    [ http://issues.apache.org/jira/browse/HARMONY-828?page=comments#action_12459006 ] 
            
Anton Luht commented on HARMONY-828:
------------------------------------

Verified at

svn = r485537, (Dec 11 2006), Windows/ia32/msvc 1310, debug build


> 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