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
249c675f
Commit
249c675f
authored
May 26, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-26672
parents
6424e3de
01dd68e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
9 deletions
+35
-9
ConfigDataLocationNotFoundException.java
...t/context/config/ConfigDataLocationNotFoundException.java
+13
-2
StandardConfigDataLocationResolver.java
...ot/context/config/StandardConfigDataLocationResolver.java
+8
-4
ConfigDataEnvironmentPostProcessorIntegrationTests.java
...g/ConfigDataEnvironmentPostProcessorIntegrationTests.java
+14
-3
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLocationNotFoundException.java
View file @
249c675f
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -44,7 +44,18 @@ public class ConfigDataLocationNotFoundException extends ConfigDataNotFoundExcep
...
@@ -44,7 +44,18 @@ public class ConfigDataLocationNotFoundException extends ConfigDataNotFoundExcep
* @param cause the exception cause
* @param cause the exception cause
*/
*/
public
ConfigDataLocationNotFoundException
(
ConfigDataLocation
location
,
Throwable
cause
)
{
public
ConfigDataLocationNotFoundException
(
ConfigDataLocation
location
,
Throwable
cause
)
{
super
(
getMessage
(
location
),
cause
);
this
(
location
,
getMessage
(
location
),
cause
);
}
/**
* Create a new {@link ConfigDataLocationNotFoundException} instance.
* @param location the location that could not be found
* @param message the exception message
* @param cause the exception cause
* @since 2.4.7
*/
public
ConfigDataLocationNotFoundException
(
ConfigDataLocation
location
,
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
Assert
.
notNull
(
location
,
"Location must not be null"
);
Assert
.
notNull
(
location
,
"Location must not be null"
);
this
.
location
=
location
;
this
.
location
=
location
;
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/StandardConfigDataLocationResolver.java
View file @
249c675f
...
@@ -43,6 +43,7 @@ import org.springframework.core.io.ResourceLoader;
...
@@ -43,6 +43,7 @@ import org.springframework.core.io.ResourceLoader;
import
org.springframework.core.io.support.SpringFactoriesLoader
;
import
org.springframework.core.io.support.SpringFactoriesLoader
;
import
org.springframework.core.log.LogMessage
;
import
org.springframework.core.log.LogMessage
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
/**
/**
...
@@ -265,10 +266,13 @@ public class StandardConfigDataLocationResolver
...
@@ -265,10 +266,13 @@ public class StandardConfigDataLocationResolver
}
}
private
Set
<
StandardConfigDataResource
>
resolvePatternEmptyDirectories
(
StandardConfigDataReference
reference
)
{
private
Set
<
StandardConfigDataResource
>
resolvePatternEmptyDirectories
(
StandardConfigDataReference
reference
)
{
Resource
[]
resources
=
this
.
resourceLoader
.
getResources
(
reference
.
getDirectory
(),
ResourceType
.
DIRECTORY
);
Resource
[]
subdirectories
=
this
.
resourceLoader
.
getResources
(
reference
.
getDirectory
(),
ResourceType
.
DIRECTORY
);
Assert
.
state
(
resources
.
length
>
0
,
ConfigDataLocation
location
=
reference
.
getConfigDataLocation
();
"No subdirectories found for mandatory directory location '"
+
reference
.
getDirectory
()
+
"'."
);
if
(
location
.
isOptional
()
&&
ObjectUtils
.
isEmpty
(
subdirectories
))
{
return
Arrays
.
stream
(
resources
).
filter
(
Resource:
:
exists
)
String
message
=
String
.
format
(
"Config data location '%s' contains no subdirectories"
,
location
);
throw
new
ConfigDataLocationNotFoundException
(
location
,
message
,
null
);
}
return
Arrays
.
stream
(
subdirectories
).
filter
(
Resource:
:
exists
)
.
map
((
resource
)
->
new
StandardConfigDataResource
(
reference
,
resource
,
true
))
.
map
((
resource
)
->
new
StandardConfigDataResource
(
reference
,
resource
,
true
))
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java
View file @
249c675f
...
@@ -713,10 +713,9 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
...
@@ -713,10 +713,9 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
@Test
@Test
void
runWhenMandatoryWildcardLocationHasNoSubdirectories
()
{
void
runWhenMandatoryWildcardLocationHasNoSubdirectories
()
{
assertThat
IllegalStateException
(
).
isThrownBy
(
assertThat
ExceptionOfType
(
ConfigDataLocationNotFoundException
.
class
).
isThrownBy
(
()
->
this
.
application
.
run
(
"--spring.config.location=file:src/test/resources/config/0-empty/*/"
))
()
->
this
.
application
.
run
(
"--spring.config.location=file:src/test/resources/config/0-empty/*/"
))
.
withMessage
(
.
withMessage
(
"Config data location 'file:src/test/resources/config/0-empty/*/' cannot be found"
);
"No subdirectories found for mandatory directory location 'file:src/test/resources/config/0-empty/*/'."
);
}
}
@Test
@Test
...
@@ -725,6 +724,18 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
...
@@ -725,6 +724,18 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
.
isThrownBy
(()
->
this
.
application
.
run
(
"--spring.config.location=file:invalid/*/"
));
.
isThrownBy
(()
->
this
.
application
.
run
(
"--spring.config.location=file:invalid/*/"
));
}
}
@Test
void
runWhenHasOptionalWildcardLocationThatDoesNotExistDoesNotThrow
()
{
assertThatNoException
()
.
isThrownBy
(()
->
this
.
application
.
run
(
"--spring.config.location=optional:file:invalid/*/"
));
}
@Test
void
runWhenOptionalWildcardLocationHasNoSubdirectoriesDoesNotThrow
()
{
assertThatNoException
().
isThrownBy
(()
->
this
.
application
.
run
(
"--spring.config.location=optional:file:src/test/resources/config/0-empty/*/"
));
}
@Test
// gh-24990
@Test
// gh-24990
void
runWhenHasProfileSpecificFileWithActiveOnProfileProperty
()
{
void
runWhenHasProfileSpecificFileWithActiveOnProfileProperty
()
{
ConfigurableApplicationContext
context
=
this
.
application
ConfigurableApplicationContext
context
=
this
.
application
...
...
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