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
16495d22
Commit
16495d22
authored
Mar 16, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
bdd61b8e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
45 deletions
+53
-45
MetricRegistryMetricReader.java
...ot/actuate/metrics/reader/MetricRegistryMetricReader.java
+10
-13
MetricRegistryMetricReaderTests.java
...tuate/metrics/reader/MetricRegistryMetricReaderTests.java
+2
-1
DataSourceInitializer.java
...mework/boot/autoconfigure/jdbc/DataSourceInitializer.java
+3
-3
ActiveMQConnectionFactoryConfiguration.java
.../jms/activemq/ActiveMQConnectionFactoryConfiguration.java
+5
-9
UndertowEmbeddedServletContainer.java
...t/embedded/undertow/UndertowEmbeddedServletContainer.java
+33
-19
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/reader/MetricRegistryMetricReader.java
View file @
16495d22
...
@@ -57,7 +57,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
...
@@ -57,7 +57,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
private
static
Log
logger
=
LogFactory
.
getLog
(
MetricRegistryMetricReader
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
MetricRegistryMetricReader
.
class
);
private
static
final
Map
<
Class
<?>,
Set
<
String
>>
NUMBER_KEYS
=
new
ConcurrentHashMap
<
Class
<?>,
Set
<
String
>>();
private
static
final
Map
<
Class
<?>,
Set
<
String
>>
numberKeys
=
new
ConcurrentHashMap
<
Class
<?>,
Set
<
String
>>();
private
final
Object
monitor
=
new
Object
();
private
final
Object
monitor
=
new
Object
();
...
@@ -129,17 +129,16 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
...
@@ -129,17 +129,16 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
@Override
@Override
public
void
onGaugeAdded
(
String
name
,
Gauge
<?>
gauge
)
{
public
void
onGaugeAdded
(
String
name
,
Gauge
<?>
gauge
)
{
if
(
gauge
.
getValue
()
instanceof
Number
)
{
if
(
!(
gauge
.
getValue
()
instanceof
Number
)
)
{
this
.
names
.
put
(
name
,
name
);
if
(
logger
.
isDebugEnabled
())
{
synchronized
(
this
.
monitor
)
{
logger
.
debug
(
"Ignoring gauge '"
+
name
+
"' ("
+
gauge
this
.
reverse
.
add
(
name
,
name
);
+
") as its value is not a Number"
);
}
}
return
;
return
;
}
}
this
.
names
.
put
(
name
,
name
);
if
(
logger
.
isDebugEnabled
())
{
synchronized
(
this
.
monitor
)
{
logger
.
debug
(
"Ignoring gauge '"
+
name
+
"' ("
+
gauge
this
.
reverse
.
add
(
name
,
name
);
+
") as its value is not a Number"
);
}
}
}
}
...
@@ -225,11 +224,9 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
...
@@ -225,11 +224,9 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
private
void
remove
(
String
name
)
{
private
void
remove
(
String
name
)
{
List
<
String
>
keys
;
List
<
String
>
keys
;
synchronized
(
this
.
monitor
)
{
synchronized
(
this
.
monitor
)
{
keys
=
this
.
reverse
.
remove
(
name
);
keys
=
this
.
reverse
.
remove
(
name
);
}
}
if
(
keys
!=
null
)
{
if
(
keys
!=
null
)
{
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
this
.
names
.
remove
(
name
+
"."
+
key
);
this
.
names
.
remove
(
name
+
"."
+
key
);
...
@@ -238,7 +235,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
...
@@ -238,7 +235,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
}
}
private
static
Set
<
String
>
getNumberKeys
(
Object
metric
)
{
private
static
Set
<
String
>
getNumberKeys
(
Object
metric
)
{
Set
<
String
>
result
=
NUMBER_KEYS
.
get
(
metric
.
getClass
());
Set
<
String
>
result
=
numberKeys
.
get
(
metric
.
getClass
());
if
(
result
==
null
)
{
if
(
result
==
null
)
{
result
=
new
HashSet
<
String
>();
result
=
new
HashSet
<
String
>();
}
}
...
@@ -249,7 +246,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
...
@@ -249,7 +246,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
result
.
add
(
descriptor
.
getName
());
result
.
add
(
descriptor
.
getName
());
}
}
}
}
NUMBER_KEYS
.
put
(
metric
.
getClass
(),
result
);
numberKeys
.
put
(
metric
.
getClass
(),
result
);
}
}
return
result
;
return
result
;
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/reader/MetricRegistryMetricReaderTests.java
View file @
16495d22
...
@@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.nullValue;
...
@@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.nullValue;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
/**
* Tests for {@link MetricRegistryMetricReader}
* Tests for {@link MetricRegistryMetricReader}
.
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
...
@@ -73,4 +73,5 @@ public class MetricRegistryMetricReaderTests {
...
@@ -73,4 +73,5 @@ public class MetricRegistryMetricReaderTests {
this
.
metricRegistry
.
remove
(
"test"
);
this
.
metricRegistry
.
remove
(
"test"
);
assertThat
(
this
.
metricReader
.
findOne
(
"test"
),
is
(
nullValue
()));
assertThat
(
this
.
metricReader
.
findOne
(
"test"
),
is
(
nullValue
()));
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java
View file @
16495d22
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -63,8 +63,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
...
@@ -63,8 +63,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
logger
.
debug
(
"Initialization disabled (not running DDL scripts)"
);
logger
.
debug
(
"Initialization disabled (not running DDL scripts)"
);
return
;
return
;
}
}
if
(
applicationContext
.
getBeanNamesForType
(
DataSource
.
class
,
false
,
false
).
length
>
0
)
{
if
(
this
.
applicationContext
.
getBeanNamesForType
(
DataSource
.
class
,
false
,
false
).
length
>
0
)
{
this
.
dataSource
=
applicationContext
.
getBean
(
DataSource
.
class
);
this
.
dataSource
=
this
.
applicationContext
.
getBean
(
DataSource
.
class
);
}
}
if
(
this
.
dataSource
==
null
)
{
if
(
this
.
dataSource
==
null
)
{
logger
.
debug
(
"No DataSource found so not initializing"
);
logger
.
debug
(
"No DataSource found so not initializing"
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryConfiguration.java
View file @
16495d22
...
@@ -25,6 +25,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
...
@@ -25,6 +25,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
/**
/**
...
@@ -46,15 +47,10 @@ class ActiveMQConnectionFactoryConfiguration {
...
@@ -46,15 +47,10 @@ class ActiveMQConnectionFactoryConfiguration {
properties
).
createConnectionFactory
(
ActiveMQConnectionFactory
.
class
);
properties
).
createConnectionFactory
(
ActiveMQConnectionFactory
.
class
);
if
(
properties
.
isPooled
())
{
if
(
properties
.
isPooled
())
{
PooledConnectionFactory
pool
=
new
PooledConnectionFactory
();
PooledConnectionFactory
pool
=
new
PooledConnectionFactory
();
Method
connectionFactorySetter
=
findConnectionFactorySetter
();
Method
setConnectionFactory
=
findConnectionFactorySetter
();
if
(
connectionFactorySetter
!=
null
)
{
Assert
.
state
(
setConnectionFactory
!=
null
,
"No supported "
ReflectionUtils
.
invokeMethod
(
connectionFactorySetter
,
pool
,
+
"setConnectionFactory method was found"
);
connectionFactory
);
ReflectionUtils
.
invokeMethod
(
setConnectionFactory
,
pool
,
connectionFactory
);
}
else
{
throw
new
IllegalStateException
(
"No supported setConnectionFactory method was found"
);
}
return
pool
;
return
pool
;
}
}
return
connectionFactory
;
return
connectionFactory
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainer.java
View file @
16495d22
...
@@ -141,27 +141,33 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
...
@@ -141,27 +141,33 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
}
}
private
Port
getPortFromChannel
(
Object
channel
)
{
private
Port
getPortFromChannel
(
Object
channel
)
{
Object
tcpServer
;
Object
tcpServer
=
channel
;
String
protocol
;
String
protocol
=
"http"
;
Field
sslContext
=
ReflectionUtils
.
findField
(
channel
.
getClass
(),
"sslContext"
);
Field
sslContext
=
ReflectionUtils
.
findField
(
channel
.
getClass
(),
"sslContext"
);
if
(
sslContext
!=
null
)
{
if
(
sslContext
!=
null
)
{
Field
tcpServerField
=
ReflectionUtils
.
findField
(
channel
.
getClass
(),
tcpServer
=
getTcpServer
(
channel
);
"tcpServer"
);
ReflectionUtils
.
makeAccessible
(
tcpServerField
);
tcpServer
=
ReflectionUtils
.
getField
(
tcpServerField
,
channel
);
protocol
=
"https"
;
protocol
=
"https"
;
}
}
else
{
ServerSocket
socket
=
getSocket
(
tcpServer
);
tcpServer
=
channel
;
if
(
socket
!=
null
)
{
protocol
=
"http"
;
return
new
Port
(
socket
.
getLocalPort
(),
protocol
)
;
}
}
return
null
;
}
private
Object
getTcpServer
(
Object
channel
)
{
Field
field
=
ReflectionUtils
.
findField
(
channel
.
getClass
(),
"tcpServer"
);
ReflectionUtils
.
makeAccessible
(
field
);
return
ReflectionUtils
.
getField
(
field
,
channel
);
}
private
ServerSocket
getSocket
(
Object
tcpServer
)
{
Field
socketField
=
ReflectionUtils
.
findField
(
tcpServer
.
getClass
(),
"socket"
);
Field
socketField
=
ReflectionUtils
.
findField
(
tcpServer
.
getClass
(),
"socket"
);
if
(
socketField
!=
null
)
{
if
(
socketField
==
null
)
{
ReflectionUtils
.
makeAccessible
(
socketField
);
return
null
;
return
new
Port
(((
ServerSocket
)
ReflectionUtils
.
getField
(
socketField
,
tcpServer
)).
getLocalPort
(),
protocol
);
}
}
return
null
;
ReflectionUtils
.
makeAccessible
(
socketField
);
return
(
ServerSocket
)
ReflectionUtils
.
getField
(
socketField
,
tcpServer
);
}
}
@Override
@Override
...
@@ -178,24 +184,32 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
...
@@ -178,24 +184,32 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
if
(
ports
.
isEmpty
())
{
if
(
ports
.
isEmpty
())
{
return
0
;
return
0
;
}
}
return
ports
.
get
(
0
).
portNumber
;
return
ports
.
get
(
0
).
getNumber
()
;
}
}
/**
* An active undertow port.
*/
private
static
class
Port
{
private
static
class
Port
{
private
final
int
portN
umber
;
private
final
int
n
umber
;
private
final
String
protocol
;
private
final
String
protocol
;
private
Port
(
int
portN
umber
,
String
protocol
)
{
private
Port
(
int
n
umber
,
String
protocol
)
{
this
.
portNumber
=
portN
umber
;
this
.
number
=
n
umber
;
this
.
protocol
=
protocol
;
this
.
protocol
=
protocol
;
}
}
public
int
getNumber
()
{
return
this
.
number
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
this
.
portN
umber
+
" ("
+
this
.
protocol
+
")"
;
return
this
.
n
umber
+
" ("
+
this
.
protocol
+
")"
;
}
}
}
}
}
}
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