do not try to convert read-only Collections/Maps (SPR-6808)

This commit is contained in:
Juergen Hoeller
2010-02-08 12:29:21 +00:00
parent 81649d5c3b
commit 6c0d934b92
2 changed files with 66 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -576,7 +576,16 @@ class TypeConverterDelegate {
if (methodParam != null) {
methodParam.decreaseNestingLevel();
}
convertedCopy.add(convertedElement);
try {
convertedCopy.add(convertedElement);
}
catch (Throwable ex) {
if (logger.isDebugEnabled()) {
logger.debug("Collection type [" + original.getClass().getName() +
"] seems to be read-only - injecting original Collection as-is", ex);
}
return original;
}
originalAllowed = originalAllowed && (element == convertedElement);
}
return (originalAllowed ? original : convertedCopy);
@@ -650,7 +659,16 @@ class TypeConverterDelegate {
if (methodParam != null) {
methodParam.decreaseNestingLevel();
}
convertedCopy.put(convertedKey, convertedValue);
try {
convertedCopy.put(convertedKey, convertedValue);
}
catch (Throwable ex) {
if (logger.isDebugEnabled()) {
logger.debug("Map type [" + original.getClass().getName() +
"] seems to be read-only - injecting original Map as-is", ex);
}
return original;
}
originalAllowed = originalAllowed && (key == convertedKey) && (value == convertedValue);
}
return (originalAllowed ? original : convertedCopy);