From 8973d1ad8a50a8eb752597e9e065fe35da761968 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Aug 2023 20:10:23 +0200 Subject: [PATCH 1/2] Polishing --- .../core/ReactiveAdapterRegistry.java | 14 +++++----- .../org/springframework/util/StopWatch.java | 28 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java index 921cb0e99e9..c4614bb3905 100644 --- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java @@ -101,13 +101,6 @@ public class ReactiveAdapterRegistry { } - /** - * Whether the registry has any adapters. - */ - public boolean hasAdapters() { - return !this.adapters.isEmpty(); - } - /** * Register a reactive type along with functions to adapt to and from a * Reactive Streams {@link Publisher}. The function arguments assume that @@ -124,6 +117,13 @@ public class ReactiveAdapterRegistry { } } + /** + * Return whether the registry has any adapters. + */ + public boolean hasAdapters() { + return !this.adapters.isEmpty(); + } + /** * Get the adapter for the given reactive type. * @return the corresponding adapter, or {@code null} if none available diff --git a/spring-core/src/main/java/org/springframework/util/StopWatch.java b/spring-core/src/main/java/org/springframework/util/StopWatch.java index 505c27dbd10..feecabbccfa 100644 --- a/spring-core/src/main/java/org/springframework/util/StopWatch.java +++ b/spring-core/src/main/java/org/springframework/util/StopWatch.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,8 +82,8 @@ public class StopWatch { } /** - * Construct a new {@code StopWatch} with the given ID. - *

The ID is handy when we have output from multiple stop watches and need + * Construct a new {@code StopWatch} with the given id. + *

The id is handy when we have output from multiple stop watches and need * to distinguish between them. *

Does not start any task. * @param id identifier for this stop watch @@ -94,8 +94,8 @@ public class StopWatch { /** - * Get the ID of this {@code StopWatch}, as specified on construction. - * @return the ID (empty String by default) + * Get the id of this {@code StopWatch}, as specified on construction. + * @return the id (empty String by default) * @since 4.2.2 * @see #StopWatch(String) */ @@ -105,9 +105,8 @@ public class StopWatch { /** * Configure whether the {@link TaskInfo} array is built over time. - *

Set this to {@code false} when using a {@code StopWatch} for millions - * of intervals; otherwise, the {@code TaskInfo} structure will consume - * excessive memory. + *

Set this to {@code false} when using a {@code StopWatch} for millions of + * tasks; otherwise, the {@code TaskInfo} structure will consume excessive memory. *

Default is {@code true}. */ public void setKeepTaskList(boolean keepTaskList) { @@ -226,7 +225,7 @@ public class StopWatch { /** - * Get the total time in nanoseconds for all tasks. + * Get the total time for all tasks in nanoseconds. * @since 5.2 * @see #getTotalTimeMillis() * @see #getTotalTimeSeconds() @@ -236,7 +235,7 @@ public class StopWatch { } /** - * Get the total time in milliseconds for all tasks. + * Get the total time for all tasks in milliseconds. * @see #getTotalTimeNanos() * @see #getTotalTimeSeconds() */ @@ -245,7 +244,7 @@ public class StopWatch { } /** - * Get the total time in seconds for all tasks. + * Get the total time for all tasks in seconds. * @see #getTotalTimeNanos() * @see #getTotalTimeMillis() */ @@ -361,7 +360,7 @@ public class StopWatch { } /** - * Get the time in nanoseconds this task took. + * Get the time this task took in nanoseconds. * @since 5.2 * @see #getTimeMillis() * @see #getTimeSeconds() @@ -371,7 +370,7 @@ public class StopWatch { } /** - * Get the time in milliseconds this task took. + * Get the time this task took in milliseconds. * @see #getTimeNanos() * @see #getTimeSeconds() */ @@ -380,14 +379,13 @@ public class StopWatch { } /** - * Get the time in seconds this task took. + * Get the time this task took in seconds. * @see #getTimeMillis() * @see #getTimeNanos() */ public double getTimeSeconds() { return nanosToSeconds(this.timeNanos); } - } } From d58e48d9f5bf3a6b19ceec8db79d062811cc8d6c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Aug 2023 20:11:28 +0200 Subject: [PATCH 2/2] Explicit note on FactoryBean resolution with MBeanExporter Closes gh-21676 --- .../ROOT/pages/integration/jmx/exporting.adoc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc b/framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc index fdc637ad2e0..2b1fb866374 100644 --- a/framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc +++ b/framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc @@ -183,18 +183,21 @@ as the following example shows: If you configure a bean with an `MBeanExporter` that is also configured for lazy initialization, the `MBeanExporter` does not break this contract and avoids -instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and -defers obtaining the bean from the container until the first invocation on the proxy -occurs. +instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and defers +obtaining the bean from the container until the first invocation on the proxy occurs. + +This also affects `FactoryBean` resolution where `MBeanExporter` will regularly +introspect the produced object, effectively triggering `FactoryBean.getObject()`. +In order to avoid this, mark the corresponding bean definition as lazy-init. [[jmx-exporting-auto]] == Automatic Registration of MBeans -Any beans that are exported through the `MBeanExporter` and are already valid MBeans are -registered as-is with the `MBeanServer` without further intervention from Spring. You can cause MBeans -to be automatically detected by the `MBeanExporter` by setting the `autodetect` -property to `true`, as the following example shows: +Any beans that are exported through the `MBeanExporter` and are already valid MBeans +are registered as-is with the `MBeanServer` without further intervention from Spring. +You can cause MBeans to be automatically detected by the `MBeanExporter` by setting +the `autodetect` property to `true`, as the following example shows: [source,xml,indent=0,subs="verbatim,quotes"] ----