When using a different port for a localhost, the driver is defaulting back to port 27017 when GMongo is built with ServerAddress objects

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.10.1
    • Component/s: Connection Management
    • None
    • Environment:
      Windows 7, Java 7
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When connecting to a port other than 27017 on localhost, the GMongo driver will not work and default back to 27017 if using an array of ServerAddress objects. See code below. The last println prints the same as the second. It should print the same as the first.

      @Grab(group='org.mongodb', module='mongo-java-driver', version='2.10.1')

      import com.mongodb.*

      //tunnels to another mongo instance
      def mongo = new Mongo("localhost",29017)
      println "${mongo.getDatabaseNames()}"

      //my actual local
      mongo = new Mongo("localhost",27017)
      println "${mongo.getDatabaseNames()}"

      //BUG - try to do connect to remote cluster (29017 is the same as connected to above)
      mongo = new Mongo([new ServerAddress("localhost",29017), new ServerAddress("localhost",29018), new ServerAddress("localhost",29018)])
      println "${mongo.getDatabaseNames()}"
      //result is that this connects to 27017 on localhost instead of the other server addresses

        1. TestMongo.java
          0.8 kB
        2. TestMongo.java
          0.9 kB
        3. test-output.txt
          3 kB

            Assignee:
            Unassigned
            Reporter:
            Scott Roberts
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: