Prevent further configuration once AbstractJdbcCall is compiled #33729
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During profiling of our application, we noticed a potential memory leak. We had a
SimpleJdbcCallobject as a field in a DAO. Typically, we would create and initialize this object during thePostConstructphase and runtime would just need to set up the inputs and call execute. However the developer accidentally put the declareParameters in the same method as execution so those paremeters kept getting added.Example DAO:
The first time
executeProcedureis called, the procedure gets compiled and all the parameters get set in thecallMetaDataContext. Subsequent calls todeclareParametersdo not alter thecallMetaDataContextand the procedure executes successfully.The problem: Each time
declareParametersis called, that parameter gets added todeclaredParametersinAbstractJdbcCallwhere it will sit there, never gets used, and never gets released for garbage collection.This proposed solution here is to check to see if the call has been compiled before adding to the
declaredParameterslist. If the call is not compiled, we'll proceed as normal. Otherwise,AbstractJdbcCallwill ignore the request because the parameter won't be added to thecallMetaDataContext.