Skip to content

Commit 43e315f

Browse files
committed
Unwrap SqlParameterValue for disposable value detection in cleanupParameters
Closes gh-22972
1 parent 30bc5e0 commit 43e315f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -312,7 +312,6 @@ else if ((sqlType == Types.CLOB || sqlType == Types.NCLOB) && isStringValue(inVa
312312
else {
313313
ps.setClob(paramIndex, new StringReader(strVal), strVal.length());
314314
}
315-
return;
316315
}
317316
else {
318317
// Fallback: setString or setNString binding
@@ -460,12 +459,17 @@ public static void cleanupParameters(@Nullable Object... paramValues) {
460459
public static void cleanupParameters(@Nullable Collection<?> paramValues) {
461460
if (paramValues != null) {
462461
for (Object inValue : paramValues) {
463-
if (inValue instanceof DisposableSqlTypeValue) {
464-
((DisposableSqlTypeValue) inValue).cleanup();
462+
// Unwrap SqlParameterValue first...
463+
if (inValue instanceof SqlParameterValue) {
464+
inValue = ((SqlParameterValue) inValue).getValue();
465465
}
466-
else if (inValue instanceof SqlValue) {
466+
// Check for disposable value types
467+
if (inValue instanceof SqlValue) {
467468
((SqlValue) inValue).cleanup();
468469
}
470+
else if (inValue instanceof DisposableSqlTypeValue) {
471+
((DisposableSqlTypeValue) inValue).cleanup();
472+
}
469473
}
470474
}
471475
}

0 commit comments

Comments
 (0)