mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Remove unnecessary overrides of finalize
Closes gh-28209
This commit is contained in:
parent
ab6c6b7f17
commit
c5d45585d9
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -276,7 +276,7 @@ public class Restarter {
|
|||||||
Assert.notNull(this.mainClassName, "Unable to find the main class to restart");
|
Assert.notNull(this.mainClassName, "Unable to find the main class to restart");
|
||||||
URL[] urls = this.urls.toArray(new URL[0]);
|
URL[] urls = this.urls.toArray(new URL[0]);
|
||||||
ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles);
|
ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles);
|
||||||
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles, this.logger);
|
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles);
|
||||||
if (this.logger.isDebugEnabled()) {
|
if (this.logger.isDebugEnabled()) {
|
||||||
this.logger.debug("Starting application " + this.mainClassName + " with URLs " + Arrays.asList(urls));
|
this.logger.debug("Starting application " + this.mainClassName + " with URLs " + Arrays.asList(urls));
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ import org.springframework.util.Assert;
|
|||||||
*/
|
*/
|
||||||
public class RestartClassLoader extends URLClassLoader implements SmartClassLoader {
|
public class RestartClassLoader extends URLClassLoader implements SmartClassLoader {
|
||||||
|
|
||||||
private final Log logger;
|
|
||||||
|
|
||||||
private final ClassLoaderFileRepository updatedFiles;
|
private final ClassLoaderFileRepository updatedFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,14 +71,16 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad
|
|||||||
* URLs were created.
|
* URLs were created.
|
||||||
* @param urls the urls managed by the classloader
|
* @param urls the urls managed by the classloader
|
||||||
* @param logger the logger used for messages
|
* @param logger the logger used for messages
|
||||||
|
* @deprecated since 2.4.11 for removal in 2.7.0 in favor of
|
||||||
|
* {@link #RestartClassLoader(ClassLoader, URL[], ClassLoaderFileRepository)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles, Log logger) {
|
public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles, Log logger) {
|
||||||
super(urls, parent);
|
super(urls, parent);
|
||||||
Assert.notNull(parent, "Parent must not be null");
|
Assert.notNull(parent, "Parent must not be null");
|
||||||
Assert.notNull(updatedFiles, "UpdatedFiles must not be null");
|
Assert.notNull(updatedFiles, "UpdatedFiles must not be null");
|
||||||
Assert.notNull(logger, "Logger must not be null");
|
Assert.notNull(logger, "Logger must not be null");
|
||||||
this.updatedFiles = updatedFiles;
|
this.updatedFiles = updatedFiles;
|
||||||
this.logger = logger;
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Created RestartClassLoader " + toString());
|
logger.debug("Created RestartClassLoader " + toString());
|
||||||
}
|
}
|
||||||
@ -187,14 +187,6 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
if (this.logger.isDebugEnabled()) {
|
|
||||||
this.logger.debug("Finalized classloader " + toString());
|
|
||||||
}
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClassReloadable(Class<?> classType) {
|
public boolean isClassReloadable(Class<?> classType) {
|
||||||
return (classType.getClassLoader() instanceof RestartClassLoader);
|
return (classType.getClassLoader() instanceof RestartClassLoader);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -44,11 +44,6 @@ class FileDescriptor {
|
|||||||
this.closer = closer;
|
this.closer = closer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquire an instance of the actual {@link Handle}. The caller must
|
* Acquire an instance of the actual {@link Handle}. The caller must
|
||||||
* {@link Handle#close() close} the resulting handle when done.
|
* {@link Handle#close() close} the resulting handle when done.
|
||||||
|
Loading…
Reference in New Issue
Block a user