WANG 6 år sedan
förälder
incheckning
69cf635b2a

+ 5 - 3
src/main/java/cn/com/qmth/examcloud/web/interceptor/StatisticInterceptor.java

@@ -26,8 +26,8 @@ public class StatisticInterceptor implements HandlerInterceptor {
 
 	private MetricRegistry metricRegistry = new MetricRegistry();
 
-	ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
-			.convertDurationsTo(TimeUnit.MILLISECONDS).build();
+	ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
+			.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
 
 	public StatisticInterceptor() {
 		reporter.start(1, TimeUnit.SECONDS);// 1s报道一次
@@ -57,6 +57,8 @@ public class StatisticInterceptor implements HandlerInterceptor {
 			Object handler, Exception ex) throws Exception {
 		Context ctx = (Context) request
 				.getAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name());
-		ctx.stop();
+		if (null != ctx) {
+			ctx.stop();
+		}
 	}
 }