Polishing

This commit is contained in:
Juergen Hoeller 2016-01-25 20:33:48 +01:00
parent 8a69159004
commit 64ce8a81c3
3 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -73,7 +73,8 @@ public class EnableMBeanExportConfigurationTests {
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4"); ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
assertNotNull(server.getObjectInstance(oname)); assertNotNull(server.getObjectInstance(oname));
assertEquals("TEST", server.getAttribute(oname, "Name")); assertEquals("TEST", server.getAttribute(oname, "Name"));
} finally { }
finally {
ctx.close(); ctx.close();
} }
} }
@ -142,7 +143,8 @@ public class EnableMBeanExportConfigurationTests {
assertNotNull(server.getObjectInstance(oname)); assertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name"); String name = (String) server.getAttribute(oname, "Name");
assertNull(name); assertNull(name);
} finally { }
finally {
ctx.close(); ctx.close();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
/** /**
* Calls {@link Enum#name()} to convert a source Enum to a String. This converter will * Calls {@link Enum#name()} to convert a source Enum to a String.
* not match enums with interfaces that can be converterd. * This converter will not match enums with interfaces that can be converted.
*
* @author Keith Donald * @author Keith Donald
* @author Phillip Webb * @author Phillip Webb
* @since 3.0 * @since 3.0
@ -33,14 +34,16 @@ final class EnumToStringConverter implements Converter<Enum<?>, String>, Conditi
private final ConversionService conversionService; private final ConversionService conversionService;
public EnumToStringConverter(ConversionService conversionService) { public EnumToStringConverter(ConversionService conversionService) {
this.conversionService = conversionService; this.conversionService = conversionService;
} }
@Override @Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
for (Class<?> interfaceType : ClassUtils.getAllInterfacesForClass(sourceType.getType())) { for (Class<?> interfaceType : ClassUtils.getAllInterfacesForClass(sourceType.getType())) {
if (conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) { if (this.conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) {
return false; return false;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,8 +80,8 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
if (debugEnabled) { if (debugEnabled) {
logger.debug(String.format("Searching for key '%s' in [%s]", key, propertySource.getName())); logger.debug(String.format("Searching for key '%s' in [%s]", key, propertySource.getName()));
} }
Object value; Object value = propertySource.getProperty(key);
if ((value = propertySource.getProperty(key)) != null) { if (value != null) {
Class<?> valueType = value.getClass(); Class<?> valueType = value.getClass();
if (resolveNestedPlaceholders && value instanceof String) { if (resolveNestedPlaceholders && value instanceof String) {
value = resolveNestedPlaceholders((String) value); value = resolveNestedPlaceholders((String) value);