[ 
https://issues.apache.org/jira/browse/CAMEL-12142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16325948#comment-16325948
 ] 

ASF GitHub Bot commented on CAMEL-12142:
----------------------------------------

oscerd closed pull request #2176: CAMEL-12142 : default mongodb host
URL: https://github.com/apache/camel/pull/2176
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-mongodb-gridfs/src/test/java/org/apache/camel/component/mongodb/gridfs/EmbedMongoConfiguration.java
 
b/components/camel-mongodb-gridfs/src/test/java/org/apache/camel/component/mongodb/gridfs/EmbedMongoConfiguration.java
index a27dab83483..d26af360480 100644
--- 
a/components/camel-mongodb-gridfs/src/test/java/org/apache/camel/component/mongodb/gridfs/EmbedMongoConfiguration.java
+++ 
b/components/camel-mongodb-gridfs/src/test/java/org/apache/camel/component/mongodb/gridfs/EmbedMongoConfiguration.java
@@ -32,6 +32,7 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import static com.mongodb.ServerAddress.defaultHost;
 import static de.flapdoodle.embed.mongo.distribution.Version.Main.PRODUCTION;
 import static de.flapdoodle.embed.process.runtime.Network.localhostIsIPv6;
 import static org.springframework.util.SocketUtils.findAvailableTcpPort;
@@ -60,6 +61,6 @@
 
     @Bean
     public MongoClient myDb() throws UnknownHostException {
-        return new MongoClient("0.0.0.0", PORT);
+        return new MongoClient(defaultHost(), PORT);
     }
 }
\ No newline at end of file
diff --git 
a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/EmbedMongoConfiguration.java
 
b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/EmbedMongoConfiguration.java
index 6a8b50aa33e..5e5941b6c9c 100644
--- 
a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/EmbedMongoConfiguration.java
+++ 
b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/EmbedMongoConfiguration.java
@@ -28,6 +28,7 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import static com.mongodb.ServerAddress.defaultHost;
 import static de.flapdoodle.embed.mongo.distribution.Version.Main.PRODUCTION;
 import static de.flapdoodle.embed.process.runtime.Network.localhostIsIPv6;
 import static org.springframework.util.SocketUtils.findAvailableTcpPort;
@@ -52,7 +53,7 @@
 
     @Bean
     public MongoClient myDb() throws UnknownHostException {
-        return new MongoClient("0.0.0.0", PORT);
+        return new MongoClient(defaultHost(), PORT);
     }
 
 }
\ No newline at end of file
diff --git 
a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/EmbedMongoConfiguration.java
 
b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/EmbedMongoConfiguration.java
index 50c119c3100..53e92386bc9 100644
--- 
a/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/EmbedMongoConfiguration.java
+++ 
b/components/camel-mongodb3/src/test/java/org/apache/camel/component/mongodb3/EmbedMongoConfiguration.java
@@ -34,6 +34,7 @@
 import org.springframework.context.annotation.Configuration;
 
 import static com.mongodb.MongoClientOptions.builder;
+import static com.mongodb.ServerAddress.defaultHost;
 import static de.flapdoodle.embed.mongo.distribution.Version.Main.PRODUCTION;
 import static de.flapdoodle.embed.process.runtime.Network.localhostIsIPv6;
 import static org.springframework.util.SocketUtils.findAvailableTcpPort;
@@ -55,7 +56,7 @@
 
     @Bean
     public MongoClient myDb() throws UnknownHostException {
-        return new MongoClient("0.0.0.0", PORT);
+        return new MongoClient(defaultHost(), PORT);
     }
 
     @Bean


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Tests failed because of incorrect mongodb host
> ----------------------------------------------
>
>                 Key: CAMEL-12142
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12142
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mongodb, camel-mongodb3
>         Environment:  
>            Reporter: Farès Hassak
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 2.21.0
>
>
> Hello,
> The tests have failed in component camel-mongodb, camel-mongodb3, 
> camel-mongodb-gridfs:
> {noformat}
> com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to 
> connect. Client view of cluster state is {type=UNKNOWN, 
> servers=[{address=0.0.0.0:25313, type=UNKNOWN, state=CONNECTING, 
> exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, 
> caused by {java.net.SocketTimeoutException: connect timed out}}]
>       at 
> com.mongodb.connection.BaseCluster.getDescription(BaseCluster.java:167)
>       at com.mongodb.Mongo.getConnectedClusterDescription(Mongo.java:881)
>       at com.mongodb.Mongo.createClientSession(Mongo.java:873)
>       at com.mongodb.Mongo$3.getClientSession(Mongo.java:862)
>       at com.mongodb.Mongo$3.execute(Mongo.java:830)
>       at 
> com.mongodb.MongoCollectionImpl.executeDrop(MongoCollectionImpl.java:790)
>       at com.mongodb.MongoCollectionImpl.drop(MongoCollectionImpl.java:780)
>       at 
> org.apache.camel.component.mongodb.AbstractMongoDbTest.doPostSetup(AbstractMongoDbTest.java:60)
>       at 
> org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:271)
> {noformat}
> Because the client is using the wrong address when connecting to mongodb:
> {noformat}
> address=0.0.0.0
> {noformat}
> The MongoClient is created here :
> {code:java}
>  public class EmbedMongoConfiguration {
>  @Bean
>  public MongoClient myDb() throws UnknownHostException {
>         return new MongoClient("0.0.0.0", PORT);
>     }
> }
> {code}
> I suggest to use the default mongodb host : 
> {noformat}
> 127.0.0.1
> {noformat}
> As défined in ServerAdress class in mongodb java driver :
> {code:java}
> public class ServerAddress implements Serializable {
>   
>     /**
>      * Returns the default database host: "127.0.0.1"
>      *
>      * @return IP address of default host.
>      */
>     public static String defaultHost() {
>         return "127.0.0.1"; // NOPMD
>    } 
> }
> {code}
> The EmbedMongoConfiguration class should return a Mongclient object with 
> default mongodb host :
> {code:java}
>  public class EmbedMongoConfiguration {
>  @Bean
>  public MongoClient myDb() throws UnknownHostException {
>         return new MongoClient(defaultHost(), PORT);
>     }
> }
> {code}
> Here my configuration :
> {noformat}
> Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 
> 2017-10-18T09:58:13+02:00)
> Maven home: D:\apache-maven-3.5.2\bin\..
> Java version: 1.8.0_152, vendor: Oracle Corporation
> Java home: D:\jdk1.8.0_152\jre
> Default locale: fr_FR, platform encoding: Cp1252
> OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
> {noformat}
> Farès



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to