Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-7585

Converting a pipeline to Java results in unresolved imports / errors

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.41.0
    • Component/s: Export to Language
    • None
    • Environment:
      OS: MacOS

      Converting a pipeline to Java using Compass (1.41.0) with the "include imports" and "include driver syntax" options both set to yes results in errors because two of the imports can't be resolved:

       

      import com.mongodb.MongoClient;
      import com.mongodb.MongoClientURI;

       
      These appear to be using the legacy API and neither appear to be in the 4.11.1 driver jar.The code the attempts to create a MongoClient using the legacy approach:
       

      MongoClient mongoClient = new MongoClient(
         new MongoClientURI(
            "mongodb+srv://<user>:<password>@perftestcluster.azzy6.mongodb.net/"
         )
      );

       
      But it then calls getDatabase, rather than getDB i.e. the modern API call, rather than the legacy call:

      MongoDatabase database = mongoClient.getDatabase("PerformanceWorkshop");

       
      Looks like this needs a bit of tidy up.
       
      This was observed in in an IntelliJ Gradle project with the 4.11.1 Java sync driver and JDK 17. 

            Assignee:
            Unassigned Unassigned
            Reporter:
            graeme.robinson@mongodb.com Graeme Robinson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: