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

MongoClient throws NumberFormatException when parsing http:// address

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 2.13.0, 3.0.0
    • 2.11.2
    • Error Handling
    • None

    Description

      import com.mongodb.MongoClient;
       
       
      public class MongoTest {
      	
      	public static void main(String[] args) throws Exception {
      		new MongoClient("http://something.com");
      	}
       
      }
       
      Exception in thread "main" java.lang.NumberFormatException: For input string: "//something.com"
      	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      	at java.lang.Integer.parseInt(Integer.java:481)
      	at java.lang.Integer.parseInt(Integer.java:527)
      	at com.mongodb.ServerAddress.<init>(ServerAddress.java:67)
      	at com.mongodb.ServerAddress.<init>(ServerAddress.java:46)
      	at com.mongodb.MongoClient.<init>(MongoClient.java:93)
      	at MongoTest.main(MongoTest.java:7)

      Expected behavior: throw a more relevant exception, or at least a MongoException.

      Attachments

        Activity

          People

            Unassigned Unassigned
            gaprice Gavin Price
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: