This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
commit 546dbab5657ae0dbcb37c06c77110430e81c298a Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed May 22 10:04:21 2024 -0400 Fix SpotBugs MC_OVERRIDABLE_METHOD_CALL_IN_READ_OBJECT in PerUserPoolDataSource --- src/changes/changes.xml | 1 + .../commons/dbcp2/datasources/PerUserPoolDataSource.java | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f2bda653..98be1b40 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -69,6 +69,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="update" dev="ggregory" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName in PoolablePreparedStatement.</action> <action type="update" dev="ggregory" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName in Utils.</action> <action type="update" dev="ggregory" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName in LocalXAConnectionFactory.</action> + <action type="update" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs MC_OVERRIDABLE_METHOD_CALL_IN_READ_OBJECT in PerUserPoolDataSource.</action> <!-- ADD --> <!-- UPDATE --> <action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 66 to 69 #360, #371.</action> diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java index 1b972ddd..85d7491a 100644 --- a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java +++ b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java @@ -693,12 +693,15 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource { * @throws ClassNotFoundException * if an error occurs */ + @SuppressWarnings("resource") private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + this.managers = readObjectImpl().managers; + } + + private PerUserPoolDataSource readObjectImpl() throws IOException, ClassNotFoundException { try { - in.defaultReadObject(); - final PerUserPoolDataSource oldDS = (PerUserPoolDataSource) new PerUserPoolDataSourceFactory() - .getObjectInstance(getReference(), null, null, null); - this.managers = oldDS.managers; + return (PerUserPoolDataSource) new PerUserPoolDataSourceFactory().getObjectInstance(getReference(), null, null, null); } catch (final NamingException e) { throw new IOException("NamingException: " + e); }