Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d62d829c
Commit
d62d829c
authored
Oct 10, 2017
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
01186538
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
24 deletions
+30
-24
MongoClientFactory.java
...ramework/boot/autoconfigure/mongo/MongoClientFactory.java
+30
-22
JsonbAutoConfigurationTests.java
...boot/autoconfigure/jsonb/JsonbAutoConfigurationTests.java
+0
-1
pom.xml
spring-boot-samples/spring-boot-sample-custom-layout/pom.xml
+0
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java
View file @
d62d829c
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mongo
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -89,39 +88,48 @@ public class MongoClientFactory {
}
private
MongoClient
createNetworkMongoClient
(
MongoClientOptions
options
)
{
if
(
this
.
properties
.
getUri
()
!=
null
)
{
return
new
MongoClient
(
new
MongoClientURI
(
this
.
properties
.
getUri
(),
builder
(
options
))
);
MongoProperties
properties
=
this
.
properties
;
if
(
properties
.
getUri
()
!=
null
)
{
return
createMongoClient
(
properties
.
getUri
(),
options
);
}
if
(
hasCustomAddress
()
||
hasCustomCredentials
())
{
if
(
options
==
null
)
{
options
=
MongoClientOptions
.
builder
().
build
();
}
List
<
MongoCredential
>
credentials
=
new
ArrayList
<>();
if
(
hasCustomCredentials
())
{
String
database
=
this
.
properties
.
getAuthenticationDatabase
()
==
null
?
this
.
properties
.
getMongoClientDatabase
()
:
this
.
properties
.
getAuthenticationDatabase
();
credentials
.
add
(
MongoCredential
.
createCredential
(
this
.
properties
.
getUsername
(),
database
,
this
.
properties
.
getPassword
()));
}
String
host
=
this
.
properties
.
getHost
()
==
null
?
"localhost"
:
this
.
properties
.
getHost
();
int
port
=
this
.
properties
.
getPort
()
!=
null
?
this
.
properties
.
getPort
()
:
MongoProperties
.
DEFAULT_PORT
;
return
new
MongoClient
(
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
)),
credentials
,
options
);
List
<
MongoCredential
>
credentials
=
getCredentials
(
properties
);
String
host
=
getValue
(
properties
.
getHost
(),
"localhost"
);
int
port
=
getValue
(
properties
.
getPort
(),
MongoProperties
.
DEFAULT_PORT
);
List
<
ServerAddress
>
seeds
=
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
));
return
new
MongoClient
(
seeds
,
credentials
,
options
);
}
return
new
MongoClient
(
new
MongoClientURI
(
MongoProperties
.
DEFAULT_URI
,
builder
(
options
)));
return
createMongoClient
(
MongoProperties
.
DEFAULT_URI
,
options
);
}
private
MongoClient
createMongoClient
(
String
uri
,
MongoClientOptions
options
)
{
return
new
MongoClient
(
new
MongoClientURI
(
uri
,
builder
(
options
)));
}
private
<
T
>
T
getValue
(
T
value
,
T
fallback
)
{
return
(
value
==
null
?
fallback
:
value
);
}
private
boolean
hasCustomAddress
()
{
return
this
.
properties
.
getHost
()
!=
null
||
this
.
properties
.
getPort
()
!=
null
;
}
private
List
<
MongoCredential
>
getCredentials
(
MongoProperties
properties
)
{
if
(!
hasCustomCredentials
())
{
return
Collections
.
emptyList
();
}
String
username
=
properties
.
getUsername
();
String
database
=
getValue
(
properties
.
getAuthenticationDatabase
(),
properties
.
getMongoClientDatabase
());
char
[]
password
=
properties
.
getPassword
();
return
Collections
.
singletonList
(
MongoCredential
.
createCredential
(
username
,
database
,
password
));
}
private
boolean
hasCustomCredentials
()
{
return
this
.
properties
.
getUsername
()
!=
null
&&
this
.
properties
.
getPassword
()
!=
null
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfigurationTests.java
View file @
d62d829c
...
...
@@ -46,7 +46,6 @@ public class JsonbAutoConfigurationTests {
public
class
DataObject
{
@SuppressWarnings
(
"unused"
)
private
String
data
=
"hello"
;
public
String
getData
()
{
...
...
spring-boot-samples/spring-boot-sample-custom-layout/pom.xml
View file @
d62d829c
...
...
@@ -50,7 +50,6 @@
<addTestClassPath>
true
</addTestClassPath>
<skipInvocation>
${skipTests}
</skipInvocation>
<streamLogs>
true
</streamLogs>
<!-- <properties> <revision>${revision}</revision> </properties> -->
</configuration>
</execution>
</executions>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment