Remove support for deprecated Java SecurityManager (-> JDK 17 build compatibility)

Includes hard JDK 9+ API dependency in CGLIB ReflectUtils (Lookup.defineClass) and removal of OutputStream spy proxy usage (avoiding invalid Mockito proxy on JDK 17)

Closes gh-26901
This commit is contained in:
Juergen Hoeller
2021-09-15 15:30:25 +02:00
parent 0640da74bc
commit cf2429b0f0
47 changed files with 147 additions and 2078 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import static org.mockito.Mockito.spy;
/**
* @author Arjen Poutsma
* @author Rossen Stoyanchev
@@ -31,7 +29,7 @@ public class MockHttpOutputMessage implements HttpOutputMessage {
private final HttpHeaders headers = new HttpHeaders();
private final ByteArrayOutputStream body = spy(new ByteArrayOutputStream());
private final ByteArrayOutputStream body = new ByteArrayOutputStream();
private boolean headersWritten = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -48,8 +48,6 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static org.springframework.http.MediaType.MULTIPART_MIXED;
@@ -226,10 +224,9 @@ public class FormHttpMessageConverterTests {
item = items.get(5);
assertThat(item.getFieldName()).isEqualTo("xml");
assertThat(item.getContentType()).isEqualTo("text/xml");
verify(outputMessage.getBody(), never()).close();
}
@Test // SPR-13309
@Test // SPR-13309
public void writeMultipartOrder() throws Exception {
MyBean myBean = new MyBean();
myBean.setString("foo");

View File

@@ -102,7 +102,7 @@ public class StringHttpMessageConverterTests {
assertThat(headers.getAcceptCharset().isEmpty()).isTrue();
}
@Test // gh-24123
@Test // gh-24123
public void writeJson() throws IOException {
String body = "{\"føø\":\"bår\"}";
this.converter.write(body, MediaType.APPLICATION_JSON, this.outputMessage);
@@ -114,7 +114,7 @@ public class StringHttpMessageConverterTests {
assertThat(headers.getAcceptCharset().isEmpty()).isTrue();
}
@Test // gh-25328
@Test // gh-25328
public void writeJsonApi() throws IOException {
String body = "{\"føø\":\"bår\"}";
MediaType contentType = new MediaType("application", "vnd.api.v1+json");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -47,8 +47,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.entry;
import static org.assertj.core.api.Assertions.within;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
* Jackson 2.x converter tests.
@@ -188,7 +186,6 @@ public class MappingJackson2HttpMessageConverterTests {
assertThat(result.contains("\"bool\":true")).isTrue();
assertThat(result.contains("\"bytes\":\"AQI=\"")).isTrue();
assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(MediaType.APPLICATION_JSON);
verify(outputMessage.getBody(), never()).close();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -51,13 +51,13 @@ public class ServletRequestAttributesTests {
@Test
public void ctorRejectsNullArg() throws Exception {
public void ctorRejectsNullArg() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ServletRequestAttributes(null));
}
@Test
public void setRequestScopedAttribute() throws Exception {
public void setRequestScopedAttribute() {
MockHttpServletRequest request = new MockHttpServletRequest();
ServletRequestAttributes attrs = new ServletRequestAttributes(request);
attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_REQUEST);
@@ -66,7 +66,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void setRequestScopedAttributeAfterCompletion() throws Exception {
public void setRequestScopedAttributeAfterCompletion() {
MockHttpServletRequest request = new MockHttpServletRequest();
ServletRequestAttributes attrs = new ServletRequestAttributes(request);
request.close();
@@ -75,7 +75,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void setSessionScopedAttribute() throws Exception {
public void setSessionScopedAttribute() {
MockHttpSession session = new MockHttpSession();
session.setAttribute(KEY, VALUE);
MockHttpServletRequest request = new MockHttpServletRequest();
@@ -86,7 +86,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void setSessionScopedAttributeAfterCompletion() throws Exception {
public void setSessionScopedAttributeAfterCompletion() {
MockHttpSession session = new MockHttpSession();
session.setAttribute(KEY, VALUE);
MockHttpServletRequest request = new MockHttpServletRequest();
@@ -100,7 +100,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void getSessionScopedAttributeDoesNotForceCreationOfSession() throws Exception {
public void getSessionScopedAttributeDoesNotForceCreationOfSession() {
HttpServletRequest request = mock(HttpServletRequest.class);
ServletRequestAttributes attrs = new ServletRequestAttributes(request);
@@ -110,7 +110,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void removeSessionScopedAttribute() throws Exception {
public void removeSessionScopedAttribute() {
MockHttpSession session = new MockHttpSession();
session.setAttribute(KEY, VALUE);
MockHttpServletRequest request = new MockHttpServletRequest();
@@ -122,7 +122,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void removeSessionScopedAttributeDoesNotForceCreationOfSession() throws Exception {
public void removeSessionScopedAttributeDoesNotForceCreationOfSession() {
HttpServletRequest request = mock(HttpServletRequest.class);
ServletRequestAttributes attrs = new ServletRequestAttributes(request);
@@ -131,7 +131,7 @@ public class ServletRequestAttributesTests {
}
@Test
public void updateAccessedAttributes() throws Exception {
public void updateAccessedAttributes() {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
given(request.getSession(anyBoolean())).willReturn(session);
@@ -153,7 +153,7 @@ public class ServletRequestAttributesTests {
@Test
public void skipImmutableCharacter() {
doSkipImmutableValue(new Character('x'));
doSkipImmutableValue(Character.valueOf('x'));
}
@Test