Skip to content

Commit 6d524e1

Browse files
committed
Unwrap SqlParameterValue for disposable value detection in cleanupParameters
Closes gh-22972
1 parent f38ab38 commit 6d524e1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 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.
@@ -513,12 +513,17 @@ public static void cleanupParameters(Object... paramValues) {
513513
public static void cleanupParameters(Collection<?> paramValues) {
514514
if (paramValues != null) {
515515
for (Object inValue : paramValues) {
516-
if (inValue instanceof DisposableSqlTypeValue) {
517-
((DisposableSqlTypeValue) inValue).cleanup();
516+
// Unwrap SqlParameterValue first...
517+
if (inValue instanceof SqlParameterValue) {
518+
inValue = ((SqlParameterValue) inValue).getValue();
518519
}
519-
else if (inValue instanceof SqlValue) {
520+
// Check for disposable value types
521+
if (inValue instanceof SqlValue) {
520522
((SqlValue) inValue).cleanup();
521523
}
524+
else if (inValue instanceof DisposableSqlTypeValue) {
525+
((DisposableSqlTypeValue) inValue).cleanup();
526+
}
522527
}
523528
}
524529
}

0 commit comments

Comments
 (0)