Skip to content

Commit c5d4558

Browse files
committed
Remove unnecessary overrides of finalize
Closes gh-28209
1 parent ab6c6b7 commit c5d4558

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -276,7 +276,7 @@ private Throwable doStart() throws Exception {
276276
Assert.notNull(this.mainClassName, "Unable to find the main class to restart");
277277
URL[] urls = this.urls.toArray(new URL[0]);
278278
ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles);
279-
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles, this.logger);
279+
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles);
280280
if (this.logger.isDebugEnabled()) {
281281
this.logger.debug("Starting application " + this.mainClassName + " with URLs " + Arrays.asList(urls));
282282
}

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
*/
4343
public class RestartClassLoader extends URLClassLoader implements SmartClassLoader {
4444

45-
private final Log logger;
46-
4745
private final ClassLoaderFileRepository updatedFiles;
4846

4947
/**
@@ -73,14 +71,16 @@ public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileReposit
7371
* URLs were created.
7472
* @param urls the urls managed by the classloader
7573
* @param logger the logger used for messages
74+
* @deprecated since 2.4.11 for removal in 2.7.0 in favor of
75+
* {@link #RestartClassLoader(ClassLoader, URL[], ClassLoaderFileRepository)}
7676
*/
77+
@Deprecated
7778
public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles, Log logger) {
7879
super(urls, parent);
7980
Assert.notNull(parent, "Parent must not be null");
8081
Assert.notNull(updatedFiles, "UpdatedFiles must not be null");
8182
Assert.notNull(logger, "Logger must not be null");
8283
this.updatedFiles = updatedFiles;
83-
this.logger = logger;
8484
if (logger.isDebugEnabled()) {
8585
logger.debug("Created RestartClassLoader " + toString());
8686
}
@@ -187,14 +187,6 @@ private URL createFileUrl(String name, ClassLoaderFile file) {
187187
}
188188
}
189189

190-
@Override
191-
protected void finalize() throws Throwable {
192-
if (this.logger.isDebugEnabled()) {
193-
this.logger.debug("Finalized classloader " + toString());
194-
}
195-
super.finalize();
196-
}
197-
198190
@Override
199191
public boolean isClassReloadable(Class<?> classType) {
200192
return (classType.getClassLoader() instanceof RestartClassLoader);

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/FileDescriptor.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,11 +44,6 @@ class FileDescriptor {
4444
this.closer = closer;
4545
}
4646

47-
@Override
48-
protected void finalize() throws Throwable {
49-
close();
50-
}
51-
5247
/**
5348
* Acquire an instance of the actual {@link Handle}. The caller must
5449
* {@link Handle#close() close} the resulting handle when done.

0 commit comments

Comments
 (0)