Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5 from amuniz/fix-npe
Browse files Browse the repository at this point in the history
[JENKINS-37757] Protection against NullPointerException
  • Loading branch information
oleg-nenashev committed Sep 29, 2016
2 parents d3a5bd4 + 88eba2a commit 8b101d4
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -15,6 +15,7 @@
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.ConverterLookup;
import com.thoughtworks.xstream.converters.ConverterRegistry;
import com.thoughtworks.xstream.converters.basic.NullConverter;
import com.thoughtworks.xstream.core.util.PrioritizedList;
import com.thoughtworks.xstream.mapper.Mapper;

Expand Down Expand Up @@ -56,7 +57,8 @@ public synchronized Converter lookupConverterForType(Class type) {
Iterator iterator = converters.iterator();
while (iterator.hasNext()) {
Converter converter = (Converter) iterator.next();
if (converter.canConvert(type)) {
if ((converter instanceof NullConverter && converter.canConvert(type))
|| (type != null && converter.canConvert(type))) {
typeToConverterMap.put(type, converter);
return converter;
}
Expand All @@ -71,7 +73,8 @@ public synchronized void registerConverter(Converter converter, int priority) {
converters.add(converter, priority);
for (Iterator iter = typeToConverterMap.keySet().iterator(); iter.hasNext();) {
Class type = (Class) iter.next();
if (converter.canConvert(type)) {
if ((converter instanceof NullConverter && converter.canConvert(type))
|| (type != null && converter.canConvert(type))) {
iter.remove();
}
}
Expand Down

0 comments on commit 8b101d4

Please sign in to comment.