Skip to content

Commit 5017d59

Browse files
committed
Merge branch '2.4.x'
Closes gh-25184
2 parents 55c47c8 + 75fc896 commit 5017d59

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+7-1
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.
@@ -22,6 +22,7 @@
2222
import java.net.URLClassLoader;
2323
import java.security.AccessController;
2424
import java.security.PrivilegedAction;
25+
import java.security.ProtectionDomain;
2526
import java.util.Enumeration;
2627

2728
import org.apache.commons.logging.Log;
@@ -167,6 +168,11 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
167168
});
168169
}
169170

171+
@Override
172+
public Class<?> publicDefineClass(String name, byte[] b, ProtectionDomain protectionDomain) {
173+
return defineClass(name, b, 0, b.length, protectionDomain);
174+
}
175+
170176
private URL createFileUrl(String name, ClassLoaderFile file) {
171177
try {
172178
return new URL("reloaded", null, -1, "/" + name, new ClassLoaderFileURLStreamHandler(file));

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java

+11-1
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.
@@ -25,6 +25,7 @@
2525
import java.nio.charset.StandardCharsets;
2626
import java.util.Collections;
2727
import java.util.Enumeration;
28+
import java.util.HashMap;
2829
import java.util.List;
2930
import java.util.jar.JarOutputStream;
3031
import java.util.zip.ZipEntry;
@@ -34,6 +35,7 @@
3435
import org.junit.jupiter.api.Test;
3536
import org.junit.jupiter.api.io.TempDir;
3637

38+
import org.springframework.aop.framework.ProxyFactory;
3739
import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind;
3840
import org.springframework.util.FileCopyUtils;
3941
import org.springframework.util.StreamUtils;
@@ -200,6 +202,14 @@ void getAddedClass() throws Exception {
200202
assertThat(loaded.getClassLoader()).isEqualTo(this.reloadClassLoader);
201203
}
202204

205+
@Test
206+
void proxyOnClassFromSystemClassLoaderDoesNotYieldWarning() {
207+
ProxyFactory pf = new ProxyFactory(new HashMap<>());
208+
pf.setProxyTargetClass(true);
209+
pf.getProxy(this.reloadClassLoader);
210+
// Warning would happen outside the boundary of the test
211+
}
212+
203213
private String readString(InputStream in) throws IOException {
204214
return new String(FileCopyUtils.copyToByteArray(in));
205215
}

0 commit comments

Comments
 (0)