Skip to content

Commit

Permalink
Unwrap SqlParameterValue for disposable value detection in cleanupPar…
Browse files Browse the repository at this point in the history
…ameters

Closes spring-projectsgh-22972
  • Loading branch information
jhoeller authored and xcl(徐程林) committed Aug 16, 2020
1 parent 1b1b621 commit f2283b3
Showing 1 changed file with 9 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -312,7 +312,6 @@ else if ((sqlType == Types.CLOB || sqlType == Types.NCLOB) && isStringValue(inVa
else {
ps.setClob(paramIndex, new StringReader(strVal), strVal.length());
}
return;
}
else {
// Fallback: setString or setNString binding
Expand Down Expand Up @@ -460,12 +459,17 @@ public static void cleanupParameters(@Nullable Object... paramValues) {
public static void cleanupParameters(@Nullable Collection<?> paramValues) {
if (paramValues != null) {
for (Object inValue : paramValues) {
if (inValue instanceof DisposableSqlTypeValue) {
((DisposableSqlTypeValue) inValue).cleanup();
// Unwrap SqlParameterValue first...
if (inValue instanceof SqlParameterValue) {
inValue = ((SqlParameterValue) inValue).getValue();
}
else if (inValue instanceof SqlValue) {
// Check for disposable value types
if (inValue instanceof SqlValue) {
((SqlValue) inValue).cleanup();
}
else if (inValue instanceof DisposableSqlTypeValue) {
((DisposableSqlTypeValue) inValue).cleanup();
}
}
}
}
Expand Down

0 comments on commit f2283b3

Please sign in to comment.