Repository: cxf Updated Branches: refs/heads/2.7.x-fixes 5ab46dfcd -> 3618467cd
CXF-6138 JAXB unmarshaller Properties get overwriten on a call to initialize() Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b68fcd88 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b68fcd88 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b68fcd88 Branch: refs/heads/2.7.x-fixes Commit: b68fcd884dab43e7fffdd4b7cf8042896c2ac8a8 Parents: 5ab46df Author: paul <[email protected]> Authored: Sat Dec 6 22:04:08 2014 +0000 Committer: Daniel Kulp <[email protected]> Committed: Mon Feb 9 13:02:15 2015 -0500 ---------------------------------------------------------------------- .../org/apache/cxf/jaxb/JAXBDataBinding.java | 8 +++- .../DataBindingMarshallerPropertiesTest.java | 39 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/b68fcd88/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java ---------------------------------------------------------------------- diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java index 14ce43f..c26372b 100644 --- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java +++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java @@ -323,8 +323,12 @@ public class JAXBDataBinding extends AbstractDataBinding contextClasses = new LinkedHashSet<Class<?>>(); - Map<String, Object> unmarshallerProps = new HashMap<String, Object>(); - this.setUnmarshallerProperties(unmarshallerProps); + + if (this.getUnmarshallerProperties() == null || this.getUnmarshallerProperties().isEmpty()) { + Map<String, Object> unmarshallerProps = new HashMap<String, Object>(); + this.setUnmarshallerProperties(unmarshallerProps); + } + for (ServiceInfo serviceInfo : service.getServiceInfos()) { JAXBContextInitializer initializer http://git-wip-us.apache.org/repos/asf/cxf/blob/b68fcd88/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java ---------------------------------------------------------------------- diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java new file mode 100644 index 0000000..82b594b --- /dev/null +++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.jaxb; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class DataBindingMarshallerPropertiesTest extends TestBase { + @Test + public void testInitializeUnmarshallerProperties() throws Exception { + JAXBDataBinding db = new JAXBDataBinding(); + Map<String, Object> unmarshallerProperties = new HashMap<String, Object>(); + unmarshallerProperties.put("someproperty", "somevalue"); + db.setUnmarshallerProperties(unmarshallerProperties); + + db.initialize(service); + + assertTrue("somevalue".equals(db.getUnmarshallerProperties().get("someproperty"))); + } +}
