From ffe53480837f6a6526cae8acd1b77d297e6a4e2f Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 1 Dec 2014 13:46:06 -0800 Subject: [PATCH 1/3] Polish formatting --- .../boot/logging/LoggingApplicationListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index d3eee2c1a9b..cc066df31b1 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -168,13 +168,13 @@ public class LoggingApplicationListener implements SmartApplicationListener { // Logback won't read backslashes so add a clean path for it to use if (!StringUtils.hasLength(System.getProperty("LOG_TEMP"))) { String path = System.getProperty("java.io.tmpdir"); - if (path!=null) { + if (path != null) { path = StringUtils.cleanPath(path); if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } System.setProperty("LOG_TEMP", path); - } + } } } From 49858a0ff1f9c6f823db7b38540fddcd289815b5 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 1 Dec 2014 13:58:18 -0800 Subject: [PATCH 2/3] Fix concurrent gaugeLocks map access Use putIfAbsent to ensure atomic creation of lock objects. Fixes gh-1995 --- .../metrics/writer/CodahaleMetricWriter.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java index 715fda39280..5f3b1cc0a59 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java @@ -90,25 +90,25 @@ public class CodahaleMetricWriter implements MetricWriter { } else { final double gauge = value.getValue().doubleValue(); - Object lock = null; - if (this.gaugeLocks.containsKey(name)) { - lock = this.gaugeLocks.get(name); - } - else { - this.gaugeLocks.putIfAbsent(name, new Object()); - lock = this.gaugeLocks.get(name); - } - // Ensure we synchronize to avoid another thread pre-empting this thread after // remove causing an error in CodaHale metrics // NOTE: CodaHale provides no way to do this atomically - synchronized (lock) { + synchronized (getGuageLock(name)) { this.registry.remove(name); this.registry.register(name, new SimpleGauge(gauge)); } } } + private Object getGuageLock(String name) { + Object lock = this.gaugeLocks.get(name); + if (lock == null) { + this.gaugeLocks.putIfAbsent(name, new Object()); + lock = this.gaugeLocks.get(name); + } + return lock; + } + @Override public void reset(String metricName) { this.registry.remove(metricName); From b519eda44120933736f9fa62d75bba0c1ed47b3d Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 1 Dec 2014 14:13:44 -0800 Subject: [PATCH 3/3] Make ErrorPageFilter public Change the visibility of ErrorPageFilter to public to fix IllegalAccessException errors on certain servlet containers. Fixes gh-2026 --- .../org/springframework/boot/context/web/ErrorPageFilter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java index cb29b3a3337..55d6b66a750 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java @@ -56,8 +56,8 @@ import org.springframework.web.filter.OncePerRequestFilter; */ @Component @Order(Ordered.HIGHEST_PRECEDENCE) -class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer implements - Filter, NonEmbeddedServletContainerFactory { +public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer + implements Filter, NonEmbeddedServletContainerFactory { private static Log logger = LogFactory.getLog(ErrorPageFilter.class);