lucene-dev mailing list archives

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


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.
  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));
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:
>             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:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message