File tree 1 file changed +2
-12
lines changed
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core
1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change 151
151
* @author Borislav Rangelov
152
152
* @author duozhilin
153
153
* @author Andreas Zink
154
+ * @author Bartłomiej Mazur
154
155
*/
155
156
@ SuppressWarnings ("deprecation" )
156
157
public class MongoTemplate implements MongoOperations , ApplicationContextAware , IndexOperationsProvider {
157
158
158
159
private static final Logger LOGGER = LoggerFactory .getLogger (MongoTemplate .class );
159
160
private static final WriteResultChecking DEFAULT_WRITE_RESULT_CHECKING = WriteResultChecking .NONE ;
160
- private static final Collection <String > ITERABLE_CLASSES ;
161
-
162
- static {
163
-
164
- Set <String > iterableClasses = new HashSet <>();
165
- iterableClasses .add (List .class .getName ());
166
- iterableClasses .add (Collection .class .getName ());
167
- iterableClasses .add (Iterator .class .getName ());
168
-
169
- ITERABLE_CLASSES = Collections .unmodifiableCollection (iterableClasses );
170
- }
171
161
172
162
private final MongoConverter mongoConverter ;
173
163
private final MappingContext <? extends MongoPersistentEntity <?>, MongoPersistentProperty > mappingContext ;
@@ -1150,7 +1140,7 @@ public <T> T insert(T objectToSave, String collectionName) {
1150
1140
1151
1141
protected void ensureNotIterable (@ Nullable Object o ) {
1152
1142
if (null != o ) {
1153
- if (o .getClass ().isArray () || ITERABLE_CLASSES . contains ( o . getClass (). getName () )) {
1143
+ if (o .getClass ().isArray () || ( o instanceof Iterable ) || ( o instanceof Iterator )) {
1154
1144
throw new IllegalArgumentException ("Cannot use a collection here." );
1155
1145
}
1156
1146
}
You can’t perform that action at this time.
0 commit comments