Skip to content

Commit

Permalink
Merge branch '1.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Oct 8, 2015
2 parents 4757635 + 6ab376e commit e473364
Show file tree
Hide file tree
Showing 507 changed files with 2,657 additions and 2,476 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public Map<String, Object> getData() {

@Override
public String toString() {
return "AuditEvent [timestamp=" + this.timestamp + ", principal="
+ this.principal + ", type=" + this.type + ", data=" + this.data + "]";
return "AuditEvent [timestamp=" + this.timestamp + ", principal=" + this.principal
+ ", type=" + this.type + ", data=" + this.data + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class AuditApplicationEvent extends ApplicationEvent {
* @param data the event data
* @see AuditEvent#AuditEvent(String, String, Map)
*/
public AuditApplicationEvent(String principal, String type, Map<String, Object> data) {
public AuditApplicationEvent(String principal, String type,
Map<String, Object> data) {
this(new AuditEvent(principal, type, data));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ public static class Commit {
private String time;

public String getId() {
return this.id == null ? "" : (this.id.length() > 7 ? this.id.substring(
0, 7) : this.id);
return this.id == null ? ""
: (this.id.length() > 7 ? this.id.substring(0, 7) : this.id);
}

public void setId(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public class ManagementServerProperties implements SecurityPrerequisite {
* management endpoints. This is a useful place to put user-defined access rules if
* you want to override the default access rules.
*/
public static final int ACCESS_OVERRIDE_ORDER = ManagementServerProperties.BASIC_AUTH_ORDER - 1;
public static final int ACCESS_OVERRIDE_ORDER = ManagementServerProperties.BASIC_AUTH_ORDER
- 1;

/**
* Management endpoint HTTP port. Use the same port as the application by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected boolean shouldNotFilterAsyncDispatch() {

@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws ServletException,
IOException {
HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
StopWatch stopWatch = createStopWatchIfNecessary(request);
String path = new UrlPathHelper().getPathWithinApplication(request);
int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class ShellProperties {
private boolean defaultAuth = true;

@Autowired(required = false)
private CrshShellProperties[] additionalProperties = new CrshShellProperties[] { new SimpleAuthenticationProperties() };
private CrshShellProperties[] additionalProperties = new CrshShellProperties[] {
new SimpleAuthenticationProperties() };

/**
* Scan for changes and update the command if necessary (in seconds).
Expand Down Expand Up @@ -215,8 +216,8 @@ public static abstract class CrshShellProperties {
/**
* Base class for Auth specific properties.
*/
public static abstract class CrshShellAuthenticationProperties extends
CrshShellProperties {
public static abstract class CrshShellAuthenticationProperties
extends CrshShellProperties {

}

Expand Down Expand Up @@ -325,8 +326,8 @@ public Integer getPort() {
* Auth specific properties for JAAS authentication.
*/
@ConfigurationProperties(prefix = "shell.auth.jaas", ignoreUnknownFields = false)
public static class JaasAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class JaasAuthenticationProperties
extends CrshShellAuthenticationProperties {

/**
* JAAS domain.
Expand Down Expand Up @@ -354,8 +355,8 @@ public String getDomain() {
* Auth specific properties for key authentication.
*/
@ConfigurationProperties(prefix = "shell.auth.key", ignoreUnknownFields = false)
public static class KeyAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class KeyAuthenticationProperties
extends CrshShellAuthenticationProperties {

/**
* Path to the authentication key. This should point to a valid ".pem" file.
Expand Down Expand Up @@ -385,8 +386,8 @@ public String getPath() {
* Auth specific properties for simple authentication.
*/
@ConfigurationProperties(prefix = "shell.auth.simple", ignoreUnknownFields = false)
public static class SimpleAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class SimpleAuthenticationProperties
extends CrshShellAuthenticationProperties {

private static Log logger = LogFactory
.getLog(SimpleAuthenticationProperties.class);
Expand Down Expand Up @@ -460,8 +461,8 @@ public void setPassword(String password) {
* Auth specific properties for Spring authentication.
*/
@ConfigurationProperties(prefix = "shell.auth.spring", ignoreUnknownFields = false)
public static class SpringAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class SpringAuthenticationProperties
extends CrshShellAuthenticationProperties {

/**
* Comma-separated list of required roles to login to the CRaSH console.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public boolean isEnabled() {
return this.enabled;
}
if (this.environment != null) {
return this.environment.getProperty(ENDPOINTS_ENABLED_PROPERTY,
Boolean.class, true);
return this.environment.getProperty(ENDPOINTS_ENABLED_PROPERTY, Boolean.class,
true);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* @author Dave Syer
*/
@ConfigurationProperties(prefix = "endpoints.beans", ignoreUnknownFields = false)
public class BeansEndpoint extends AbstractEndpoint<List<Object>> implements
ApplicationContextAware {
public class BeansEndpoint extends AbstractEndpoint<List<Object>>
implements ApplicationContextAware {

private final LiveBeansView liveBeansView = new LiveBeansView();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public Collection<Metric<?>> metrics() {
return metrics;
}

private <T extends Number> void addMetric(Set<Metric<?>> metrics, String name, T value) {
private <T extends Number> void addMetric(Set<Metric<?>> metrics, String name,
T value) {
if (value != null) {
metrics.add(new Metric<T>(name, value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public DumpEndpoint() {

@Override
public List<ThreadInfo> invoke() {
return Arrays.asList(ManagementFactory.getThreadMXBean().dumpAllThreads(true,
true));
return Arrays
.asList(ManagementFactory.getThreadMXBean().dumpAllThreads(true, true));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ public Map<String, Object> invoke() {
protected void extractMethodMappings(ApplicationContext applicationContext,
Map<String, Object> result) {
if (applicationContext != null) {
for (String name : applicationContext.getBeansOfType(
AbstractHandlerMethodMapping.class).keySet()) {
for (String name : applicationContext
.getBeansOfType(AbstractHandlerMethodMapping.class).keySet()) {
@SuppressWarnings("unchecked")
Map<?, HandlerMethod> methods = applicationContext.getBean(name,
AbstractHandlerMethodMapping.class).getHandlerMethods();
Map<?, HandlerMethod> methods = applicationContext
.getBean(name, AbstractHandlerMethodMapping.class)
.getHandlerMethods();
for (Object key : methods.keySet()) {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("bean", name);
Expand Down Expand Up @@ -144,10 +145,8 @@ protected void extractMethodMappings(
for (AbstractHandlerMethodMapping<?> mapping : methodMappings) {
Map<?, HandlerMethod> methods = mapping.getHandlerMethods();
for (Map.Entry<?, HandlerMethod> entry : methods.entrySet()) {
result.put(
String.valueOf(entry.getKey()),
Collections.singletonMap("method",
String.valueOf(entry.getValue())));
result.put(String.valueOf(entry.getKey()), Collections
.singletonMap("method", String.valueOf(entry.getValue())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public Collection<Metric<?>> metrics() {

private List<Metric<?>> convert(RichGauge gauge) {
List<Metric<?>> result = new ArrayList<Metric<?>>(6);
result.add(new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
result.add(
new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
result.add(
new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* @author Christian Dupuis
*/
@ConfigurationProperties(prefix = "endpoints.shutdown", ignoreUnknownFields = false)
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> implements
ApplicationContextAware {
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
implements ApplicationContextAware {

private ConfigurableApplicationContext context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public Collection<Metric<?>> metrics() {
protected void addBasicMetrics(Collection<Metric<?>> result) {
// NOTE: ManagementFactory must not be used here since it fails on GAE
result.add(new Metric<Long>("mem", Runtime.getRuntime().totalMemory() / 1024));
result.add(new Metric<Long>("mem.free", Runtime.getRuntime().freeMemory() / 1024));
result.add(new Metric<Integer>("processors", Runtime.getRuntime()
.availableProcessors()));
result.add(new Metric<Long>("instance.uptime", System.currentTimeMillis()
- this.timestamp));
result.add(
new Metric<Long>("mem.free", Runtime.getRuntime().freeMemory() / 1024));
result.add(new Metric<Integer>("processors",
Runtime.getRuntime().availableProcessors()));
result.add(new Metric<Long>("instance.uptime",
System.currentTimeMillis() - this.timestamp));
}

/**
Expand All @@ -81,10 +82,10 @@ protected void addBasicMetrics(Collection<Metric<?>> result) {
private void addManagementMetrics(Collection<Metric<?>> result) {
try {
// Add JVM up time in ms
result.add(new Metric<Long>("uptime", ManagementFactory.getRuntimeMXBean()
.getUptime()));
result.add(new Metric<Double>("systemload.average", ManagementFactory
.getOperatingSystemMXBean().getSystemLoadAverage()));
result.add(new Metric<Long>("uptime",
ManagementFactory.getRuntimeMXBean().getUptime()));
result.add(new Metric<Double>("systemload.average",
ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()));
addHeapMetrics(result);
addThreadMetrics(result);
addClassLoadingMetrics(result);
Expand Down Expand Up @@ -114,10 +115,10 @@ protected void addHeapMetrics(Collection<Metric<?>> result) {
*/
protected void addThreadMetrics(Collection<Metric<?>> result) {
ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
result.add(new Metric<Long>("threads.peak", (long) threadMxBean
.getPeakThreadCount()));
result.add(new Metric<Long>("threads.daemon", (long) threadMxBean
.getDaemonThreadCount()));
result.add(new Metric<Long>("threads.peak",
(long) threadMxBean.getPeakThreadCount()));
result.add(new Metric<Long>("threads.daemon",
(long) threadMxBean.getDaemonThreadCount()));
result.add(new Metric<Long>("threads", (long) threadMxBean.getThreadCount()));
}

Expand All @@ -127,12 +128,12 @@ protected void addThreadMetrics(Collection<Metric<?>> result) {
*/
protected void addClassLoadingMetrics(Collection<Metric<?>> result) {
ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean();
result.add(new Metric<Long>("classes", (long) classLoadingMxBean
.getLoadedClassCount()));
result.add(new Metric<Long>("classes.loaded", classLoadingMxBean
.getTotalLoadedClassCount()));
result.add(new Metric<Long>("classes.unloaded", classLoadingMxBean
.getUnloadedClassCount()));
result.add(new Metric<Long>("classes",
(long) classLoadingMxBean.getLoadedClassCount()));
result.add(new Metric<Long>("classes.loaded",
classLoadingMxBean.getTotalLoadedClassCount()));
result.add(new Metric<Long>("classes.unloaded",
classLoadingMxBean.getUnloadedClassCount()));
}

/**
Expand All @@ -144,10 +145,10 @@ protected void addGarbageCollectionMetrics(Collection<Metric<?>> result) {
.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans) {
String name = beautifyGcName(garbageCollectorMXBean.getName());
result.add(new Metric<Long>("gc." + name + ".count", garbageCollectorMXBean
.getCollectionCount()));
result.add(new Metric<Long>("gc." + name + ".time", garbageCollectorMXBean
.getCollectionTime()));
result.add(new Metric<Long>("gc." + name + ".count",
garbageCollectorMXBean.getCollectionCount()));
result.add(new Metric<Long>("gc." + name + ".time",
garbageCollectorMXBean.getCollectionTime()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
@Override
public Collection<Metric<?>> metrics() {
if (this.applicationContext instanceof EmbeddedWebApplicationContext) {
Manager manager = getManager((EmbeddedWebApplicationContext) this.applicationContext);
Manager manager = getManager(
(EmbeddedWebApplicationContext) this.applicationContext);
if (manager != null) {
return metrics(manager);
}
Expand All @@ -65,7 +66,8 @@ private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
}

private Manager getManager(TomcatEmbeddedServletContainer servletContainer) {
for (Container container : servletContainer.getTomcat().getHost().findChildren()) {
for (Container container : servletContainer.getTomcat().getHost()
.findChildren()) {
if (container instanceof Context) {
return ((Context) container).getManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
* @author Christian Dupuis
* @author Andy Wilkinson
*/
public class EnvironmentMvcEndpoint extends EndpointMvcAdapter implements
EnvironmentAware {
public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
implements EnvironmentAware {

private Environment environment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public ShutdownMvcEndpoint(ShutdownEndpoint delegate) {
@Override
public Object invoke() {
if (!getDelegate().isEnabled()) {
return new ResponseEntity<Map<String, String>>(Collections.singletonMap(
"message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
return new ResponseEntity<Map<String, String>>(
Collections.singletonMap("message", "This endpoint is disabled"),
HttpStatus.NOT_FOUND);
}
return super.invoke();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ protected void doHealthCheck(Health.Builder builder) throws Exception {
builder.up();
}
else {
logger.warn(String.format("Free disk space below threshold. "
+ "Available: %d bytes (threshold: %d bytes)", diskFreeInBytes,
this.properties.getThreshold()));
logger.warn(String.format(
"Free disk space below threshold. "
+ "Available: %d bytes (threshold: %d bytes)",
diskFreeInBytes, this.properties.getThreshold()));
builder.down();
}
builder.withDetail("total", path.getTotalSpace())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public String toString() {
* @return a new {@link Metric} instance
*/
public Metric<Long> increment(int amount) {
return new Metric<Long>(this.getName(), new Long(this.getValue().longValue()
+ amount));
return new Metric<Long>(this.getName(),
new Long(this.getValue().longValue() + amount));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
* @param reader a reader as the source of metrics
* @param writer the writer to send the metrics to
*/
public PrefixMetricGroupExporter(PrefixMetricReader reader, PrefixMetricWriter writer) {
public PrefixMetricGroupExporter(PrefixMetricReader reader,
PrefixMetricWriter writer) {
this(reader, writer, "");
}

Expand All @@ -57,8 +58,8 @@ public PrefixMetricGroupExporter(PrefixMetricReader reader, PrefixMetricWriter w
* @param writer the writer to send the metrics to
* @param prefix the prefix for metrics to export
*/
public PrefixMetricGroupExporter(PrefixMetricReader reader,
PrefixMetricWriter writer, String prefix) {
public PrefixMetricGroupExporter(PrefixMetricReader reader, PrefixMetricWriter writer,
String prefix) {
super(prefix);
this.reader = reader;
this.writer = writer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ private static Set<String> getNumberKeys(Object metric) {
result = new HashSet<String>();
}
if (result.isEmpty()) {
for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(metric
.getClass())) {
for (PropertyDescriptor descriptor : BeanUtils
.getPropertyDescriptors(metric.getClass())) {
if (ClassUtils.isAssignable(Number.class, descriptor.getPropertyType())) {
result.add(descriptor.getName());
}
Expand Down
Loading

0 comments on commit e473364

Please sign in to comment.