XmlOptionsFactoryBean initializes empty XmlOptions by default and uses efficient entrySet iteration

Issue: SPR-12383
This commit is contained in:
Juergen Hoeller 2014-10-28 13:34:56 +01:00
parent cb095132b1
commit ad2d5952c6
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -30,6 +30,7 @@ import org.springframework.beans.factory.FactoryBean;
* in the {@link XmlBeansMarshaller}.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
* @since 3.0
* @see XmlOptions
* @see #setOptions(java.util.Map)
@ -37,7 +38,7 @@ import org.springframework.beans.factory.FactoryBean;
*/
public class XmlOptionsFactoryBean implements FactoryBean<XmlOptions> {
private XmlOptions xmlOptions;
private XmlOptions xmlOptions = new XmlOptions();
/**
@ -51,8 +52,8 @@ public class XmlOptionsFactoryBean implements FactoryBean<XmlOptions> {
public void setOptions(Map<String, ?> optionsMap) {
this.xmlOptions = new XmlOptions();
if (optionsMap != null) {
for (String option : optionsMap.keySet()) {
this.xmlOptions.put(option, optionsMap.get(option));
for (Map.Entry<String, ?> option : optionsMap.entrySet()) {
this.xmlOptions.put(option.getKey(), option.getValue());
}
}
}