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
2d2e4eea
Commit
2d2e4eea
authored
Dec 10, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
66fe9536
2694605a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
50 deletions
+62
-50
MetricFilterAutoConfigurationTests.java
...ate/autoconfigure/MetricFilterAutoConfigurationTests.java
+2
-1
ConfigurationMetadataAnnotationProcessor.java
...onprocessor/ConfigurationMetadataAnnotationProcessor.java
+21
-26
ConfigurationMetadataAnnotationProcessorTests.java
...cessor/ConfigurationMetadataAnnotationProcessorTests.java
+30
-13
TestProject.java
...ingframework/boot/configurationprocessor/TestProject.java
+2
-2
LombokInnerClassProperties.java
...onfigurationsample/lombok/LombokInnerClassProperties.java
+2
-0
SimpleLombokPojo.java
...ork/boot/configurationsample/lombok/SimpleLombokPojo.java
+1
-0
AnsiOutput.java
...c/main/java/org/springframework/boot/ansi/AnsiOutput.java
+4
-8
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfigurationTests.java
View file @
2d2e4eea
...
...
@@ -180,7 +180,8 @@ public class MetricFilterAutoConfigurationTests {
@Test
public
void
skipsFilterIfPropertyDisabled
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
context
,
"endpoints.metrics.filter.enabled:false"
);
EnvironmentTestUtils
.
addEnvironment
(
context
,
"endpoints.metrics.filter.enabled:false"
);
context
.
register
(
Config
.
class
,
MetricFilterAutoConfiguration
.
class
);
context
.
refresh
();
assertThat
(
context
.
getBeansOfType
(
Filter
.
class
).
size
(),
equalTo
(
0
));
...
...
spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java
View file @
2d2e4eea
...
...
@@ -276,19 +276,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
String
name
=
entry
.
getKey
();
ExecutableElement
getter
=
entry
.
getValue
();
VariableElement
field
=
members
.
getFields
().
get
(
name
);
Element
returnType
=
this
.
processingEnv
.
getTypeUtils
()
.
asElement
(
getter
.
getReturnType
());
AnnotationMirror
annotation
=
getAnnotation
(
getter
,
configurationPropertiesAnnotation
());
boolean
isNested
=
isNested
(
returnType
,
field
,
element
);
if
(
returnType
!=
null
&&
returnType
instanceof
TypeElement
&&
annotation
==
null
&&
isNested
)
{
String
nestedPrefix
=
ConfigurationMetadata
.
nestedPrefix
(
prefix
,
name
);
this
.
metadataCollector
.
add
(
ItemMetadata
.
newGroup
(
nestedPrefix
,
this
.
typeUtils
.
getType
(
returnType
),
this
.
typeUtils
.
getType
(
element
),
getter
.
toString
()));
processTypeElement
(
nestedPrefix
,
(
TypeElement
)
returnType
);
}
processNestedType
(
prefix
,
element
,
name
,
getter
,
field
,
getter
.
getReturnType
());
}
}
...
...
@@ -297,19 +286,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
for
(
Map
.
Entry
<
String
,
VariableElement
>
entry
:
members
.
getFields
().
entrySet
())
{
String
name
=
entry
.
getKey
();
VariableElement
field
=
entry
.
getValue
();
if
(!
isLombokField
(
field
,
element
))
{
continue
;
}
Element
returnType
=
this
.
processingEnv
.
getTypeUtils
()
.
asElement
(
field
.
asType
());
boolean
isNested
=
isNested
(
returnType
,
field
,
element
);
if
(
returnType
!=
null
&&
returnType
instanceof
TypeElement
&&
isNested
)
{
String
nestedPrefix
=
ConfigurationMetadata
.
nestedPrefix
(
prefix
,
name
);
this
.
metadataCollector
.
add
(
ItemMetadata
.
newGroup
(
nestedPrefix
,
this
.
typeUtils
.
getType
(
returnType
),
this
.
typeUtils
.
getType
(
element
),
null
));
processTypeElement
(
nestedPrefix
,
(
TypeElement
)
returnType
);
if
(
isLombokField
(
field
,
element
))
{
processNestedType
(
prefix
,
element
,
name
,
null
,
field
,
field
.
asType
());
}
}
}
...
...
@@ -327,6 +305,23 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
||
hasAnnotation
(
element
,
LOMBOK_DATA_ANNOTATION
));
}
private
void
processNestedType
(
String
prefix
,
TypeElement
element
,
String
name
,
ExecutableElement
getter
,
VariableElement
field
,
TypeMirror
returnType
)
{
Element
returnElement
=
this
.
processingEnv
.
getTypeUtils
().
asElement
(
returnType
);
boolean
isNested
=
isNested
(
returnElement
,
field
,
element
);
AnnotationMirror
annotation
=
getAnnotation
(
getter
,
configurationPropertiesAnnotation
());
if
(
returnElement
!=
null
&&
returnElement
instanceof
TypeElement
&&
annotation
==
null
&&
isNested
)
{
String
nestedPrefix
=
ConfigurationMetadata
.
nestedPrefix
(
prefix
,
name
);
this
.
metadataCollector
.
add
(
ItemMetadata
.
newGroup
(
nestedPrefix
,
this
.
typeUtils
.
getType
(
returnElement
),
this
.
typeUtils
.
getType
(
element
),
(
getter
==
null
?
null
:
getter
.
toString
())));
processTypeElement
(
nestedPrefix
,
(
TypeElement
)
returnElement
);
}
}
private
boolean
isNested
(
Element
returnType
,
VariableElement
field
,
TypeElement
element
)
{
if
(
hasAnnotation
(
field
,
nestedConfigurationPropertyAnnotation
()))
{
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
View file @
2d2e4eea
...
...
@@ -366,11 +366,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat
(
metadata
,
containsProperty
(
"config.second.bar.name"
));
assertThat
(
metadata
,
containsGroup
(
"config.third"
).
ofType
(
SimpleLombokPojo
.
class
)
.
fromSource
(
LombokInnerClassProperties
.
class
));
// For some reason the annotation processor resolves a type for SimpleLombokPojo that
// is resolved (compiled) and the source annotations are gone. Because we don't see the
// @Data annotation anymore, no field is harvested. What is crazy is that a sample project
// works fine so this seem to be related to the unit test environment for some reason.
//assertThat(metadata, containsProperty("config.third.value"));
// For some reason the annotation processor resolves a type for SimpleLombokPojo
// that is resolved (compiled) and the source annotations are gone. Because we
// don't see the @Data annotation anymore, no field is harvested. What is crazy is
// that a sample project works fine so this seem to be related to the unit test
// environment for some reason. assertThat(metadata,
// containsProperty("config.third.value"));
assertThat
(
metadata
,
containsProperty
(
"config.fourth"
));
assertThat
(
metadata
,
not
(
containsGroup
(
"config.fourth"
)));
}
...
...
@@ -507,34 +508,52 @@ public class ConfigurationMetadataAnnotationProcessorTests {
.
withDeprecation
(
"Lame name."
,
"simple.the-name"
));
}
@Test
public
void
mergingOfAdditionalMetadata
()
throws
Exception
{
File
metaInfFolder
=
new
File
(
this
.
compiler
.
getOutputLocation
(),
"META-INF"
);
metaInfFolder
.
mkdirs
();
File
additionalMetadataFile
=
new
File
(
metaInfFolder
,
"additional-spring-configuration-metadata.json"
);
additionalMetadataFile
.
createNewFile
();
JSONObject
property
=
new
JSONObject
();
property
.
put
(
"name"
,
"foo"
);
property
.
put
(
"type"
,
"java.lang.String"
);
property
.
put
(
"sourceType"
,
AdditionalMetadata
.
class
.
getName
());
JSONArray
properties
=
new
JSONArray
();
properties
.
put
(
property
);
JSONObject
additionalMetadata
=
new
JSONObject
();
additionalMetadata
.
put
(
"properties"
,
properties
);
FileWriter
writer
=
new
FileWriter
(
additionalMetadataFile
);
additionalMetadata
.
write
(
writer
);
writer
.
flush
();
ConfigurationMetadata
metadata
=
compile
(
SimpleProperties
.
class
);
assertThat
(
metadata
,
containsProperty
(
"simple.comparator"
));
assertThat
(
metadata
,
containsProperty
(
"foo"
,
String
.
class
)
.
fromSource
(
AdditionalMetadata
.
class
));
}
@Test
public
void
incrementalBuild
()
throws
Exception
{
TestProject
project
=
new
TestProject
(
this
.
temporaryFolder
,
FooProperties
.
class
,
BarProperties
.
class
);
assertFalse
(
project
.
getOutputFile
(
MetadataStore
.
METADATA_PATH
).
exists
());
ConfigurationMetadata
metadata
=
project
.
fullBuild
();
assertTrue
(
project
.
getOutputFile
(
MetadataStore
.
METADATA_PATH
).
exists
());
assertThat
(
metadata
,
containsProperty
(
"foo.counter"
).
fromSource
(
FooProperties
.
class
));
assertThat
(
metadata
,
containsProperty
(
"bar.counter"
).
fromSource
(
BarProperties
.
class
));
metadata
=
project
.
incrementalBuild
(
BarProperties
.
class
);
assertThat
(
metadata
,
containsProperty
(
"foo.counter"
).
fromSource
(
FooProperties
.
class
));
assertThat
(
metadata
,
containsProperty
(
"bar.counter"
).
fromSource
(
BarProperties
.
class
));
project
.
addSourceCode
(
BarProperties
.
class
,
BarProperties
.
class
.
getResourceAsStream
(
"BarProperties.snippet"
));
metadata
=
project
.
incrementalBuild
(
BarProperties
.
class
);
assertThat
(
metadata
,
containsProperty
(
"bar.extra"
));
assertThat
(
metadata
,
containsProperty
(
"foo.counter"
));
assertThat
(
metadata
,
containsProperty
(
"bar.counter"
));
project
.
revert
(
BarProperties
.
class
);
metadata
=
project
.
incrementalBuild
(
BarProperties
.
class
);
assertThat
(
metadata
,
not
(
containsProperty
(
"bar.extra"
)));
...
...
@@ -549,7 +568,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata
metadata
=
project
.
fullBuild
();
assertThat
(
metadata
,
containsProperty
(
"foo.counter"
));
assertThat
(
metadata
,
containsProperty
(
"bar.counter"
));
project
.
replaceText
(
BarProperties
.
class
,
"@ConfigurationProperties"
,
"//@ConfigurationProperties"
);
metadata
=
project
.
incrementalBuild
(
BarProperties
.
class
);
...
...
@@ -568,7 +586,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
containsProperty
(
"bar.counter"
).
fromSource
(
BarProperties
.
class
));
assertThat
(
metadata
,
not
(
containsProperty
(
"bar.counter"
).
fromSource
(
RenamedBarProperties
.
class
)));
project
.
delete
(
BarProperties
.
class
);
project
.
add
(
RenamedBarProperties
.
class
);
metadata
=
project
.
incrementalBuild
(
RenamedBarProperties
.
class
);
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java
View file @
2d2e4eea
...
...
@@ -161,7 +161,7 @@ public class TestProject {
/**
* Restore source code of given class to its original contents.
* @param type the class to revert
* @throws IOException
in case of I/O errors
* @throws IOException
on IO error
*/
public
void
revert
(
Class
<?>
type
)
throws
IOException
{
Assert
.
assertTrue
(
getSourceFile
(
type
).
exists
());
...
...
@@ -171,7 +171,7 @@ public class TestProject {
/**
* Add source code of given class to this project.
* @param type the class to add
* @throws IOException
in case of I/O errors
* @throws IOException
on IO error
*/
public
void
add
(
Class
<?>
type
)
throws
IOException
{
Assert
.
assertFalse
(
getSourceFile
(
type
).
exists
());
...
...
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/lombok/LombokInnerClassProperties.java
View file @
2d2e4eea
...
...
@@ -28,6 +28,7 @@ import org.springframework.boot.configurationsample.NestedConfigurationProperty;
*/
@Data
@ConfigurationProperties
(
prefix
=
"config"
)
@SuppressWarnings
(
"unused"
)
public
class
LombokInnerClassProperties
{
private
final
Foo
first
=
new
Foo
();
...
...
@@ -58,4 +59,5 @@ public class LombokInnerClassProperties {
public
enum
Fourth
{
YES
,
NO
}
}
spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/lombok/SimpleLombokPojo.java
View file @
2d2e4eea
...
...
@@ -24,6 +24,7 @@ import lombok.Data;
* @author Stephane Nicoll
*/
@Data
@SuppressWarnings
(
"unused"
)
public
class
SimpleLombokPojo
{
private
int
value
;
...
...
spring-boot/src/main/java/org/springframework/boot/ansi/AnsiOutput.java
View file @
2d2e4eea
...
...
@@ -133,19 +133,15 @@ public abstract class AnsiOutput {
private
static
boolean
isEnabled
()
{
if
(
enabled
==
Enabled
.
DETECT
)
{
return
detectIfAnsiCapable
();
if
(
ansiCapable
==
null
)
{
ansiCapable
=
detectIfAnsiCapable
();
}
return
ansiCapable
;
}
return
enabled
==
Enabled
.
ALWAYS
;
}
private
static
boolean
detectIfAnsiCapable
()
{
if
(
ansiCapable
==
null
)
{
ansiCapable
=
doDetectIfAnsiCapable
();
}
return
ansiCapable
;
}
private
static
boolean
doDetectIfAnsiCapable
()
{
try
{
if
(
Boolean
.
FALSE
.
equals
(
consoleAvailable
))
{
return
false
;
...
...
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