lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dawid Weiss (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-3847) LuceneTestCase should check for modifications on System properties
Date Mon, 05 Mar 2012 08:54:57 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-3847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222224#comment-13222224
] 

Dawid Weiss commented on LUCENE-3847:
-------------------------------------

Now I remember what it was that I had a problem with. Properties has the notion of "defaults"
so it falls back to another Properties by default if the key is not present. Unfortunately
get() is not overridden in Properties (and everything else is) so things like propertyNames
or getProperty will return a value from the fallback set, but get() won't.
{code}
  public static void main(String[] args) {
    Properties defaults = new Properties();
    Properties p = new Properties(defaults);
    String key = "custom-key";
    String value = "value";
    defaults.put(key, value);
    for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) {
      Object currentKey = e.nextElement();
      if (currentKey == key) {
        System.out.println("Default key found in propertyNames(), but...");
        System.out.println("p.get()=" + p.get(key));
        System.out.println("p.getProperty()=" + p.getProperty(key));
      }
    }
  }
{code}
You can easily corrupt other programs by inserting Object values into the system property
set -- any enumeration will then fail with a classcast. Still don't remember where this caused
a problem but it definitely was.
                
> LuceneTestCase should check for modifications on System properties
> ------------------------------------------------------------------
>
>                 Key: LUCENE-3847
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3847
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: general/test
>            Reporter: Dawid Weiss
>            Assignee: Dawid Weiss
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3847.patch
>
>
> - fail the test if changes have been detected.
> - revert the state of system properties before the suite.
> - cleanup after the suite.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message