Merge branch '6.0.x'
This commit is contained in:
commit
3c34e69cc2
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 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.
|
||||||
|
|
@ -68,9 +68,21 @@ public class StandardBeanInfoFactory implements BeanInfoFactory, Ordered {
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
|
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
|
||||||
return (shouldIntrospectorIgnoreBeaninfoClasses ?
|
BeanInfo beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ?
|
||||||
Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) :
|
Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) :
|
||||||
Introspector.getBeanInfo(beanClass));
|
Introspector.getBeanInfo(beanClass));
|
||||||
|
|
||||||
|
// Immediately remove class from Introspector cache to allow for proper garbage
|
||||||
|
// collection on class loader shutdown; we cache it in CachedIntrospectionResults
|
||||||
|
// in a GC-friendly manner. This is necessary (again) for the JDK ClassInfo cache.
|
||||||
|
Class<?> classToFlush = beanClass;
|
||||||
|
do {
|
||||||
|
Introspector.flushFromCaches(classToFlush);
|
||||||
|
classToFlush = classToFlush.getSuperclass();
|
||||||
|
}
|
||||||
|
while (classToFlush != null && classToFlush != Object.class);
|
||||||
|
|
||||||
|
return beanInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import java.sql.SQLException;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||||
import org.springframework.jdbc.LobRetrievalFailureException;
|
import org.springframework.jdbc.LobRetrievalFailureException;
|
||||||
import org.springframework.jdbc.support.lob.LobCreator;
|
import org.springframework.jdbc.support.lob.LobCreator;
|
||||||
|
|
@ -55,11 +54,9 @@ public class LobSupportTests {
|
||||||
|
|
||||||
final SetValuesCalled svc = new SetValuesCalled();
|
final SetValuesCalled svc = new SetValuesCalled();
|
||||||
|
|
||||||
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(
|
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(handler) {
|
||||||
handler) {
|
|
||||||
@Override
|
@Override
|
||||||
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
|
protected void setValues(PreparedStatement ps, LobCreator lobCreator) {
|
||||||
throws SQLException, DataAccessException {
|
|
||||||
svc.b = true;
|
svc.b = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -73,46 +70,43 @@ public class LobSupportTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
|
public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
|
||||||
ResultSet rset = mock();
|
ResultSet rs = mock();
|
||||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
|
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
|
||||||
lobRse.extractData(rset));
|
.isThrownBy(() -> lobRse.extractData(rs));
|
||||||
verify(rset).next();
|
verify(rs).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstractLobStreamingResultSetExtractorOneRow() throws SQLException {
|
public void testAbstractLobStreamingResultSetExtractorOneRow() throws SQLException {
|
||||||
ResultSet rset = mock();
|
ResultSet rs = mock();
|
||||||
given(rset.next()).willReturn(true, false);
|
given(rs.next()).willReturn(true, false);
|
||||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||||
lobRse.extractData(rset);
|
lobRse.extractData(rs);
|
||||||
verify(rset).clearWarnings();
|
verify(rs).clearWarnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstractLobStreamingResultSetExtractorMultipleRows()
|
public void testAbstractLobStreamingResultSetExtractorMultipleRows() throws SQLException {
|
||||||
throws SQLException {
|
ResultSet rs = mock();
|
||||||
ResultSet rset = mock();
|
given(rs.next()).willReturn(true, true, false);
|
||||||
given(rset.next()).willReturn(true, true, false);
|
|
||||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
|
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
|
||||||
lobRse.extractData(rset));
|
.isThrownBy(() -> lobRse.extractData(rs));
|
||||||
verify(rset).clearWarnings();
|
verify(rs).clearWarnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstractLobStreamingResultSetExtractorCorrectException()
|
public void testAbstractLobStreamingResultSetExtractorCorrectException() throws SQLException {
|
||||||
throws SQLException {
|
ResultSet rs = mock();
|
||||||
ResultSet rset = mock();
|
given(rs.next()).willReturn(true);
|
||||||
given(rset.next()).willReturn(true);
|
|
||||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
|
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
|
||||||
assertThatExceptionOfType(LobRetrievalFailureException.class).isThrownBy(() ->
|
assertThatExceptionOfType(LobRetrievalFailureException.class)
|
||||||
lobRse.extractData(rset));
|
.isThrownBy(() -> lobRse.extractData(rs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
|
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
|
||||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<>() {
|
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void streamData(ResultSet rs) throws SQLException, IOException {
|
protected void streamData(ResultSet rs) throws SQLException, IOException {
|
||||||
if (ex) {
|
if (ex) {
|
||||||
|
|
@ -125,4 +119,5 @@ public class LobSupportTests {
|
||||||
};
|
};
|
||||||
return lobRse;
|
return lobRse;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue