From 67ea4b3a050af3db5545f58ff85a0d132ee91c2a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 6 Apr 2017 14:10:46 +0200 Subject: [PATCH] package-info for repackaged libraries (and other polishing) --- .../java/org/aopalliance/aop/package-info.java | 4 ++++ .../org/aopalliance/intercept/package-info.java | 4 ++++ .../main/java/org/aopalliance/package-info.java | 4 ++++ .../cache/config/CacheNamespaceHandler.java | 11 +++++++---- .../context/annotation/Configuration.java | 2 +- .../beanvalidation/LocalValidatorFactoryBean.java | 1 + .../org/springframework/asm/package-info.java | 6 ++---- .../org/springframework/cglib/package-info.java | 6 ++---- .../springframework/util/ObjectUtilsTests.java | 7 ++++++- .../jdbc/datasource/init/ScriptUtils.java | 15 +++++++-------- .../http/converter/FormHttpMessageConverter.java | 11 +++-------- .../http/converter/json/GsonBuilderUtils.java | 5 +---- .../http/converter/json/GsonFactoryBean.java | 6 +----- .../xml/Jaxb2CollectionHttpMessageConverter.java | 3 ++- 14 files changed, 45 insertions(+), 40 deletions(-) create mode 100644 spring-aop/src/main/java/org/aopalliance/aop/package-info.java create mode 100644 spring-aop/src/main/java/org/aopalliance/intercept/package-info.java create mode 100644 spring-aop/src/main/java/org/aopalliance/package-info.java diff --git a/spring-aop/src/main/java/org/aopalliance/aop/package-info.java b/spring-aop/src/main/java/org/aopalliance/aop/package-info.java new file mode 100644 index 0000000000..add1d414f6 --- /dev/null +++ b/spring-aop/src/main/java/org/aopalliance/aop/package-info.java @@ -0,0 +1,4 @@ +/** + * The core AOP Alliance advice marker. + */ +package org.aopalliance.aop; diff --git a/spring-aop/src/main/java/org/aopalliance/intercept/package-info.java b/spring-aop/src/main/java/org/aopalliance/intercept/package-info.java new file mode 100644 index 0000000000..11ada4f946 --- /dev/null +++ b/spring-aop/src/main/java/org/aopalliance/intercept/package-info.java @@ -0,0 +1,4 @@ +/** + * The AOP Alliance reflective interception abstraction. + */ +package org.aopalliance.intercept; diff --git a/spring-aop/src/main/java/org/aopalliance/package-info.java b/spring-aop/src/main/java/org/aopalliance/package-info.java new file mode 100644 index 0000000000..a525a32aec --- /dev/null +++ b/spring-aop/src/main/java/org/aopalliance/package-info.java @@ -0,0 +1,4 @@ +/** + * Spring's variant of the AOP Alliance interfaces. + */ +package org.aopalliance; diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java b/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java index 59dcc256df..68bcbcbdca 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java +++ b/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2017 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. @@ -39,10 +39,11 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport { static final String DEFAULT_CACHE_MANAGER_BEAN_NAME = "cacheManager"; + static String extractCacheManager(Element element) { - return (element.hasAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) ? element - .getAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) - : CacheNamespaceHandler.DEFAULT_CACHE_MANAGER_BEAN_NAME); + return (element.hasAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) ? + element.getAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) : + CacheNamespaceHandler.DEFAULT_CACHE_MANAGER_BEAN_NAME); } static BeanDefinition parseKeyGenerator(Element element, BeanDefinition def) { @@ -53,9 +54,11 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport { return def; } + @Override public void init() { registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenCacheBeanDefinitionParser()); registerBeanDefinitionParser("advice", new CacheAdviceParser()); } + } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java index 5e96e5fa1a..04627fb749 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java @@ -390,7 +390,7 @@ public @interface Configuration { /** * Explicitly specify the name of the Spring bean definition associated - * with this Configuration class. If left unspecified (the common case), + * with this Configuration class. If left unspecified (the common case), * a bean name will be automatically generated. *

The custom name applies only if the Configuration class is picked up via * component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}. diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java index 607ed56ca9..f9c2efc169 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java @@ -355,6 +355,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter @Override public ParameterNameProvider getParameterNameProvider() { + Assert.notNull(this.validatorFactory, "No target ValidatorFactory set"); return this.validatorFactory.getParameterNameProvider(); } diff --git a/spring-core/src/main/java/org/springframework/asm/package-info.java b/spring-core/src/main/java/org/springframework/asm/package-info.java index 98c9a0d8ca..dc7bf51693 100644 --- a/spring-core/src/main/java/org/springframework/asm/package-info.java +++ b/spring-core/src/main/java/org/springframework/asm/package-info.java @@ -1,6 +1,6 @@ /** * Spring's repackaging of - * org.objectweb.asm 5.0 + * ASM * (for internal use only). * *

This repackaging technique avoids any potential conflicts with @@ -8,8 +8,6 @@ * libraries and frameworks. * *

As this repackaging happens at the class file level, sources - * and javadocs are not available here. See the original ObjectWeb - * ASM 5.0 javadocs - * for details when working with these classes. + * and javadocs are not available here. */ package org.springframework.asm; diff --git a/spring-core/src/main/java/org/springframework/cglib/package-info.java b/spring-core/src/main/java/org/springframework/cglib/package-info.java index 78ef762bee..85d1758e53 100644 --- a/spring-core/src/main/java/org/springframework/cglib/package-info.java +++ b/spring-core/src/main/java/org/springframework/cglib/package-info.java @@ -1,6 +1,6 @@ /** * Spring's repackaging of - * net.sf.cglib 3.2 + * CGLIB * (for internal use only). * *

This repackaging technique avoids any potential conflicts with @@ -8,8 +8,6 @@ * libraries and frameworks. * *

As this repackaging happens at the class file level, sources - * and javadocs are not available here. See the original - * CGLIB 3.2 javadocs - * for details when working with these classes. + * and javadocs are not available here. */ package org.springframework.cglib; diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 71570eea61..57af7b38b7 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -239,18 +239,21 @@ public class ObjectUtilsTests { } @Test + @Deprecated public void hashCodeWithBooleanFalse() { int expected = Boolean.FALSE.hashCode(); assertEquals(expected, ObjectUtils.hashCode(false)); } @Test + @Deprecated public void hashCodeWithBooleanTrue() { int expected = Boolean.TRUE.hashCode(); assertEquals(expected, ObjectUtils.hashCode(true)); } @Test + @Deprecated public void hashCodeWithDouble() { double dbl = 9830.43; int expected = (new Double(dbl)).hashCode(); @@ -258,6 +261,7 @@ public class ObjectUtilsTests { } @Test + @Deprecated public void hashCodeWithFloat() { float flt = 34.8f; int expected = (new Float(flt)).hashCode(); @@ -265,6 +269,7 @@ public class ObjectUtilsTests { } @Test + @Deprecated public void hashCodeWithLong() { long lng = 883l; int expected = (new Long(lng)).hashCode(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index 5ff0cebf64..18190283c3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -199,7 +199,7 @@ public abstract class ScriptUtils { } if (!inSingleQuote && !inDoubleQuote) { if (script.startsWith(separator, i)) { - // we've reached the end of the current statement + // We've reached the end of the current statement if (sb.length() > 0) { statements.add(sb.toString()); sb = new StringBuilder(); @@ -208,32 +208,31 @@ public abstract class ScriptUtils { continue; } else if (script.startsWith(commentPrefix, i)) { - // skip over any content from the start of the comment to the EOL + // Skip over any content from the start of the comment to the EOL int indexOfNextNewline = script.indexOf("\n", i); if (indexOfNextNewline > i) { i = indexOfNextNewline; continue; } else { - // if there's no EOL, we must be at the end - // of the script, so stop here. + // If there's no EOL, we must be at the end of the script, so stop here. break; } } else if (script.startsWith(blockCommentStartDelimiter, i)) { - // skip over any block comments + // Skip over any block comments int indexOfCommentEnd = script.indexOf(blockCommentEndDelimiter, i); if (indexOfCommentEnd > i) { i = indexOfCommentEnd + blockCommentEndDelimiter.length() - 1; continue; } else { - throw new ScriptParseException(String.format("Missing block comment end delimiter [%s].", - blockCommentEndDelimiter), resource); + throw new ScriptParseException( + "Missing block comment end delimiter: " + blockCommentEndDelimiter, resource); } } else if (c == ' ' || c == '\n' || c == '\t') { - // avoid multiple adjacent whitespace characters + // Avoid multiple adjacent whitespace characters if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') { c = ' '; } diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 19194622fd..19c5b308a7 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -396,12 +396,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter getHttpEntity(Object part) { - if (part instanceof HttpEntity) { - return (HttpEntity) part; - } - else { - return new HttpEntity<>(part); - } + return (part instanceof HttpEntity ? (HttpEntity) part : new HttpEntity<>(part)); } /** @@ -416,7 +411,7 @@ public class FormHttpMessageConverter implements HttpMessageConverterNOTE: Use of this option requires the presence of the - * Apache Commons Codec library on the classpath when running on Java 6 or 7. - * On Java 8, the standard {@link java.util.Base64} facility is used instead. */ public static GsonBuilder gsonBuilderWithBase64EncodedByteArrays() { GsonBuilder builder = new GsonBuilder(); diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/GsonFactoryBean.java b/spring-web/src/main/java/org/springframework/http/converter/json/GsonFactoryBean.java index 549db72f47..0c5f05530a 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/GsonFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/GsonFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -24,7 +24,6 @@ import com.google.gson.GsonBuilder; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; - /** * A {@link FactoryBean} for creating a Google Gson 2.x {@link Gson} instance. * @@ -54,9 +53,6 @@ public class GsonFactoryBean implements FactoryBean, InitializingBean { * registered via {@link GsonBuilder#registerTypeHierarchyAdapter(Class, Object)} * which serializes a {@code byte[]} property to and from a Base64-encoded String * instead of a JSON array. - *

NOTE: Use of this option requires the presence of the - * Apache Commons Codec library on the classpath when running on Java 6 or 7. - * On Java 8, the standard {@link java.util.Base64} facility is used instead. * @see GsonBuilderUtils#gsonBuilderWithBase64EncodedByteArrays() */ public void setBase64EncodeByteArrays(boolean base64EncodeByteArrays) { diff --git a/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java index 884a53b34d..b9b3afc775 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -230,6 +230,7 @@ public class Jaxb2CollectionHttpMessageConverter @Override public void write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { + throw new UnsupportedOperationException(); }