Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-174

prevent stack overflow in case of erroneous cyclic reference

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • 2.5
    • Affects Version/s: 2.1
    • Component/s: Codecs
    • Labels:
      None

      Synthetic example, but possible real case:

      Domain class
      ---------------------------------------------

      public class E3 extends ReflectionDBObject {
      private String stringData;
      private E4 e4data;

      public E3() {
      }

      public E3(String stringData, E4 e4data)

      { this.stringData = stringData; this.e4data = e4data; }

      public String getStringData()

      { return stringData; }

      public void setStringData(String stringData)

      { this.stringData = stringData; }

      public E4 getE4data()

      { return e4data; }

      public void setE4data(E4 e4data)

      { this.e4data = e4data; }

      }

      Domain class
      ---------------------------------------------

      public class E4 extends ReflectionDBObject {
      private int integerData;
      private E3 e3data;

      public E4() {
      }

      public E4(int integerData, E3 e3data)

      { this.integerData = integerData; this.e3data = e3data; }

      public int getIntegerData()

      { return integerData; }

      public void setIntegerData(int integerData)

      { this.integerData = integerData; }

      public E3 getE3data()

      { return e3data; }

      public void setE3data(E3 e3data)

      { this.e3data = e3data; }

      }

      Application code
      ---------------------------------------------

      E3 e3 = new E3();
      E4 e4 = new E4(4, e3);
      e3.setE4data(e4);
      e3.setStringData("e3");

      coll.save(e3);

      ---------------------------------------------

      Exception in thread "main" java.lang.StackOverflowError
      ...
      at com.mongodb.ReflectionDBObject$JavaWrapper.get(ReflectionDBObject.java:155)
      at com.mongodb.ReflectionDBObject.get(ReflectionDBObject.java:31)
      at com.mongodb.DBCollection._checkKeys(DBCollection.java:852)
      at com.mongodb.DBCollection._checkKeys(DBCollection.java:853)
      at com.mongodb.DBCollection._checkKeys(DBCollection.java:853)
      ...

            Assignee:
            antoine Antoine Girbal
            Reporter:
            ilya Ilya Brodotsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: