Skip to content

Commit 0717de7

Browse files
committed
Polish
1 parent 9a33a72 commit 0717de7

File tree

30 files changed

+247
-193
lines changed

30 files changed

+247
-193
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,33 +182,20 @@ public boolean equals(Object obj) {
182182
if (this == obj) {
183183
return true;
184184
}
185-
if (obj == null) {
186-
return false;
187-
}
188-
if (getClass() != obj.getClass()) {
185+
if (obj == null || getClass() != obj.getClass()) {
189186
return false;
190187
}
191188
CacheKey other = (CacheKey) obj;
192-
if (this.apiVersion != other.apiVersion) {
193-
return false;
194-
}
195-
if (this.principal == null) {
196-
if (other.principal != null) {
197-
return false;
198-
}
199-
}
200-
else if (!this.principal.equals(other.principal)) {
201-
return false;
202-
}
203-
return true;
189+
return this.apiVersion.equals(other.apiVersion)
190+
&& ObjectUtils.nullSafeEquals(this.principal, other.principal);
204191
}
205192

206193
@Override
207194
public int hashCode() {
208195
final int prime = 31;
209196
int result = 1;
210197
result = prime * result + this.apiVersion.hashCode();
211-
result = prime * result + ((this.principal == null) ? 0 : this.principal.hashCode());
198+
result = prime * result + ObjectUtils.nullSafeHashCode(this.principal);
212199
return result;
213200
}
214201

spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,17 @@ See the {spring-boot-module-api}/cloud/CloudFoundryVcapEnvironmentPostProcessor.
181181

182182
TIP: The https://github.com/pivotal-cf/java-cfenv/[Java CFEnv] project is a better fit for tasks such as configuring a DataSource.
183183

184+
185+
184186
[[cloud-deployment-kubernetes]]
185187
=== Kubernetes
186188
Spring Boot auto-detects Kubernetes deployment environments by checking the environment for `"*_SERVICE_HOST"` and `"*_SERVICE_PORT"` variables.
187189
You can override this detection with the configprop:management.health.probes.enabled[] configuration property.
188190

189191
Spring Boot helps you to <<spring-boot-features.adoc#boot-features-application-availability-state,manage the state of your application>> and export it with <<production-ready-features.adoc#production-ready-kubernetes-probes, HTTP Kubernetes Probes using Actuator>>.
190192

193+
194+
191195
[[cloud-deployment-kubernetes-container-lifecycle]]
192196
==== Kubernetes Container Lifecycle
193197
When Kubernetes deletes an application instance, the shutdown process involves several subsystems concurrently: shutdown hooks, unregistering the service, removing the instance from the load-balancer...
@@ -207,6 +211,7 @@ lifecycle:
207211
Once the pre-stop hook has completed, SIGTERM will be sent to the container and <<spring-boot-features#boot-features-graceful-shutdown,graceful shutdown>> will begin, allowing any remaining in-flight requests to complete.
208212

209213

214+
210215
[[cloud-deployment-heroku]]
211216
=== Heroku
212217
Heroku is another popular PaaS platform.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ It's also possible to override the `show-details` and `roles` properties if requ
870870
TIP: You can use `@Qualifier("groupname")` if you need to register custom `StatusAggregator` or `HttpCodeStatusMapper` beans for use with the group.
871871

872872

873+
873874
[[production-ready-kubernetes-probes]]
874875
=== Kubernetes Probes
875876
Applications deployed on Kubernetes can provide information about their internal state with https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes[Container Probes].
@@ -905,6 +906,8 @@ The `"startupProbe"` is not necessarily needed here as the `"readinessProbe"` fa
905906
WARNING: If your Actuator endpoints are deployed on a separate management context, be aware that endpoints are then not using the same web infrastructure (port, connection pools, framework components) as the main application.
906907
In this case, a Probe check could be successful even if the main application does not work properly (for example, it cannot accept new connections).
907908

909+
910+
908911
[[production-ready-kubernetes-probes-external-state]]
909912
==== Checking external state with Kubernetes Probes
910913
Actuator configures the "liveness" and "readiness" Probes as Health Groups; this means that all the <<production-ready-health-groups, Health Groups features>> are available for them.
@@ -927,6 +930,7 @@ Some external systems might not be shared by application instances or not essent
927930
Also, Kubernetes will react differently to applications being taken out of the load-balancer, depending on its https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/[autoscaling configuration].
928931

929932

933+
930934
[[production-ready-kubernetes-probes-lifecycle]]
931935
==== Application lifecycle and Probes states
932936
An important aspect of the Kubernetes Probes support is its consistency with the application lifecycle.
@@ -952,7 +956,6 @@ When a Spring Boot application starts:
952956
|live
953957
|ready
954958
|Startup tasks are finished. The application is receiving traffic.
955-
956959
|===
957960

958961
When a Spring Boot application shuts down:
@@ -975,12 +978,12 @@ When a Spring Boot application shuts down:
975978
|broken
976979
|unready
977980
|The application context is closed and the application cannot serve traffic.
978-
979981
|===
980982

981983
TIP: Check out the <<deployment.adoc#cloud-deployment-kubernetes-container-lifecycle,Kubernetes container lifecycle section>> for more information about Kubernetes deployment.
982984

983985

986+
984987
[[production-ready-application-info]]
985988
=== Application Information
986989
Application information exposes various information collected from all {spring-boot-actuator-module-code}/info/InfoContributor.java[`InfoContributor`] beans defined in your `ApplicationContext`.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ NOTE: There are some restrictions when creating an `ApplicationContext` hierarch
191191
For example, Web components *must* be contained within the child context, and the same `Environment` is used for both parent and child contexts.
192192
See the {spring-boot-module-api}/builder/SpringApplicationBuilder.html[`SpringApplicationBuilder` Javadoc] for full details.
193193

194+
195+
194196
[[boot-features-application-availability-state]]
195197
=== Application Availability State
196198
When deployed on plaftorms, applications can provide information about their availability to the platform using infrastructure like https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/[Kubernetes Probes].
197199
Spring Boot manages this application state with the `ApplicationAvailabilityProvider` and makes it available to application components and the platform itself.
198200

199201

202+
200203
[[boot-features-application-availability-liveness]]
201204
==== Liveness State
202205
The "Liveness" state of an application tells whether its internal state allows it to work correctly, or recover by itself if it's currently failing.
@@ -209,6 +212,8 @@ The internal state of Spring Boot applications is mostly represented by the Spri
209212
If the application context has started successfully, Spring Boot assumes that the application is in a valid state.
210213
An application is considered live as soon as the context has been refreshed, see <<boot-features-application-events-and-listeners, Spring Boot application lifecycle and related Application Events>>.
211214

215+
216+
212217
[[boot-features-application-availability-readiness]]
213218
==== Readiness State
214219
The "Readiness" state of an application tells whether the application is ready to handle traffic.

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/HttpClientHttp.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ private Response execute(HttpUriRequest request) {
150150

151151
/**
152152
* {@link HttpEntity} to send {@link Content} content.
153-
*
154-
* @author Phillip Webb
155153
*/
156154
private static class WritableHttpEntity extends AbstractHttpEntity {
157155

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ include::../gradle/packaging/boot-jar-layered-exclude-tools.gradle[tags=layered]
306306
include::../gradle/packaging/boot-jar-layered-exclude-tools.gradle.kts[tags=layered]
307307
----
308308

309+
310+
309311
[[packaging-layers-configuration]]
310312
===== Custom Layers configuration
311313
Depending on your application, you may want to tune how layers are created and add new ones.

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.gradle.api.plugins.JavaPlugin;
2525
import org.gradle.api.plugins.JavaPluginConvention;
2626
import org.gradle.api.tasks.SourceSet;
27+
import org.gradle.api.tasks.TaskContainer;
2728
import org.gradle.api.tasks.TaskProvider;
2829
import org.gradle.jvm.tasks.Jar;
2930

@@ -91,15 +92,11 @@ public void buildInfo() {
9192
* @param configurer the task configurer
9293
*/
9394
public void buildInfo(Action<BuildInfo> configurer) {
94-
TaskProvider<BuildInfo> bootBuildInfo = this.project.getTasks().register("bootBuildInfo", BuildInfo.class,
95-
(task) -> {
96-
task.setGroup(BasePlugin.BUILD_GROUP);
97-
task.setDescription("Generates a META-INF/build-info.properties file.");
98-
task.getConventionMapping().map("destinationDir",
99-
() -> new File(determineMainSourceSetResourcesOutputDir(), "META-INF"));
100-
});
95+
TaskContainer tasks = this.project.getTasks();
96+
TaskProvider<BuildInfo> bootBuildInfo = tasks.register("bootBuildInfo", BuildInfo.class,
97+
this::configureBuildInfoTask);
10198
this.project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
102-
this.project.getTasks().getByName(JavaPlugin.CLASSES_TASK_NAME).dependsOn(bootBuildInfo.get());
99+
tasks.getByName(JavaPlugin.CLASSES_TASK_NAME).dependsOn(bootBuildInfo.get());
103100
this.project.afterEvaluate((evaluated) -> {
104101
BuildInfoProperties properties = bootBuildInfo.get().getProperties();
105102
if (properties.getArtifact() == null) {
@@ -112,6 +109,13 @@ public void buildInfo(Action<BuildInfo> configurer) {
112109
}
113110
}
114111

112+
private void configureBuildInfoTask(BuildInfo task) {
113+
task.setGroup(BasePlugin.BUILD_GROUP);
114+
task.setDescription("Generates a META-INF/build-info.properties file.");
115+
task.getConventionMapping().map("destinationDir",
116+
() -> new File(determineMainSourceSetResourcesOutputDir(), "META-INF"));
117+
}
118+
115119
private File determineMainSourceSetResourcesOutputDir() {
116120
return this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
117121
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir();

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private Layer layerForFileDetails(FileCopyDetails details) {
245245
String coordinates = this.coordinatesByFileName.get(details.getName());
246246
LibraryCoordinates libraryCoordinates = (coordinates != null) ? new LibraryCoordinates(coordinates)
247247
: new LibraryCoordinates("?:?:?");
248-
return this.layers.getLayer(new Library(null, details.getFile(), null, false, libraryCoordinates));
248+
return this.layers.getLayer(new Library(null, details.getFile(), null, libraryCoordinates, false));
249249
}
250250
if (path.startsWith("BOOT-INF/classes/")) {
251251
return this.layers.getLayer(details.getSourcePath());

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayerConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ public void exclude(String... excludes) {
153153

154154
private static final class StrategySpec {
155155

156-
private enum TYPE {
157-
158-
LIBRARIES, RESOURCES;
159-
160-
}
161-
162156
private final TYPE type;
163157

164158
private List<LibraryFilter> libraryFilters;
@@ -232,6 +226,12 @@ private static StrategySpec forResources() {
232226
return new StrategySpec(TYPE.RESOURCES);
233227
}
234228

229+
private enum TYPE {
230+
231+
LIBRARIES, RESOURCES;
232+
233+
}
234+
235235
}
236236

237237
}

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public class Library {
3737

3838
private final LibraryScope scope;
3939

40-
private final boolean unpackRequired;
41-
4240
private final LibraryCoordinates coordinates;
4341

42+
private final boolean unpackRequired;
43+
4444
/**
4545
* Create a new {@link Library}.
4646
* @param file the source file
@@ -69,15 +69,24 @@ public Library(File file, LibraryScope scope, boolean unpackRequired) {
6969
* @param unpackRequired if the library needs to be unpacked before it can be used
7070
*/
7171
public Library(String name, File file, LibraryScope scope, boolean unpackRequired) {
72-
this(name, file, scope, unpackRequired, null);
72+
this(name, file, scope, null, unpackRequired);
7373
}
7474

75-
public Library(String name, File file, LibraryScope scope, boolean unpackRequired, LibraryCoordinates coordinates) {
75+
/**
76+
* Create a new {@link Library}.
77+
* @param name the name of the library as it should be written or {@code null} to use
78+
* the file name
79+
* @param file the source file
80+
* @param scope the scope of the library
81+
* @param coordinates the library coordinates or {@code null}
82+
* @param unpackRequired if the library needs to be unpacked before it can be used
83+
*/
84+
public Library(String name, File file, LibraryScope scope, LibraryCoordinates coordinates, boolean unpackRequired) {
7685
this.name = (name != null) ? name : file.getName();
7786
this.file = file;
7887
this.scope = scope;
79-
this.unpackRequired = unpackRequired;
8088
this.coordinates = coordinates;
89+
this.unpackRequired = unpackRequired;
8190
}
8291

8392
/**
@@ -113,6 +122,14 @@ public LibraryScope getScope() {
113122
return this.scope;
114123
}
115124

125+
/**
126+
* Return the {@linkplain LibraryCoordinates coordinates} of the library.
127+
* @return the coordinates
128+
*/
129+
public LibraryCoordinates getCoordinates() {
130+
return this.coordinates;
131+
}
132+
116133
/**
117134
* Return if the file cannot be used directly as a nested jar and needs to be
118135
* unpacked.
@@ -122,14 +139,6 @@ public boolean isUnpackRequired() {
122139
return this.unpackRequired;
123140
}
124141

125-
/**
126-
* Return the {@linkplain LibraryCoordinates coordinates} of the library.
127-
* @return the coordinates
128-
*/
129-
public LibraryCoordinates getCoordinates() {
130-
return this.coordinates;
131-
}
132-
133142
long getLastModified() {
134143
return this.file.lastModified();
135144
}

0 commit comments

Comments
 (0)