From 64ce8a81c3f6d5ef99ee6cd8220e3c8ad9e5f846 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 25 Jan 2016 20:33:48 +0100 Subject: [PATCH] Polishing --- .../EnableMBeanExportConfigurationTests.java | 8 +++++--- .../core/convert/support/EnumToStringConverter.java | 11 +++++++---- .../core/env/PropertySourcesPropertyResolver.java | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java index 6ad47d7eb9..caad398299 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java @@ -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"); * 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"); assertNotNull(server.getObjectInstance(oname)); assertEquals("TEST", server.getAttribute(oname, "Name")); - } finally { + } + finally { ctx.close(); } } @@ -142,7 +143,8 @@ public class EnableMBeanExportConfigurationTests { assertNotNull(server.getObjectInstance(oname)); String name = (String) server.getAttribute(oname, "Name"); assertNull(name); - } finally { + } + finally { ctx.close(); } } diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java index bfd1762d96..02a5f19f29 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java @@ -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"); * 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; /** - * Calls {@link Enum#name()} to convert a source Enum to a String. This converter will - * not match enums with interfaces that can be converterd. + * Calls {@link Enum#name()} to convert a source Enum to a String. + * This converter will not match enums with interfaces that can be converted. + * * @author Keith Donald * @author Phillip Webb * @since 3.0 @@ -33,14 +34,16 @@ final class EnumToStringConverter implements Converter, String>, Conditi private final ConversionService conversionService; + public EnumToStringConverter(ConversionService conversionService) { this.conversionService = conversionService; } + @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { for (Class interfaceType : ClassUtils.getAllInterfacesForClass(sourceType.getType())) { - if (conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) { + if (this.conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) { return false; } } diff --git a/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java index 9e33628448..edf0b72965 100644 --- a/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -80,8 +80,8 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver { if (debugEnabled) { logger.debug(String.format("Searching for key '%s' in [%s]", key, propertySource.getName())); } - Object value; - if ((value = propertySource.getProperty(key)) != null) { + Object value = propertySource.getProperty(key); + if (value != null) { Class valueType = value.getClass(); if (resolveNestedPlaceholders && value instanceof String) { value = resolveNestedPlaceholders((String) value);