Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4906193

StackOverflowError due to infinite recursion of java.util.Properties.getProperty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P2 P2
    • None
    • 1.3.1_09
    • core-libs
    • None
    • generic
    • solaris_8

      However please note that the *real* customer problem occurs over time and many
      iterations of this being called in a servlet based on your tutorial for JAAS (I
      don't have the link and I know that the tutorial code does not have a for loop, it has a call to setProperty which ultimately gets called repeatedly over time). This simple example speeds things up in order to demonstrate it more quickly.

      Yes, the stacksize can be set for this simple example but the point is that this is a cumulative effect over time and no matter what you would set the stack to it would eventually get a stackoverflow when you try to do a getProperty() on anything other than the property that has been repeatedly been set. In this case, if you try to get a propery other than "blah", then a stackoverflow. If you get the property "blah" then no stackoverflow.


      more stacktest.java
      import java.util.Properties;

      public class stacktest {

        public static void main(String args[]) {

          int max = 100000; // or some other large number depending on the stack size

          for ( int i = 0; i < max; i++ ) {
            Properties p = new Properties(System.getProperties());
            p.put("blah", "blah");
            System.setProperties(p);
          }

          System.out.println("Went through "+max+" iterations, now get a property");
          String s = System.getProperty("some property other than blah");
          // If we get the "blah" property instead of "some property other than blah" like
      //above at this point, then there is no stackoverflow.
      // String s = System.getProperty("blah");
        }

      }


      actual code from program is located at
      http://webhome.sfbay/rm111379/cases/63677192/TagUtility.java

      stack overflow does not happen when they comment out the following code:

      **********************
      reader = new BufferedReader
      (
                                   new InputStreamReader(urlConnection.getInputStream())
       );
      **********************
      This does not appear to be data related as we have verified the the
      input stream is well-formed HTML (not that this should matter).

            mmcclosksunw Michael Mccloskey (Inactive)
            msusko Mark Susko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: