diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java index 5acddd8ce54..38381ea1761 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -25,7 +25,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import java.util.Set; @@ -201,7 +200,7 @@ public abstract class YamlProcessor { } Map map = (Map) object; - for (Entry entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { Object value = entry.getValue(); if (value instanceof Map) { value = asMap(value); @@ -273,7 +272,7 @@ public abstract class YamlProcessor { } private void buildFlattenedMap(Map result, Map source, String path) { - for (Entry entry : source.entrySet()) { + for (Map.Entry entry : source.entrySet()) { String key = entry.getKey(); if (StringUtils.hasText(path)) { if (key.startsWith("[")) { diff --git a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java index 94ecbe74a06..e9f76390041 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java +++ b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -34,11 +34,17 @@ public class BeanFactoryResolver implements BeanResolver { private final BeanFactory beanFactory; + + /** + * Create a new {@link BeanFactoryResolver} for the given factory. + * @param beanFactory the {@link BeanFactory} to resolve bean names against + */ public BeanFactoryResolver(BeanFactory beanFactory) { Assert.notNull(beanFactory, "BeanFactory must not be null"); this.beanFactory = beanFactory; } + @Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { try { diff --git a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java index c48a347951a..5b5eb9f5bb3 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java +++ b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -143,8 +143,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver { } StandardEvaluationContext sec = this.evaluationCache.get(evalContext); if (sec == null) { - sec = new StandardEvaluationContext(); - sec.setRootObject(evalContext); + sec = new StandardEvaluationContext(evalContext); sec.addPropertyAccessor(new BeanExpressionContextAccessor()); sec.addPropertyAccessor(new BeanFactoryAccessor()); sec.addPropertyAccessor(new MapAccessor()); diff --git a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java index 908b54d3417..fa378ed0639 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -69,7 +69,7 @@ public abstract class SpringFactoriesLoader { /** * Load and instantiate the factory implementations of the given type from * {@value #FACTORIES_RESOURCE_LOCATION}, using the given class loader. - *

The returned factories are sorted in accordance with the {@link AnnotationAwareOrderComparator}. + *

The returned factories are sorted through {@link AnnotationAwareOrderComparator}. *

If a custom instantiation strategy is required, use {@link #loadFactoryNames} * to obtain all registered factory names. * @param factoryClass the interface or abstract class representing the factory diff --git a/spring-expression/src/main/java/org/springframework/expression/BeanResolver.java b/spring-expression/src/main/java/org/springframework/expression/BeanResolver.java index 1f6726f1f10..63355633357 100644 --- a/spring-expression/src/main/java/org/springframework/expression/BeanResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/BeanResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -17,10 +17,9 @@ package org.springframework.expression; /** - * A bean resolver can be registered with the evaluation context - * and will kick in for {@code @myBeanName} and {@code &myBeanName} expressions. - * The & variant syntax allows access to the factory bean where - * relevant. + * A bean resolver can be registered with the evaluation context and will kick in + * for bean references: {@code @myBeanName} and {@code &myBeanName} expressions. + * The & variant syntax allows access to the factory bean where relevant. * * @author Andy Clement * @since 3.0.3 @@ -28,12 +27,12 @@ package org.springframework.expression; public interface BeanResolver { /** - * Look up the named bean and return it. If attempting to access a factory - * bean the name will have a & prefix. + * Look up a bean by the given name and return a corresponding instance for it. + * For attempting access to a factory bean, the name needs a & prefix. * @param context the current evaluation context - * @param beanName the name of the bean to lookup + * @param beanName the name of the bean to look up * @return an object representing the bean - * @throws AccessException if there is an unexpected problem resolving the named bean + * @throws AccessException if there is an unexpected problem resolving the bean */ Object resolve(EvaluationContext context, String beanName) throws AccessException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java index 0ff6458b544..b93ad2f848a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -44,7 +44,7 @@ public abstract class AbstractExpressionTests { protected final ExpressionParser parser = new SpelExpressionParser(); - protected final StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext(); + protected final StandardEvaluationContext context = TestScenarioCreator.getTestEvaluationContext(); /** @@ -63,14 +63,14 @@ public abstract class AbstractExpressionTests { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext); + Object value = expr.getValue(context); // Check the return value if (value == null) { if (expectedValue == null) { return; // no point doing other checks } - assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null); + assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue); } Class resultType = value.getClass(); @@ -95,12 +95,12 @@ public abstract class AbstractExpressionTests { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext, expectedResultType); + Object value = expr.getValue(context, expectedResultType); if (value == null) { if (expectedValue == null) { return; // no point doing other checks } - assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null); + assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue); } Class resultType = value.getClass(); @@ -127,12 +127,12 @@ public abstract class AbstractExpressionTests { if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext); + Object value = expr.getValue(context); if (value == null) { if (expectedValue == null) { return; // no point doing other checks } - assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null); + assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue); } Class resultType = value.getClass(); if (expectedValue instanceof String) { @@ -142,10 +142,10 @@ public abstract class AbstractExpressionTests { else { assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value); } - assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult + - "' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType), true); + assertTrue("Type of the result was not as expected. Expected '" + expectedClassOfResult + + "' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType)); - boolean isWritable = expr.isWritable(eContext); + boolean isWritable = expr.isWritable(context); if (isWritable != shouldBeWritable) { if (shouldBeWritable) fail("Expected the expression to be writable but it is not"); @@ -184,10 +184,10 @@ public abstract class AbstractExpressionTests { fail("Parser returned null for expression"); } if (expectedReturnType != null) { - expr.getValue(eContext, expectedReturnType); + expr.getValue(context, expectedReturnType); } else { - expr.getValue(eContext); + expr.getValue(context); } fail("Should have failed with message " + expectedMessage); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java index f9c63b58148..5feccfb836a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -104,11 +104,12 @@ public class BooleanExpressionTests extends AbstractExpressionTests { return targetType.getType() == Boolean.class ? false : null; } }; - eContext.setTypeConverter(new StandardTypeConverter(conversionService)); + context.setTypeConverter(new StandardTypeConverter(conversionService)); evaluate("null or true", Boolean.TRUE, Boolean.class, false); evaluate("null and true", Boolean.FALSE, Boolean.class, false); evaluate("!null", Boolean.TRUE, Boolean.class, false); evaluate("null ? 'foo' : 'bar'", "bar", String.class, false); } + } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java index a6e753fea70..f28b6a6816b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java @@ -359,7 +359,7 @@ public class EvaluationTests extends AbstractExpressionTests { @Test public void testTernaryOperator04() { Expression e = parser.parseExpression("1>2?3:4"); - assertFalse(e.isWritable(eContext)); + assertFalse(e.isWritable(context)); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java index a09169f3e93..27f712c5be4 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -98,7 +98,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext(); eContext.setVariable("bar", 3); Object o = expr.getValue(eContext); - assertEquals(o, 3); + assertEquals(3, o); assertEquals(1, parser.parseExpression("counter").getValue(eContext)); // Now the expression has cached that throwException(int) is the right thing to call @@ -163,9 +163,9 @@ public class MethodInvocationTests extends AbstractExpressionTests { SpelExpressionParser parser = new SpelExpressionParser(); Expression expr = parser.parseExpression("throwException(#bar)"); - eContext.setVariable("bar", 2); + context.setVariable("bar", 2); try { - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (Exception ex) { @@ -187,9 +187,9 @@ public class MethodInvocationTests extends AbstractExpressionTests { SpelExpressionParser parser = new SpelExpressionParser(); Expression expr = parser.parseExpression("throwException(#bar)"); - eContext.setVariable("bar", 4); + context.setVariable("bar", 4); try { - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (ExpressionInvocationTargetException ex) { @@ -251,7 +251,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { ctx.addMethodResolver(dummy); assertEquals(2, ctx.getMethodResolvers().size()); - List copy = new ArrayList(); + List copy = new ArrayList<>(); copy.addAll(ctx.getMethodResolvers()); assertTrue(ctx.removeMethodResolver(dummy)); assertFalse(ctx.removeMethodResolver(dummy)); @@ -294,7 +294,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { public void testMethodOfClass() throws Exception { Expression expression = parser.parseExpression("getName()"); Object value = expression.getValue(new StandardEvaluationContext(String.class)); - assertEquals(value, "java.lang.String"); + assertEquals("java.lang.String", value); } @Test @@ -341,7 +341,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { @Override public List filter(List methods) { filterCalled = true; - List forRemoval = new ArrayList(); + List forRemoval = new ArrayList<>(); for (Method method: methods) { if (removeIfNotAnnotated && !isAnnotated(method)) { forRemoval.add(method); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 95cb70312da..534f8025ed4 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -102,11 +102,11 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void SPR5899() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Spr5899Class()); + StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class()); Expression expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(12)"); - assertEquals(12, expr.getValue(eContext)); + assertEquals(12, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(null)"); - assertEquals(null, expr.getValue(eContext)); + assertEquals(null, expr.getValue(context)); try { expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull2(null)"); expr.getValue(); @@ -115,73 +115,73 @@ public class SpelReproTests extends AbstractExpressionTests { catch (EvaluationException see) { // success } - eContext.setTypeLocator(new MyTypeLocator()); + context.setTypeLocator(new MyTypeLocator()); // varargs expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull3(null,'a','b')"); - assertEquals("ab", expr.getValue(eContext)); + assertEquals("ab", expr.getValue(context)); // varargs 2 - null is packed into the varargs expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull3(12,'a',null,'c')"); - assertEquals("anullc", expr.getValue(eContext)); + assertEquals("anullc", expr.getValue(context)); // check we can find the ctor ok expr = new SpelExpressionParser().parseRaw("new Spr5899Class().toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null).toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); // ctor varargs expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null,'a','b').toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); // ctor varargs 2 expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null,'a', null, 'b').toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); } @Test public void SPR5905_InnerTypeReferences() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Spr5899Class()); + StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class()); Expression expr = new SpelExpressionParser().parseRaw("T(java.util.Map$Entry)"); - assertEquals(Map.Entry.class, expr.getValue(eContext)); + assertEquals(Map.Entry.class, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("T(org.springframework.expression.spel.SpelReproTests$Outer$Inner).run()"); - assertEquals(12, expr.getValue(eContext)); + assertEquals(12, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("new org.springframework.expression.spel.SpelReproTests$Outer$Inner().run2()"); - assertEquals(13, expr.getValue(eContext)); + assertEquals(13, expr.getValue(context)); } @Test public void SPR5804() { Map m = new HashMap<>(); m.put("foo", "bar"); - StandardEvaluationContext eContext = new StandardEvaluationContext(m); // root is a map instance - eContext.addPropertyAccessor(new MapAccessor()); + StandardEvaluationContext context = new StandardEvaluationContext(m); // root is a map instance + context.addPropertyAccessor(new MapAccessor()); Expression expr = new SpelExpressionParser().parseRaw("['foo']"); - assertEquals("bar", expr.getValue(eContext)); + assertEquals("bar", expr.getValue(context)); } @Test public void SPR5847() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new TestProperties()); + StandardEvaluationContext context = new StandardEvaluationContext(new TestProperties()); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("jdbcProperties['username']"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("Dave", name); expr = new SpelExpressionParser().parseRaw("jdbcProperties[username]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("Dave", name); // MapAccessor required for this to work expr = new SpelExpressionParser().parseRaw("jdbcProperties.username"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Dave", name); // --- dotted property names @@ -189,14 +189,14 @@ public class SpelReproTests extends AbstractExpressionTests { // lookup foo on the root, then bar on that, then use that as the key into // jdbcProperties expr = new SpelExpressionParser().parseRaw("jdbcProperties[foo.bar]"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Dave2", name); // key is foo.bar expr = new SpelExpressionParser().parseRaw("jdbcProperties['foo.bar']"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Elephant", name); } @@ -237,60 +237,60 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void accessingNullPropertyViaReflection_SPR5663() throws AccessException { - PropertyAccessor propertyAccessor = new ReflectivePropertyAccessor(); + PropertyAccessor accessor = new ReflectivePropertyAccessor(); EvaluationContext context = TestScenarioCreator.getTestEvaluationContext(); - assertFalse(propertyAccessor.canRead(context, null, "abc")); - assertFalse(propertyAccessor.canWrite(context, null, "abc")); + assertFalse(accessor.canRead(context, null, "abc")); + assertFalse(accessor.canWrite(context, null, "abc")); try { - propertyAccessor.read(context, null, "abc"); - fail("Should have failed with an AccessException"); + accessor.read(context, null, "abc"); + fail("Should have failed with an IllegalStateException"); } - catch (AccessException ex) { + catch (IllegalStateException ex) { // expected } try { - propertyAccessor.write(context, null, "abc", "foo"); - fail("Should have failed with an AccessException"); + accessor.write(context, null, "abc", "foo"); + fail("Should have failed with an IllegalStateException"); } - catch (AccessException ex) { + catch (IllegalStateException ex) { // expected } } @Test public void nestedProperties_SPR6923() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Foo()); + StandardEvaluationContext context = new StandardEvaluationContext(new Foo()); Expression expr = new SpelExpressionParser().parseRaw("resource.resource.server"); - String name = expr.getValue(eContext, String.class); + String name = expr.getValue(context, String.class); assertEquals("abc", name); } /** Should be accessing Goo.getKey because 'bar' field evaluates to "key" */ @Test public void indexingAsAPropertyAccess_SPR6968_1() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[bar]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("hello", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("hello", name); } /** Should be accessing Goo.getKey because 'bar' variable evaluates to "key" */ @Test public void indexingAsAPropertyAccess_SPR6968_2() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); - eContext.setVariable("bar", "key"); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); + context.setVariable("bar", "key"); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("hello", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("hello", name); } @@ -298,8 +298,8 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void dollarPrefixedIdentifier_SPR7100() { Holder h = new Holder(); - StandardEvaluationContext eContext = new StandardEvaluationContext(h); - eContext.addPropertyAccessor(new MapAccessor()); + StandardEvaluationContext context = new StandardEvaluationContext(h); + context.addPropertyAccessor(new MapAccessor()); h.map.put("$foo", "wibble"); h.map.put("foo$bar", "wobble"); h.map.put("foobar$$", "wabble"); @@ -310,42 +310,42 @@ public class SpelReproTests extends AbstractExpressionTests { Expression expr = null; expr = new SpelExpressionParser().parseRaw("map.$foo"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wibble", name); expr = new SpelExpressionParser().parseRaw("map.foo$bar"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wobble", name); expr = new SpelExpressionParser().parseRaw("map.foobar$$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wabble", name); expr = new SpelExpressionParser().parseRaw("map.$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wubble", name); expr = new SpelExpressionParser().parseRaw("map.$$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("webble", name); expr = new SpelExpressionParser().parseRaw("map.$_$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("tribble", name); } /** Should be accessing Goo.wibble field because 'bar' variable evaluates to "wibble" */ @Test public void indexingAsAPropertyAccess_SPR6968_3() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); - eContext.setVariable("bar", "wibble"); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); + context.setVariable("bar", "wibble"); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]"); // will access the field 'wibble' and not use a getter - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wobble", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("wobble", name); } @@ -356,14 +356,14 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void indexingAsAPropertyAccess_SPR6968_4() { Goo g = Goo.instance; - StandardEvaluationContext eContext = new StandardEvaluationContext(g); - eContext.setVariable("bar", "wibble"); + StandardEvaluationContext context = new StandardEvaluationContext(g); + context.setVariable("bar", "wibble"); Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]='world'"); // will access the field 'wibble' and not use a getter - expr.getValue(eContext, String.class); + expr.getValue(context, String.class); assertEquals("world", g.wibble); - expr.getValue(eContext, String.class); // will be using the cached accessor this time + expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("world", g.wibble); } @@ -371,31 +371,31 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void indexingAsAPropertyAccess_SPR6968_5() { Goo g = Goo.instance; - StandardEvaluationContext eContext = new StandardEvaluationContext(g); + StandardEvaluationContext context = new StandardEvaluationContext(g); Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[bar]='world'"); - expr.getValue(eContext, String.class); + expr.getValue(context, String.class); assertEquals("world", g.value); - expr.getValue(eContext, String.class); // will be using the cached accessor this time + expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("world", g.value); } @Test public void dollars() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; expr = new SpelExpressionParser().parseRaw("m['$foo']"); - eContext.setVariable("file_name", "$foo"); - assertEquals("wibble", expr.getValue(eContext, String.class)); + context.setVariable("file_name", "$foo"); + assertEquals("wibble", expr.getValue(context, String.class)); } @Test public void dollars2() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; expr = new SpelExpressionParser().parseRaw("m[$foo]"); - eContext.setVariable("file_name", "$foo"); - assertEquals("wibble", expr.getValue(eContext, String.class)); + context.setVariable("file_name", "$foo"); + assertEquals("wibble", expr.getValue(context, String.class)); } private void checkTemplateParsing(String expression, String expectedValue) { @@ -448,33 +448,33 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void beanResolution() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; // no resolver registered == exception try { expr = new SpelExpressionParser().parseRaw("@foo"); - assertEquals("custard", expr.getValue(eContext, String.class)); + assertEquals("custard", expr.getValue(context, String.class)); } catch (SpelEvaluationException see) { assertEquals(SpelMessage.NO_BEAN_RESOLVER_REGISTERED, see.getMessageCode()); assertEquals("foo", see.getInserts()[0]); } - eContext.setBeanResolver(new MyBeanResolver()); + context.setBeanResolver(new MyBeanResolver()); // bean exists expr = new SpelExpressionParser().parseRaw("@foo"); - assertEquals("custard", expr.getValue(eContext, String.class)); + assertEquals("custard", expr.getValue(context, String.class)); // bean does not exist expr = new SpelExpressionParser().parseRaw("@bar"); - assertEquals(null, expr.getValue(eContext, String.class)); + assertEquals(null, expr.getValue(context, String.class)); // bean name will cause AccessException expr = new SpelExpressionParser().parseRaw("@goo"); try { - assertEquals(null, expr.getValue(eContext, String.class)); + assertEquals(null, expr.getValue(context, String.class)); } catch (SpelEvaluationException see) { assertEquals(SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION, see.getMessageCode()); @@ -485,12 +485,12 @@ public class SpelReproTests extends AbstractExpressionTests { // bean exists expr = new SpelExpressionParser().parseRaw("@'foo.bar'"); - assertEquals("trouble", expr.getValue(eContext, String.class)); + assertEquals("trouble", expr.getValue(context, String.class)); // bean exists try { expr = new SpelExpressionParser().parseRaw("@378"); - assertEquals("trouble", expr.getValue(eContext, String.class)); + assertEquals("trouble", expr.getValue(context, String.class)); } catch (SpelParseException spe) { assertEquals(SpelMessage.INVALID_BEAN_REFERENCE, spe.getMessageCode()); @@ -499,7 +499,7 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void elvis_SPR7209_1() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; // Different parts of elvis expression are null @@ -513,7 +513,7 @@ public class SpelReproTests extends AbstractExpressionTests { // Different parts of ternary expression are null try { expr = new SpelExpressionParser().parseRaw("(?'abc':'default')"); - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (SpelEvaluationException see) { @@ -525,7 +525,7 @@ public class SpelReproTests extends AbstractExpressionTests { // Assignment try { expr = new SpelExpressionParser().parseRaw("(='default')"); - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (SpelEvaluationException see) { @@ -553,55 +553,55 @@ public class SpelReproTests extends AbstractExpressionTests { nameMap.put("givenName", "Arthur"); map.put("value", nameMap); - StandardEvaluationContext ctx = new StandardEvaluationContext(map); + StandardEvaluationContext context = new StandardEvaluationContext(map); ExpressionParser parser = new SpelExpressionParser(); String el1 = "#root['value'].get('givenName')"; Expression exp = parser.parseExpression(el1); - Object evaluated = exp.getValue(ctx); + Object evaluated = exp.getValue(context); assertEquals("Arthur", evaluated); String el2 = "#root['value']['givenName']"; exp = parser.parseExpression(el2); - evaluated = exp.getValue(ctx); + evaluated = exp.getValue(context); assertEquals("Arthur", evaluated); } @Test public void projectionTypeDescriptors_1() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "ls.![#this.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - List value = (List) exp.getValue(ctx); + List value = (List) exp.getValue(context); // value is list containing [true,false] assertEquals(Boolean.class, value.get(0).getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(null, evaluated.getElementTypeDescriptor()); } @Test public void projectionTypeDescriptors_2() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "as.![#this.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - Object[] value = (Object[]) exp.getValue(ctx); + Object[] value = (Object[]) exp.getValue(context); // value is array containing [true,false] assertEquals(Boolean.class, value[0].getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(Boolean.class, evaluated.getElementTypeDescriptor().getType()); } @Test public void projectionTypeDescriptors_3() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "ms.![key.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - List value = (List) exp.getValue(ctx); + List value = (List) exp.getValue(context); // value is list containing [true,false] assertEquals(Boolean.class, value.get(0).getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(null, evaluated.getElementTypeDescriptor()); } @@ -615,23 +615,23 @@ public class SpelReproTests extends AbstractExpressionTests { list.add(new D(null)); list.add(new D("zzz")); - StandardEvaluationContext ctx = new StandardEvaluationContext(list); + StandardEvaluationContext context = new StandardEvaluationContext(list); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "#root.?[a < 'hhh']"; SpelExpression exp = parser.parseRaw(el1); - Object value = exp.getValue(ctx); + Object value = exp.getValue(context); assertEquals("[D(aaa), D(bbb), D(null), D(ccc), D(null)]", value.toString()); String el2 = "#root.?[a > 'hhh']"; SpelExpression exp2 = parser.parseRaw(el2); - Object value2 = exp2.getValue(ctx); + Object value2 = exp2.getValue(context); assertEquals("[D(zzz)]", value2.toString()); // trim out the nulls first String el3 = "#root.?[a!=null].?[a < 'hhh']"; SpelExpression exp3 = parser.parseRaw(el3); - Object value3 = exp3.getValue(ctx); + Object value3 = exp3.getValue(context); assertEquals("[D(aaa), D(bbb), D(ccc)]", value3.toString()); } @@ -820,41 +820,41 @@ public class SpelReproTests extends AbstractExpressionTests { } } - StandardEvaluationContext ctx = new StandardEvaluationContext(new Reserver()); + StandardEvaluationContext context = new StandardEvaluationContext(new Reserver()); SpelExpressionParser parser = new SpelExpressionParser(); String ex = "getReserver().NE"; SpelExpression exp = parser.parseRaw(ex); - String value = (String) exp.getValue(ctx); + String value = (String) exp.getValue(context); assertEquals("abc", value); ex = "getReserver().ne"; exp = parser.parseRaw(ex); - value = (String) exp.getValue(ctx); + value = (String) exp.getValue(context); assertEquals("def", value); ex = "getReserver().m[NE]"; exp = parser.parseRaw(ex); - value = (String) exp.getValue(ctx); + value = (String) exp.getValue(context); assertEquals("xyz", value); ex = "getReserver().DIV"; exp = parser.parseRaw(ex); - assertEquals(1, exp.getValue(ctx)); + assertEquals(1, exp.getValue(context)); ex = "getReserver().div"; exp = parser.parseRaw(ex); - assertEquals(3, exp.getValue(ctx)); + assertEquals(3, exp.getValue(context)); exp = parser.parseRaw("NE"); - assertEquals("abc", exp.getValue(ctx)); + assertEquals("abc", exp.getValue(context)); } @Test public void reservedWordProperties_SPR9862() { - StandardEvaluationContext ctx = new StandardEvaluationContext(); + StandardEvaluationContext context = new StandardEvaluationContext(); SpelExpressionParser parser = new SpelExpressionParser(); SpelExpression expression = parser.parseRaw("T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST"); - Object value = expression.getValue(ctx); + Object value = expression.getValue(context); assertEquals(value, Reserver.CONST); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java index 91bae22b4ca..7d5d6efcdae 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java @@ -38,7 +38,7 @@ import org.springframework.expression.spel.support.ReflectionHelper.ArgumentsMat import static org.junit.Assert.*; /** - * Tests for any helper code. + * Tests for reflection helper code. * * @author Andy Clement */ @@ -46,23 +46,14 @@ public class ReflectionHelperTests extends AbstractExpressionTests { @Test public void testFormatHelperForClassName() { - assertEquals("java.lang.String",FormatHelper.formatClassNameForMessage(String.class)); - assertEquals("java.lang.String[]",FormatHelper.formatClassNameForMessage(new String[1].getClass())); - assertEquals("java.lang.String[][]",FormatHelper.formatClassNameForMessage(new String[1][1].getClass())); - assertEquals("int[]",FormatHelper.formatClassNameForMessage(new int[1].getClass())); - assertEquals("int[][]",FormatHelper.formatClassNameForMessage(new int[1][2].getClass())); - assertEquals("null",FormatHelper.formatClassNameForMessage(null)); + assertEquals("java.lang.String", FormatHelper.formatClassNameForMessage(String.class)); + assertEquals("java.lang.String[]", FormatHelper.formatClassNameForMessage(String[].class)); + assertEquals("java.lang.String[][]", FormatHelper.formatClassNameForMessage(String[][].class)); + assertEquals("int[]", FormatHelper.formatClassNameForMessage(int[].class)); + assertEquals("int[][]", FormatHelper.formatClassNameForMessage(int[][].class)); + assertEquals("null", FormatHelper.formatClassNameForMessage(null)); } - /* - @Test - public void testFormatHelperForMethod() { - assertEquals("foo(java.lang.String)",FormatHelper.formatMethodForMessage("foo", String.class)); - assertEquals("goo(java.lang.String,int[])",FormatHelper.formatMethodForMessage("goo", String.class, new int[1].getClass())); - assertEquals("boo()",FormatHelper.formatMethodForMessage("boo")); - } - */ - @Test public void testUtilities() throws ParseException { SpelExpression expr = (SpelExpression)parser.parseExpression("3+4+5+6+7-2"); @@ -159,47 +150,45 @@ public class ReflectionHelperTests extends AbstractExpressionTests { StandardTypeConverter typeConverter = new StandardTypeConverter(); // Passing (Super,String) on call to foo(Sub,String) is not a match - checkMatch(new Class[] {Super.class,String.class}, new Class[] {Sub.class,String.class},typeConverter,null); + checkMatch(new Class[] {Super.class,String.class}, new Class[] {Sub.class,String.class}, typeConverter, null); } @Test public void testReflectionHelperCompareArguments_Varargs_ExactMatching() { StandardTypeConverter tc = new StandardTypeConverter(); - Class stringArrayClass = new String[0].getClass(); - Class integerArrayClass = new Integer[0].getClass(); // Passing (String[]) on call to (String[]) is exact match - checkMatch2(new Class[] {stringArrayClass}, new Class[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT); + checkMatch2(new Class[] {String[].class}, new Class[] {String[].class}, tc, ArgumentsMatchKind.EXACT); // Passing (Integer, String[]) on call to (Integer, String[]) is exact match - checkMatch2(new Class[] {Integer.class, stringArrayClass}, new Class[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT); + checkMatch2(new Class[] {Integer.class, String[].class}, new Class[] {Integer.class, String[].class}, tc, ArgumentsMatchKind.EXACT); // Passing (String, Integer, String[]) on call to (String, String, String[]) is exact match - checkMatch2(new Class[] {String.class, Integer.class, stringArrayClass}, new Class[] {String.class,Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT); + checkMatch2(new Class[] {String.class, Integer.class, String[].class}, new Class[] {String.class,Integer.class, String[].class}, tc, ArgumentsMatchKind.EXACT); // Passing (Sub, String[]) on call to (Super, String[]) is exact match - checkMatch2(new Class[] {Sub.class, stringArrayClass}, new Class[] {Super.class,stringArrayClass}, tc, ArgumentsMatchKind.CLOSE); + checkMatch2(new Class[] {Sub.class, String[].class}, new Class[] {Super.class,String[].class}, tc, ArgumentsMatchKind.CLOSE); // Passing (Integer, String[]) on call to (String, String[]) is exact match - checkMatch2(new Class[] {Integer.class, stringArrayClass}, new Class[] {String.class, stringArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION); + checkMatch2(new Class[] {Integer.class, String[].class}, new Class[] {String.class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION); // Passing (Integer, Sub, String[]) on call to (String, Super, String[]) is exact match checkMatch2(new Class[] {Integer.class, Sub.class, String[].class}, new Class[] {String.class,Super .class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION); // Passing (String) on call to (String[]) is exact match - checkMatch2(new Class[] {String.class}, new Class[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT); + checkMatch2(new Class[] {String.class}, new Class[] {String[].class}, tc, ArgumentsMatchKind.EXACT); // Passing (Integer,String) on call to (Integer,String[]) is exact match - checkMatch2(new Class[] {Integer.class, String.class}, new Class[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT); + checkMatch2(new Class[] {Integer.class, String.class}, new Class[] {Integer.class, String[].class}, tc, ArgumentsMatchKind.EXACT); // Passing (String) on call to (Integer[]) is conversion match (String to Integer) - checkMatch2(new Class[] {String.class}, new Class[] {integerArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION); + checkMatch2(new Class[] {String.class}, new Class[] {Integer[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION); // Passing (Sub) on call to (Super[]) is close match - checkMatch2(new Class[] {Sub.class}, new Class[] {new Super[0].getClass()}, tc, ArgumentsMatchKind.CLOSE); + checkMatch2(new Class[] {Sub.class}, new Class[] {Super[].class}, tc, ArgumentsMatchKind.CLOSE); // Passing (Super) on call to (Sub[]) is not a match - checkMatch2(new Class[] {Super.class}, new Class[] {new Sub[0].getClass()}, tc, null); + checkMatch2(new Class[] {Super.class}, new Class[] {Sub[].class}, tc, null); checkMatch2(new Class[] {Unconvertable.class, String.class}, new Class[] {Sub.class, Super[].class}, tc, null); @@ -234,12 +223,12 @@ public class ReflectionHelperTests extends AbstractExpressionTests { // varargs with nothing needing conversion args = new Object[] {3, "abc", "abc"}; ReflectionHelper.convertArguments(tc, args, twoArg, 1); - checkArguments(args, "3","abc","abc"); + checkArguments(args, "3", "abc", "abc"); // varargs with conversion required args = new Object[] {3, false ,3.0d}; ReflectionHelper.convertArguments(tc, args, twoArg, 1); - checkArguments(args, "3","false","3.0"); + checkArguments(args, "3", "false", "3.0"); } @Test @@ -251,33 +240,33 @@ public class ReflectionHelperTests extends AbstractExpressionTests { // Simple conversion: int to string Object[] args = new Object[] {3}; ReflectionHelper.convertAllArguments(tc, args, oneArg); - checkArguments(args,"3"); + checkArguments(args, "3"); // varargs conversion args = new Object[] {3, false, 3.0f}; ReflectionHelper.convertAllArguments(tc, args, twoArg); - checkArguments(args,"3","false","3.0"); + checkArguments(args, "3", "false", "3.0"); // varargs conversion but no varargs args = new Object[] {3}; ReflectionHelper.convertAllArguments(tc, args, twoArg); - checkArguments(args,"3"); + checkArguments(args, "3"); // null value args = new Object[] {3, null, 3.0f}; ReflectionHelper.convertAllArguments(tc, args, twoArg); - checkArguments(args,"3",null,"3.0"); + checkArguments(args, "3", null, "3.0"); } @Test public void testSetupArguments() { Object[] newArray = ReflectionHelper.setupArgumentsForVarargsInvocation( - new Class[] {new String[0].getClass()},"a","b","c"); + new Class[] {String[].class}, "a", "b", "c"); assertEquals(1, newArray.length); Object firstParam = newArray[0]; assertEquals(String.class,firstParam.getClass().getComponentType()); - Object[] firstParamArray = (Object[])firstParam; + Object[] firstParamArray = (Object[]) firstParam; assertEquals(3,firstParamArray.length); assertEquals("a",firstParamArray[0]); assertEquals("b",firstParamArray[1]); @@ -285,75 +274,75 @@ public class ReflectionHelperTests extends AbstractExpressionTests { } @Test - public void testReflectivePropertyResolver() throws Exception { - ReflectivePropertyAccessor rpr = new ReflectivePropertyAccessor(); + public void testReflectivePropertyAccessor() throws Exception { + ReflectivePropertyAccessor rpa = new ReflectivePropertyAccessor(); Tester t = new Tester(); t.setProperty("hello"); EvaluationContext ctx = new StandardEvaluationContext(t); - assertTrue(rpr.canRead(ctx, t, "property")); - assertEquals("hello",rpr.read(ctx, t, "property").getValue()); - assertEquals("hello",rpr.read(ctx, t, "property").getValue()); // cached accessor used + assertTrue(rpa.canRead(ctx, t, "property")); + assertEquals("hello",rpa.read(ctx, t, "property").getValue()); + assertEquals("hello",rpa.read(ctx, t, "property").getValue()); // cached accessor used - assertTrue(rpr.canRead(ctx, t, "field")); - assertEquals(3,rpr.read(ctx, t, "field").getValue()); - assertEquals(3,rpr.read(ctx, t, "field").getValue()); // cached accessor used + assertTrue(rpa.canRead(ctx, t, "field")); + assertEquals(3,rpa.read(ctx, t, "field").getValue()); + assertEquals(3,rpa.read(ctx, t, "field").getValue()); // cached accessor used - assertTrue(rpr.canWrite(ctx, t, "property")); - rpr.write(ctx, t, "property","goodbye"); - rpr.write(ctx, t, "property","goodbye"); // cached accessor used + assertTrue(rpa.canWrite(ctx, t, "property")); + rpa.write(ctx, t, "property", "goodbye"); + rpa.write(ctx, t, "property", "goodbye"); // cached accessor used - assertTrue(rpr.canWrite(ctx, t, "field")); - rpr.write(ctx, t, "field",12); - rpr.write(ctx, t, "field",12); + assertTrue(rpa.canWrite(ctx, t, "field")); + rpa.write(ctx, t, "field", 12); + rpa.write(ctx, t, "field", 12); // Attempted write as first activity on this field and property to drive testing // of populating type descriptor cache - rpr.write(ctx,t,"field2",3); - rpr.write(ctx, t, "property2","doodoo"); - assertEquals(3,rpr.read(ctx,t,"field2").getValue()); + rpa.write(ctx, t, "field2", 3); + rpa.write(ctx, t, "property2", "doodoo"); + assertEquals(3,rpa.read(ctx, t, "field2").getValue()); // Attempted read as first activity on this field and property (no canRead before them) - assertEquals(0,rpr.read(ctx,t,"field3").getValue()); - assertEquals("doodoo",rpr.read(ctx,t,"property3").getValue()); + assertEquals(0,rpa.read(ctx, t, "field3").getValue()); + assertEquals("doodoo",rpa.read(ctx, t, "property3").getValue()); // Access through is method -// assertEquals(0,rpr.read(ctx,t,"field3").getValue()); - assertEquals(false,rpr.read(ctx,t,"property4").getValue()); - assertTrue(rpr.canRead(ctx,t,"property4")); + assertEquals(0,rpa .read(ctx, t, "field3").getValue()); + assertEquals(false,rpa.read(ctx, t, "property4").getValue()); + assertTrue(rpa.canRead(ctx, t, "property4")); // repro SPR-9123, ReflectivePropertyAccessor JavaBean property names compliance tests - assertEquals("iD",rpr.read(ctx,t,"iD").getValue()); - assertTrue(rpr.canRead(ctx,t,"iD")); - assertEquals("id",rpr.read(ctx,t,"id").getValue()); - assertTrue(rpr.canRead(ctx,t,"id")); - assertEquals("ID",rpr.read(ctx,t,"ID").getValue()); - assertTrue(rpr.canRead(ctx,t,"ID")); + assertEquals("iD",rpa.read(ctx, t, "iD").getValue()); + assertTrue(rpa.canRead(ctx, t, "iD")); + assertEquals("id",rpa.read(ctx, t, "id").getValue()); + assertTrue(rpa.canRead(ctx, t, "id")); + assertEquals("ID",rpa.read(ctx, t, "ID").getValue()); + assertTrue(rpa.canRead(ctx, t, "ID")); // note: "Id" is not a valid JavaBean name, nevertheless it is treated as "id" - assertEquals("id",rpr.read(ctx,t,"Id").getValue()); - assertTrue(rpr.canRead(ctx,t,"Id")); + assertEquals("id",rpa.read(ctx, t, "Id").getValue()); + assertTrue(rpa.canRead(ctx, t, "Id")); // repro SPR-10994 - assertEquals("xyZ",rpr.read(ctx,t,"xyZ").getValue()); - assertTrue(rpr.canRead(ctx,t,"xyZ")); - assertEquals("xY",rpr.read(ctx,t,"xY").getValue()); - assertTrue(rpr.canRead(ctx,t,"xY")); + assertEquals("xyZ",rpa.read(ctx, t, "xyZ").getValue()); + assertTrue(rpa.canRead(ctx, t, "xyZ")); + assertEquals("xY",rpa.read(ctx, t, "xY").getValue()); + assertTrue(rpa.canRead(ctx, t, "xY")); // SPR-10122, ReflectivePropertyAccessor JavaBean property names compliance tests - setters - rpr.write(ctx, t, "pEBS","Test String"); - assertEquals("Test String",rpr.read(ctx,t,"pEBS").getValue()); + rpa.write(ctx, t, "pEBS", "Test String"); + assertEquals("Test String",rpa.read(ctx, t, "pEBS").getValue()); } @Test - public void testOptimalReflectivePropertyResolver() throws Exception { - ReflectivePropertyAccessor rpr = new ReflectivePropertyAccessor(); + public void testOptimalReflectivePropertyAccessor() throws Exception { + ReflectivePropertyAccessor rpa = new ReflectivePropertyAccessor(); Tester t = new Tester(); t.setProperty("hello"); EvaluationContext ctx = new StandardEvaluationContext(t); -// assertTrue(rpr.canRead(ctx, t, "property")); -// assertEquals("hello",rpr.read(ctx, t, "property").getValue()); -// assertEquals("hello",rpr.read(ctx, t, "property").getValue()); // cached accessor used + assertTrue(rpa.canRead(ctx, t, "property")); + assertEquals("hello", rpa.read(ctx, t, "property").getValue()); + assertEquals("hello", rpa.read(ctx, t, "property").getValue()); // cached accessor used - PropertyAccessor optA = rpr.createOptimalAccessor(ctx, t, "property"); + PropertyAccessor optA = rpa.createOptimalAccessor(ctx, t, "property"); assertTrue(optA.canRead(ctx, t, "property")); assertFalse(optA.canRead(ctx, t, "property2")); try { @@ -381,14 +370,14 @@ public class ReflectionHelperTests extends AbstractExpressionTests { // success } try { - optA.write(ctx,t,"property",null); + optA.write(ctx, t, "property", null); fail(); } catch (UnsupportedOperationException uoe) { // success } - optA = rpr.createOptimalAccessor(ctx, t, "field"); + optA = rpa.createOptimalAccessor(ctx, t, "field"); assertTrue(optA.canRead(ctx, t, "field")); assertFalse(optA.canRead(ctx, t, "field2")); try { @@ -406,7 +395,7 @@ public class ReflectionHelperTests extends AbstractExpressionTests { // success } assertEquals(3,optA.read(ctx, t, "field").getValue()); - assertEquals(3,optA.read(ctx, t, "field").getValue()); // cached accessor used + assertEquals(3,optA.read(ctx, t, "field").getValue()); // cached accessor used try { optA.getSpecificTargetClasses(); @@ -416,7 +405,7 @@ public class ReflectionHelperTests extends AbstractExpressionTests { // success } try { - optA.write(ctx,t,"field",null); + optA.write(ctx, t, "field", null); fail(); } catch (UnsupportedOperationException uoe) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java index 929b40a1104..700951b0027 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.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. @@ -49,7 +49,7 @@ import org.springframework.util.StringUtils; * top-level class and it must have a default or no-arg constructor. * *

Column values are mapped based on matching the column name as obtained from result set - * metadata to public setters for the corresponding properties. The names are matched either + * meta-data to public setters for the corresponding properties. The names are matched either * directly or by transforming a name separating the parts with underscores to the same name * using "camel" case. * @@ -207,7 +207,7 @@ public class BeanPropertyRowMapper implements RowMapper { /** - * Initialize the mapping metadata for the given class. + * Initialize the mapping meta-data for the given class. * @param mappedClass the mapped class */ protected void initialize(Class mappedClass) { @@ -268,7 +268,7 @@ public class BeanPropertyRowMapper implements RowMapper { /** * Extract the values for all columns in the current row. - *

Utilizes public setters and result set metadata. + *

Utilizes public setters and result set meta-data. * @see java.sql.ResultSetMetaData */ @Override @@ -361,7 +361,6 @@ public class BeanPropertyRowMapper implements RowMapper { * @param rs is the ResultSet holding the data * @param index is the column index * @param pd the bean property that each result object is expected to match - * (or {@code null} if none specified) * @return the Object value * @throws SQLException in case of extraction failure * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java index 0e65bf8d2ee..37a7d895817 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java @@ -258,7 +258,7 @@ public class PreparedStatementCreatorFactory { for (int i = 0; i < this.parameters.size(); i++) { Object in = this.parameters.get(i); SqlParameter declaredParameter; - // SqlParameterValue overrides declared parameter metadata, in particular for + // SqlParameterValue overrides declared parameter meta-data, in particular for // independence from the declared parameter position in case of named parameters. if (in instanceof SqlParameterValue) { SqlParameterValue paramValue = (SqlParameterValue) in; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/ResultSetSupportingSqlParameter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/ResultSetSupportingSqlParameter.java index ca515b5bbc8..b6b05c0be74 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/ResultSetSupportingSqlParameter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/ResultSetSupportingSqlParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -127,7 +127,7 @@ public class ResultSetSupportingSqlParameter extends SqlParameter { /** - *

This implementation always returns {@code false}. + * This implementation always returns {@code false}. */ @Override public boolean isInputValueProvided() { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlInOutParameter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlInOutParameter.java index 1c25a16b853..bec02349db7 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlInOutParameter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlInOutParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -21,8 +21,7 @@ package org.springframework.jdbc.core; * Will return {@code true} for SqlParameter's {@link #isInputValueProvided} * test, in contrast to a standard SqlOutParameter. * - *

Output parameters - like all stored procedure parameters - - * must have names. + *

Output parameters - like all stored procedure parameters - must have names. * * @author Thomas Risberg * @author Juergen Hoeller diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlOutParameter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlOutParameter.java index 0baba25d2f3..367a3fb195e 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlOutParameter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlOutParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 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. @@ -17,12 +17,10 @@ package org.springframework.jdbc.core; /** - * Subclass of SqlParameter to represent an output parameter. - * No additional properties: instanceof will be used to check - * for such types. + * Subclass of {@link SqlParameter} to represent an output parameter. + * No additional properties: instanceof will be used to check for such types. * - *

Output parameters - like all stored procedure parameters - - * must have names. + *

Output parameters - like all stored procedure parameters - must have names. * * @author Rod Johnson * @author Thomas Risberg diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java index b4ce5c5bee5..ffcd702620d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java @@ -25,7 +25,7 @@ import org.springframework.util.Assert; /** * Object to represent a SQL parameter definition. * - *

Parameters may be anonymous in which case "name" is {@code null}. + *

Parameters may be anonymous, in which case "name" is {@code null}. * However, all parameters must define a SQL type according to {@link java.sql.Types}. * * @author Rod Johnson @@ -165,7 +165,7 @@ public class SqlParameter { /** * Return whether this parameter is an implicit return parameter used during the - * results preocessing of the CallableStatement.getMoreResults/getUpdateCount. + * results processing of {@code CallableStatement.getMoreResults/getUpdateCount}. *

This implementation always returns {@code false}. */ public boolean isResultsParameter() { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameterValue.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameterValue.java index 4fdc5b10d31..3c30cf01d09 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameterValue.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameterValue.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. @@ -17,7 +17,7 @@ package org.springframework.jdbc.core; /** - * Object to represent a SQL parameter value, including parameter metadata + * Object to represent a SQL parameter value, including parameter meta-data * such as the SQL type and the scale for numeric values. * *

Designed for use with {@link JdbcTemplate}'s operations that take an array of diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnResultSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnResultSet.java index 02e956c2915..6ea9cecaa73 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnResultSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnResultSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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,7 +23,7 @@ package org.springframework.jdbc.core; * must be provided to handle any returned rows. * *

Returned {@link java.sql.ResultSet ResultSets} - like all stored procedure - * parameters - must have names. + * parameters - must have names. * * @author Thomas Risberg * @author Juergen Hoeller @@ -57,13 +57,13 @@ public class SqlReturnResultSet extends ResultSetSupportingSqlParameter { super(name, 0, mapper); } + /** - * Return whether this parameter is an implicit return parameter used during the - * results preocessing of the CallableStatement.getMoreResults/getUpdateCount. - *

This implementation always returns {@code true}. + * This implementation always returns {@code true}. */ @Override public boolean isResultsParameter() { return true; } + } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnUpdateCount.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnUpdateCount.java index 397ce33e6fa..d78431fbd47 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnUpdateCount.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlReturnUpdateCount.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2018 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. + * 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.springframework.jdbc.core; import java.sql.Types; @@ -13,7 +29,7 @@ import java.sql.Types; public class SqlReturnUpdateCount extends SqlParameter { /** - * Create a new instance of the {@link SqlReturnUpdateCount} class. + * Create a new SqlReturnUpdateCount. * @param name name of the parameter, as used in input and output maps */ public SqlReturnUpdateCount(String name) { @@ -22,9 +38,7 @@ public class SqlReturnUpdateCount extends SqlParameter { /** - * Return whether this parameter holds input values that should be set - * before execution even if they are {@code null}. - *

This implementation always returns {@code false}. + * This implementation always returns {@code false}. */ @Override public boolean isInputValueProvided() { @@ -32,12 +46,11 @@ public class SqlReturnUpdateCount extends SqlParameter { } /** - * Return whether this parameter is an implicit return parameter used during the - * results preocessing of the CallableStatement.getMoreResults/getUpdateCount. - *

This implementation always returns {@code true}. + * This implementation always returns {@code true}. */ @Override public boolean isResultsParameter() { return true; } + } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java index a888190dc60..ad5c8f1ddb1 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java @@ -23,7 +23,7 @@ import java.util.List; import org.springframework.jdbc.core.SqlParameter; /** - * Interface specifying the API to be implemented by a class providing call metadata. + * Interface specifying the API to be implemented by a class providing call meta-data. * *

This is intended for internal use by Spring's * {@link org.springframework.jdbc.core.simple.SimpleJdbcCall}. @@ -41,9 +41,9 @@ public interface CallMetaDataProvider { void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException; /** - * Initialize the database specific management of procedure column meta data. + * Initialize the database specific management of procedure column meta-data. * This is only called for databases that are supported. This initialization - * can be turned off by specifying that column meta data should not be used. + * can be turned off by specifying that column meta-data should not be used. * @param databaseMetaData used to retrieve database specific information * @param catalogName name of catalog to use (or {@code null} if none) * @param schemaName name of schema name to use (or {@code null} if none) @@ -55,80 +55,80 @@ public interface CallMetaDataProvider { String schemaName, String procedureName) throws SQLException; /** - * Provide any modification of the procedure name passed in to match the meta data currently used. + * Provide any modification of the procedure name passed in to match the meta-data currently used. * This could include altering the case. */ String procedureNameToUse(String procedureName); /** - * Provide any modification of the catalog name passed in to match the meta data currently used. + * Provide any modification of the catalog name passed in to match the meta-data currently used. * This could include altering the case. */ String catalogNameToUse(String catalogName); /** - * Provide any modification of the schema name passed in to match the meta data currently used. + * Provide any modification of the schema name passed in to match the meta-data currently used. * This could include altering the case. */ String schemaNameToUse(String schemaName); /** - * Provide any modification of the catalog name passed in to match the meta data currently used. - * The returned value will be used for meta data lookups. This could include altering the case + * Provide any modification of the catalog name passed in to match the meta-data currently used. + * The returned value will be used for meta-data lookups. This could include altering the case * used or providing a base catalog if none is provided. */ - String metaDataCatalogNameToUse(String catalogName) ; + String metaDataCatalogNameToUse(String catalogName); /** - * Provide any modification of the schema name passed in to match the meta data currently used. - * The returned value will be used for meta data lookups. This could include altering the case + * Provide any modification of the schema name passed in to match the meta-data currently used. + * The returned value will be used for meta-data lookups. This could include altering the case * used or providing a base schema if none is provided. */ - String metaDataSchemaNameToUse(String schemaName) ; + String metaDataSchemaNameToUse(String schemaName); /** - * Provide any modification of the column name passed in to match the meta data currently used. + * Provide any modification of the column name passed in to match the meta-data currently used. * This could include altering the case. * @param parameterName name of the parameter of column */ String parameterNameToUse(String parameterName); /** - * Create a default out parameter based on the provided meta data. + * Create a default out parameter based on the provided meta-data. * This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter - * @param meta meta data used for this call + * @param meta meta-data used for this call * @return the configured SqlOutParameter */ SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta); /** - * Create a default inout parameter based on the provided meta data. + * Create a default inout parameter based on the provided meta-data. * This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter - * @param meta meta data used for this call + * @param meta meta-data used for this call * @return the configured SqlInOutParameter */ SqlParameter createDefaultInOutParameter(String parameterName, CallParameterMetaData meta); /** - * Create a default in parameter based on the provided meta data. + * Create a default in parameter based on the provided meta-data. * This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter - * @param meta meta data used for this call + * @param meta meta-data used for this call * @return the configured SqlParameter */ SqlParameter createDefaultInParameter(String parameterName, CallParameterMetaData meta); /** - * Get the name of the current user. Useful for meta data lookups etc. + * Get the name of the current user. Useful for meta-data lookups etc. * @return current user name from database connection */ String getUserName(); /** - * Does this database support returning ResultSets that should be retrieved with the JDBC call. - * {@link java.sql.Statement#getResultSet()} + * Does this database support returning ResultSets that should be retrieved with the JDBC call: + * {@link java.sql.Statement#getResultSet()}? */ boolean isReturnResultSetSupported(); @@ -145,7 +145,7 @@ public interface CallMetaDataProvider { int getRefCursorSqlType(); /** - * Are we using the meta data for the procedure columns? + * Are we using the meta-data for the procedure columns? */ boolean isProcedureColumnMetaDataUsed(); @@ -157,18 +157,18 @@ public interface CallMetaDataProvider { boolean byPassReturnParameter(String parameterName); /** - * Get the call parameter metadata that is currently used. + * Get the call parameter meta-data that is currently used. * @return List of {@link CallParameterMetaData} */ List getCallParameterMetaData(); /** - * Does the database support the use of catalog name in procedure calls + * Does the database support the use of catalog name in procedure calls? */ boolean isSupportsCatalogsInProcedureCalls(); /** - * Does the database support the use of schema name in procedure calls + * Does the database support the use of schema name in procedure calls? */ boolean isSupportsSchemasInProcedureCalls(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java index 528176097bd..b220c04ba5c 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java @@ -63,9 +63,9 @@ public class CallMetaDataProviderFactory { /** - * Create a {@link CallMetaDataProvider} based on the database metadata - * @param dataSource used to retrieve metadata - * @param context the class that holds configuration and metadata + * Create a {@link CallMetaDataProvider} based on the database meta-data. + * @param dataSource the JDBC DataSource to use for retrieving meta-data + * @param context the class that holds configuration and meta-data * @return instance of the CallMetaDataProvider implementation to be used */ public static CallMetaDataProvider createMetaDataProvider(DataSource dataSource, final CallMetaDataContext context) { @@ -139,7 +139,7 @@ public class CallMetaDataProviderFactory { }); } catch (MetaDataAccessException ex) { - throw new DataAccessResourceFailureException("Error retrieving database metadata", ex); + throw new DataAccessResourceFailureException("Error retrieving database meta-data", ex); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyTableMetaDataProvider.java index 8ea0bdfffb6..b40ac99fb0a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyTableMetaDataProvider.java @@ -21,7 +21,7 @@ import java.sql.SQLException; /** * The Derby specific implementation of {@link TableMetaDataProvider}. - * Overrides the Derby metadata info regarding retrieving generated keys. + * Overrides the Derby meta-data info regarding retrieving generated keys. * * @author Thomas Risberg * @since 3.0 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java index c580fde6d0a..efaecad81f3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java @@ -61,8 +61,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { /** - * Constructor used to initialize with provided database meta data. - * @param databaseMetaData meta data to be used + * Constructor used to initialize with provided database meta-data. + * @param databaseMetaData meta-data to be used */ protected GenericCallMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException { this.userName = databaseMetaData.getUserName(); @@ -249,14 +249,14 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { /** - * Specify whether the database supports the use of catalog name in procedure calls + * Specify whether the database supports the use of catalog name in procedure calls. */ protected void setSupportsCatalogsInProcedureCalls(boolean supportsCatalogsInProcedureCalls) { this.supportsCatalogsInProcedureCalls = supportsCatalogsInProcedureCalls; } /** - * Does the database support the use of catalog name in procedure calls + * Does the database support the use of catalog name in procedure calls? */ @Override public boolean isSupportsCatalogsInProcedureCalls() { @@ -264,14 +264,14 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { } /** - * Specify whether the database supports the use of schema name in procedure calls + * Specify whether the database supports the use of schema name in procedure calls. */ protected void setSupportsSchemasInProcedureCalls(boolean supportsSchemasInProcedureCalls) { this.supportsSchemasInProcedureCalls = supportsSchemasInProcedureCalls; } /** - * Does the database support the use of schema name in procedure calls + * Does the database support the use of schema name in procedure calls? */ @Override public boolean isSupportsSchemasInProcedureCalls() { @@ -279,28 +279,28 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { } /** - * Specify whether the database uses upper case for identifiers + * Specify whether the database uses upper case for identifiers. */ protected void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) { this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers; } /** - * Does the database use upper case for identifiers + * Does the database use upper case for identifiers? */ protected boolean isStoresUpperCaseIdentifiers() { return this.storesUpperCaseIdentifiers; } /** - * Specify whether the database uses lower case for identifiers + * Specify whether the database uses lower case for identifiers. */ protected void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) { this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers; } /** - * Does the database use lower case for identifiers + * Does the database use lower case for identifiers? */ protected boolean isStoresLowerCaseIdentifiers() { return this.storesLowerCaseIdentifiers; @@ -308,7 +308,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { /** - * Process the procedure column metadata + * Process the procedure column meta-data. */ private void processProcedureColumns( DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String procedureName) { @@ -317,7 +317,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { String metaDataSchemaName = metaDataSchemaNameToUse(schemaName); String metaDataProcedureName = procedureNameToUse(procedureName); if (logger.isDebugEnabled()) { - logger.debug("Retrieving metadata for " + metaDataCatalogName + '/' + + logger.debug("Retrieving meta-data for " + metaDataCatalogName + '/' + metaDataSchemaName + '/' + metaDataProcedureName); } @@ -367,7 +367,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { columnType == DatabaseMetaData.procedureColumnInOut || columnType == DatabaseMetaData.procedureColumnOut)) { if (logger.isDebugEnabled()) { - logger.debug("Skipping metadata for: " + columnType + " " + procs.getInt("DATA_TYPE") + + logger.debug("Skipping meta-data for: " + columnType + " " + procs.getInt("DATA_TYPE") + " " + procs.getString("TYPE_NAME") + " " + procs.getInt("NULLABLE") + " (probably a member of a collection)"); } @@ -378,7 +378,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { procs.getInt("NULLABLE") == DatabaseMetaData.procedureNullable); this.callParameterMetaData.add(meta); if (logger.isDebugEnabled()) { - logger.debug("Retrieved metadata: " + meta.getParameterName() + " " + + logger.debug("Retrieved meta-data: " + meta.getParameterName() + " " + meta.getParameterType() + " " + meta.getSqlType() + " " + meta.getTypeName() + " " + meta.isNullable()); } @@ -387,7 +387,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { } catch (SQLException ex) { if (logger.isWarnEnabled()) { - logger.warn("Error while retrieving metadata for procedure columns: " + ex); + logger.warn("Error while retrieving meta-data for procedure columns: " + ex); } } finally { @@ -398,7 +398,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { } catch (SQLException ex) { if (logger.isWarnEnabled()) { - logger.warn("Problem closing ResultSet for procedure column metadata: " + ex); + logger.warn("Problem closing ResultSet for procedure column meta-data: " + ex); } } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java index a86338237c7..10c15f869d5 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java @@ -46,7 +46,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { /** Logger available to subclasses */ protected static final Log logger = LogFactory.getLog(TableMetaDataProvider.class); - /** indicator whether column metadata should be used */ + /** indicator whether column meta-data should be used */ private boolean tableColumnMetaDataUsed = false; /** the version of the database */ @@ -79,8 +79,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { /** - * Constructor used to initialize with provided database metadata. - * @param databaseMetaData metadata to be used + * Constructor used to initialize with provided database meta-data. + * @param databaseMetaData meta-data to be used */ protected GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException { this.userName = databaseMetaData.getUserName(); @@ -307,7 +307,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } /** - * Method supporting the metadata processing for a table. + * Method supporting the meta-data processing for a table. */ private void locateTableAndProcessMetaData( DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName) { @@ -332,7 +332,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } catch (SQLException ex) { if (logger.isWarnEnabled()) { - logger.warn("Error while accessing table meta data results: " + ex.getMessage()); + logger.warn("Error while accessing table meta-data results: " + ex.getMessage()); } } finally { @@ -341,7 +341,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { if (tableMeta.isEmpty()) { if (logger.isWarnEnabled()) { - logger.warn("Unable to locate table meta data for '" + tableName + "': column names must be provided"); + logger.warn("Unable to locate table meta-data for '" + tableName + "': column names must be provided"); } } else { @@ -353,7 +353,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { if (schemaName != null) { TableMetaData tmd = tableMeta.get(schemaName.toUpperCase()); if (tmd == null) { - throw new DataAccessResourceFailureException("Unable to locate table meta data for '" + + throw new DataAccessResourceFailureException("Unable to locate table meta-data for '" + tableName + "' in the '" + schemaName + "' schema"); } return tmd; @@ -374,14 +374,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { } if (tmd == null) { throw new DataAccessResourceFailureException( - "Unable to locate table meta data for '" + tableName + "' in the default schema"); + "Unable to locate table meta-data for '" + tableName + "' in the default schema"); } return tmd; } } /** - * Method supporting the metadata processing for a table's columns + * Method supporting the meta-data processing for a table's columns */ private void processTableColumns(DatabaseMetaData databaseMetaData, TableMetaData tmd) { ResultSet tableColumns = null; @@ -389,7 +389,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { String metaDataSchemaName = metaDataSchemaNameToUse(tmd.getSchemaName()); String metaDataTableName = tableNameToUse(tmd.getTableName()); if (logger.isDebugEnabled()) { - logger.debug("Retrieving metadata for " + metaDataCatalogName + '/' + + logger.debug("Retrieving meta-data for " + metaDataCatalogName + '/' + metaDataSchemaName + '/' + metaDataTableName); } try { @@ -407,7 +407,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { if ("NUMBER".equals(typeName) && decimalDigits == 0) { dataType = Types.NUMERIC; if (logger.isDebugEnabled()) { - logger.debug("Overriding metadata: " + columnName + " now NUMERIC instead of DECIMAL"); + logger.debug("Overriding meta-data: " + columnName + " now NUMERIC instead of DECIMAL"); } } } @@ -415,14 +415,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable); this.tableParameterMetaData.add(meta); if (logger.isDebugEnabled()) { - logger.debug("Retrieved metadata: " + meta.getParameterName() + " " + + logger.debug("Retrieved meta-data: " + meta.getParameterName() + " " + meta.getSqlType() + " " + meta.isNullable()); } } } catch (SQLException ex) { if (logger.isWarnEnabled()) { - logger.warn("Error while retrieving metadata for table columns: " + ex.getMessage()); + logger.warn("Error while retrieving meta-data for table columns: " + ex.getMessage()); } } finally { @@ -432,7 +432,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { /** - * Inner class representing table meta data. + * Inner class representing table meta-data. */ private static class TableMetaData { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/OracleTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/OracleTableMetaDataProvider.java index 96ecffe2ef4..4918424b3f4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/OracleTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/OracleTableMetaDataProvider.java @@ -29,7 +29,7 @@ import org.springframework.util.ReflectionUtils; /** * Oracle-specific implementation of the {@link org.springframework.jdbc.core.metadata.TableMetaDataProvider}. - * Supports a feature for including synonyms in the metadata lookup. Also supports lookup of current schema + * Supports a feature for including synonyms in the meta-data lookup. Also supports lookup of current schema * using the {@code sys_context}. * *

Thanks to Mike Youngstrom and Bruce Campbell for submitting the original suggestion for the Oracle @@ -47,16 +47,16 @@ public class OracleTableMetaDataProvider extends GenericTableMetaDataProvider { /** - * Constructor used to initialize with provided database metadata. - * @param databaseMetaData metadata to be used + * Constructor used to initialize with provided database meta-data. + * @param databaseMetaData meta-data to be used */ public OracleTableMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException { this(databaseMetaData, false); } /** - * Constructor used to initialize with provided database metadata. - * @param databaseMetaData metadata to be used + * Constructor used to initialize with provided database meta-data. + * @param databaseMetaData meta-data to be used * @param includeSynonyms whether to include synonyms */ public OracleTableMetaDataProvider(DatabaseMetaData databaseMetaData, boolean includeSynonyms) @@ -111,14 +111,14 @@ public class OracleTableMetaDataProvider extends GenericTableMetaDataProvider { String catalogName, String schemaName, String tableName) throws SQLException { if (!this.includeSynonyms) { - logger.debug("Defaulting to no synonyms in table metadata lookup"); + logger.debug("Defaulting to no synonyms in table meta-data lookup"); super.initializeWithTableColumnMetaData(databaseMetaData, catalogName, schemaName, tableName); return; } Connection con = databaseMetaData.getConnection(); if (con == null) { - logger.warn("Unable to include synonyms in table metadata lookup - no Connection from DatabaseMetaData"); + logger.warn("Unable to include synonyms in table meta-data lookup - no Connection from DatabaseMetaData"); super.initializeWithTableColumnMetaData(databaseMetaData, catalogName, schemaName, tableName); return; } @@ -148,13 +148,13 @@ public class OracleTableMetaDataProvider extends GenericTableMetaDataProvider { if (!isOracleCon) { if (logger.isWarnEnabled()) { - logger.warn("Unable to include synonyms in table metadata lookup - no Oracle Connection: " + con); + logger.warn("Unable to include synonyms in table meta-data lookup - no Oracle Connection: " + con); } super.initializeWithTableColumnMetaData(databaseMetaData, catalogName, schemaName, tableName); return; } - logger.debug("Including synonyms in table metadata lookup"); + logger.debug("Including synonyms in table meta-data lookup"); Method setIncludeSynonyms; Boolean originalValueForIncludeSynonyms; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProvider.java index 900eb63fe34..20173e2c4bd 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProvider.java @@ -23,7 +23,7 @@ import java.util.List; import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor; /** - * Interface specifying the API to be implemented by a class providing table metadata. + * Interface specifying the API to be implemented by a class providing table meta-data. * This is intended for internal use by the Simple JDBC classes. * * @author Thomas Risberg @@ -32,61 +32,63 @@ import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor; public interface TableMetaDataProvider { /** - * Initialize using the database metadata provided. + * Initialize using the database meta-data provided. * @param databaseMetaData used to retrieve database specific information * @throws SQLException in case of initialization failure */ void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException; /** - * Initialize using provided database metadata, table and column information. - * This initialization can be turned off by specifying that column meta data should not be used. + * Initialize using provided database meta-data, table and column information. + * This initialization can be turned off by specifying that column meta-data should not be used. * @param databaseMetaData used to retrieve database specific information * @param catalogName name of catalog to use (or {@code null} if none) * @param schemaName name of schema name to use (or {@code null} if none) * @param tableName name of the table * @throws SQLException in case of initialization failure */ - void initializeWithTableColumnMetaData( - DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName) - throws SQLException; + void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName, + String schemaName, String tableName) throws SQLException; /** - * Get the table name formatted based on metadata information. This could include altering the case. + * Get the table name formatted based on meta-data information. + * This could include altering the case. */ String tableNameToUse(String tableName); /** - * Get the catalog name formatted based on metadata information. This could include altering the case. + * Get the catalog name formatted based on meta-data information. + * This could include altering the case. */ String catalogNameToUse(String catalogName); /** - * Get the schema name formatted based on metadata information. This could include altering the case. + * Get the schema name formatted based on meta-data information. + * This could include altering the case. */ String schemaNameToUse(String schemaName); /** - * Provide any modification of the catalog name passed in to match the meta data currently used. - * The returned value will be used for meta data lookups. This could include altering the case used or - * providing a base catalog if none is provided. + * Provide any modification of the catalog name passed in to match the meta-data currently used. + * The returned value will be used for meta-data lookups. + * This could include altering the case used or providing a base catalog if none is provided. */ String metaDataCatalogNameToUse(String catalogName) ; /** - * Provide any modification of the schema name passed in to match the meta data currently used. - * The returned value will be used for meta data lookups. This could include altering the case used or - * providing a base schema if none is provided. + * Provide any modification of the schema name passed in to match the meta-data currently used. + * The returned value will be used for meta-data lookups. + * This could include altering the case used or providing a base schema if none is provided. */ String metaDataSchemaNameToUse(String schemaName) ; /** - * Are we using the meta data for the table columns? + * Are we using the meta-data for the table columns? */ boolean isTableColumnMetaDataUsed(); /** - * Does this database support the JDBC 3.0 feature of retrieving generated keys + * Does this database support the JDBC 3.0 feature of retrieving generated keys: * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}? */ boolean isGetGeneratedKeysSupported(); @@ -99,18 +101,18 @@ public interface TableMetaDataProvider { boolean isGetGeneratedKeysSimulated(); /** - * Get the simple query to retrieve a generated key + * Get the simple query to retrieve a generated key. */ String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName); /** - * Does this database support a column name String array for retrieving generated keys - * {@link java.sql.Connection#createStruct(String, Object[])} + * Does this database support a column name String array for retrieving generated keys: + * {@link java.sql.Connection#createStruct(String, Object[])}? */ boolean isGeneratedKeysColumnNameArraySupported(); /** - * Get the table parameter metadata that is currently used. + * Get the table parameter meta-data that is currently used. * @return List of {@link TableParameterMetaData} */ List getTableParameterMetaData(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java index d916a83a058..7ab5d2d848b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataProviderFactory.java @@ -42,9 +42,9 @@ public class TableMetaDataProviderFactory { /** - * Create a {@link TableMetaDataProvider} based on the database metadata. - * @param dataSource used to retrieve metadata - * @param context the class that holds configuration and metadata + * Create a {@link TableMetaDataProvider} based on the database meta-data. + * @param dataSource used to retrieve meta-data + * @param context the class that holds configuration and meta-data * @return instance of the TableMetaDataProvider implementation to be used */ public static TableMetaDataProvider createMetaDataProvider(DataSource dataSource, TableMetaDataContext context) { @@ -68,8 +68,8 @@ public class TableMetaDataProviderFactory { String databaseProductName = JdbcUtils.commonDatabaseName(databaseMetaData.getDatabaseProductName()); boolean accessTableColumnMetaData = context.isAccessTableColumnMetaData(); - TableMetaDataProvider provider; + if ("Oracle".equals(databaseProductName)) { provider = new OracleTableMetaDataProvider( databaseMetaData, context.isOverrideIncludeSynonymsDefault()); @@ -103,7 +103,7 @@ public class TableMetaDataProviderFactory { }); } catch (MetaDataAccessException ex) { - throw new DataAccessResourceFailureException("Error retrieving database metadata", ex); + throw new DataAccessResourceFailureException("Error retrieving database meta-data", ex); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableParameterMetaData.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableParameterMetaData.java index f63f29f4704..7f6081dddf6 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableParameterMetaData.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableParameterMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -17,7 +17,7 @@ package org.springframework.jdbc.core.metadata; /** - * Holder of metadata for a specific parameter that is used for table processing. + * Holder of meta-data for a specific parameter that is used for table processing. * * @author Thomas Risberg * @since 2.5 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/package-info.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/package-info.java index 7ad1eaee190..32634d757b5 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/package-info.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/package-info.java @@ -1,4 +1,5 @@ /** - * Context metadata abstraction for the configuration and execution of a stored procedure call. + * Context metadata abstraction for the configuration and execution + * of table inserts and stored procedure calls. */ package org.springframework.jdbc.core.metadata; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java index e08be0acd66..e2d2d3da858 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -28,26 +28,25 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource; /** * A SimpleJdbcCall is a multi-threaded, reusable object representing a call - * to a stored procedure or a stored function. It provides meta data processing + * to a stored procedure or a stored function. It provides meta-data processing * to simplify the code needed to access basic stored procedures/functions. * All you need to provide is the name of the procedure/function and a Map * containing the parameters when you execute the call. The names of the * supplied parameters will be matched up with in and out parameters declared * when the stored procedure was created. * - *

The meta data processing is based on the DatabaseMetaData provided by + *

The meta-data processing is based on the DatabaseMetaData provided by * the JDBC driver. Since we rely on the JDBC driver, this "auto-detection" - * can only be used for databases that are known to provide accurate meta data. + * can only be used for databases that are known to provide accurate meta-data. * These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2, * Sybase and PostgreSQL. For any other databases you are required to declare * all parameters explicitly. You can of course declare all parameters - * explicitly even if the database provides the necessary meta data. In that + * explicitly even if the database provides the necessary meta-data. In that * case your declared parameters will take precedence. You can also turn off - * any metadata processing if you want to use parameter names that do not + * any meta-data processing if you want to use parameter names that do not * match what is declared during the stored procedure compilation. * - *

The actual insert is being handled using Spring's - * {@link org.springframework.jdbc.core.JdbcTemplate}. + *

The actual insert is being handled using Spring's {@link JdbcTemplate}. * *

Many of the configuration methods return the current instance of the * SimpleJdbcCall in order to provide the ability to chain multiple ones diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java index 6cb91185c72..4067c86e068 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.java @@ -71,7 +71,7 @@ public interface SimpleJdbcCallOperations { /** * Specify one or more parameters if desired. These parameters will be supplemented with - * any parameter information retrieved from the database meta data. + * any parameter information retrieved from the database meta-data. *

Note that only parameters declared as {@code SqlParameter} and {@code SqlInOutParameter} * will be used to provide input values. This is different from the {@code StoredProcedure} * class which - for backwards compatibility reasons - allows input values to be provided @@ -96,7 +96,7 @@ public interface SimpleJdbcCallOperations { SimpleJdbcCallOperations returningResultSet(String parameterName, RowMapper rowMapper); /** - * Turn off any processing of parameter meta data information obtained via JDBC. + * Turn off any processing of parameter meta-data information obtained via JDBC. * @return the instance of this SimpleJdbcCall */ SimpleJdbcCallOperations withoutProcedureColumnMetaDataAccess(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java index 417423507fc..d20d3b4b21d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.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. @@ -27,22 +27,23 @@ import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor; /** * A SimpleJdbcInsert is a multi-threaded, reusable object providing easy insert - * capabilities for a table. It provides meta data processing to simplify the code + * capabilities for a table. It provides meta-data processing to simplify the code * needed to construct a basic insert statement. All you need to provide is the * name of the table and a Map containing the column names and the column values. * - *

The meta data processing is based on the DatabaseMetaData provided by the + *

The meta-data processing is based on the DatabaseMetaData provided by the * JDBC driver. As long as the JDBC driver can provide the names of the columns * for a specified table than we can rely on this auto-detection feature. If that * is not the case, then the column names must be specified explicitly. * - *

The actual insert is being handled using Spring's - * {@link org.springframework.jdbc.core.JdbcTemplate}. + *

The actual insert is being handled using Spring's {@link JdbcTemplate}. * - *

Many of the configuration methods return the current instance of the SimpleJdbcInsert - * to provide the ability to chain multiple ones together in a "fluent" interface style. + *

Many of the configuration methods return the current instance of the + * SimpleJdbcInsert to provide the ability to chain multiple ones together + * in a "fluent" interface style. * * @author Thomas Risberg + * @author Juergen Hoeller * @since 2.5 * @see java.sql.DatabaseMetaData * @see org.springframework.jdbc.core.JdbcTemplate diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java index 55bf65994cb..e219da517cf 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java @@ -68,13 +68,13 @@ public interface SimpleJdbcInsertOperations { SimpleJdbcInsertOperations usingGeneratedKeyColumns(String... columnNames); /** - * Turn off any processing of column meta data information obtained via JDBC. + * Turn off any processing of column meta-data information obtained via JDBC. * @return the instance of this SimpleJdbcInsert */ SimpleJdbcInsertOperations withoutTableColumnMetaDataAccess(); /** - * Include synonyms for the column meta data lookups via JDBC. + * Include synonyms for the column meta-data lookups via JDBC. *

Note: This is only necessary to include for Oracle since other databases * supporting synonyms seems to include the synonyms automatically. * @return the instance of this SimpleJdbcInsert diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/package-info.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/package-info.java index d9403a2c9b4..af57f1d56ba 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/package-info.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/package-info.java @@ -1,8 +1,8 @@ /** - * Simplification layer over JdbcTemplate for Java 5 and above. + * Simplification layer for table inserts and stored procedure calls. * - *

{@code SimpleJdbcInsert} and {@code SimpleJdbcCall} are classes that takes advantage - * of database metadata provided by the JDBC driver to simplify the application code. Much of the - * parameter specification becomes unnecessary since it can be looked up in the metadata. + *

{@code SimpleJdbcInsert} and {@code SimpleJdbcCall} take advantage of database + * meta-data provided by the JDBC driver to simplify the application code. Much of the + * parameter specification becomes unnecessary since it can be looked up in the meta-data. */ package org.springframework.jdbc.core.simple; 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 423bc3f36a2..246077a5a62 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -178,6 +178,7 @@ public abstract class ScriptUtils { boolean inSingleQuote = false; boolean inDoubleQuote = false; boolean inEscape = false; + for (int i = 0; i < script.length(); i++) { char c = script.charAt(i); if (inEscape) { @@ -243,6 +244,7 @@ public abstract class ScriptUtils { } sb.append(c); } + if (StringUtils.hasText(sb)) { statements.add(sb.toString()); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseMetaDataCallback.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseMetaDataCallback.java index abb9d7e33b3..883bca7c262 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseMetaDataCallback.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseMetaDataCallback.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. @@ -21,7 +21,7 @@ import java.sql.SQLException; /** * A callback interface used by the JdbcUtils class. Implementations of this - * interface perform the actual work of extracting database meta data, but + * interface perform the actual work of extracting database meta-data, but * don't need to worry about exception handling. SQLExceptions will be caught * and handled correctly by the JdbcUtils class. * @@ -31,15 +31,15 @@ import java.sql.SQLException; public interface DatabaseMetaDataCallback { /** - * Implementations must implement this method to process the meta data + * Implementations must implement this method to process the meta-data * passed in. Exactly what the implementation chooses to do is up to it. * @param dbmd the DatabaseMetaData to process - * @return a result object extracted from the meta data + * @return a result object extracted from the meta-data * (can be an arbitrary object, as needed by the implementation) * @throws SQLException if a SQLException is encountered getting * column values (that is, there's no need to catch SQLException) * @throws MetaDataAccessException in case of other failures while - * extracting meta data (for example, reflection failure) + * extracting meta-data (for example, reflection failure) */ Object processMetaData(DatabaseMetaData dbmd) throws SQLException, MetaDataAccessException; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcAccessor.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcAccessor.java index f43a4478161..bcd17286953 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcAccessor.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcAccessor.java @@ -64,7 +64,7 @@ public abstract class JdbcAccessor implements InitializingBean { /** * Specify the database product name for the DataSource that this accessor uses. * This allows to initialize a SQLErrorCodeSQLExceptionTranslator without - * obtaining a Connection from the DataSource to get the metadata. + * obtaining a Connection from the DataSource to get the meta-data. * @param dbName the database product name that identifies the error codes entry * @see SQLErrorCodeSQLExceptionTranslator#setDatabaseProductName * @see java.sql.DatabaseMetaData#getDatabaseProductName() diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java index 2cd2c450450..501122df756 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java @@ -303,19 +303,19 @@ public abstract class JdbcUtils { } /** - * Extract database meta data via the given DatabaseMetaDataCallback. - *

This method will open a connection to the database and retrieve the database metadata. + * Extract database meta-data via the given DatabaseMetaDataCallback. + *

This method will open a connection to the database and retrieve the database meta-data. * Since this method is called before the exception translation feature is configured for * a datasource, this method can not rely on the SQLException translation functionality. *

Any exceptions will be wrapped in a MetaDataAccessException. This is a checked exception * and any calling code should catch and handle this exception. You can just log the * error and hope for the best, but there is probably a more serious error that will * reappear when you try to access the database again. - * @param dataSource the DataSource to extract metadata for + * @param dataSource the DataSource to extract meta-data for * @param action callback that will do the actual work * @return object containing the extracted information, as returned by * the DatabaseMetaDataCallback's {@code processMetaData} method - * @throws MetaDataAccessException if meta data access failed + * @throws MetaDataAccessException if meta-data access failed */ public static Object extractDatabaseMetaData(DataSource dataSource, DatabaseMetaDataCallback action) throws MetaDataAccessException { @@ -352,7 +352,7 @@ public abstract class JdbcUtils { /** * Call the specified method on DatabaseMetaData for the given DataSource, * and extract the invocation result. - * @param dataSource the DataSource to extract meta data for + * @param dataSource the DataSource to extract meta-data for * @param metaDataMethodName the name of the DatabaseMetaData method to call * @return the object returned by the specified DatabaseMetaData method * @throws MetaDataAccessException if we couldn't access the DatabaseMetaData @@ -421,7 +421,7 @@ public abstract class JdbcUtils { /** * Extract a common name for the target database in use even if * various drivers/platforms provide varying names at runtime. - * @param source the name as provided in database metadata + * @param source the name as provided in database meta-data * @return the common name to be used (e.g. "DB2" or "Sybase") */ public static String commonDatabaseName(String source) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/MetaDataAccessException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/MetaDataAccessException.java index 45d9d57f1c7..9923a7580f3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/MetaDataAccessException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/MetaDataAccessException.java @@ -19,11 +19,11 @@ package org.springframework.jdbc.support; import org.springframework.core.NestedCheckedException; /** - * Exception indicating that something went wrong during JDBC metadata lookup. + * Exception indicating that something went wrong during JDBC meta-data lookup. * *

This is a checked exception since we want it to be caught, logged and * handled rather than cause the application to fail. Failure to read JDBC - * metadata is usually not a fatal problem. + * meta-data is usually not a fatal problem. * * @author Thomas Risberg * @since 1.0.1 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java index d9afb8837fe..a71156badb1 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -44,7 +44,7 @@ import org.springframework.jdbc.InvalidResultSetAccessException; * concrete and is typically used itself, in which case this rule doesn't apply. *

  • Apply error code matching. Error codes are obtained from the SQLErrorCodesFactory * by default. This factory loads a "sql-error-codes.xml" file from the class path, - * defining error code mappings for database names from database metadata. + * defining error code mappings for database names from database meta-data. *
  • Fallback to a fallback translator. {@link SQLStateSQLExceptionTranslator} is the * default fallback translator, analyzing the exception's SQL state only. On Java 6 * which introduces its own {@code SQLException} subclass hierarchy, we will @@ -87,8 +87,8 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep /** * Create a SQL error code translator for the given DataSource. * Invoking this constructor will cause a Connection to be obtained - * from the DataSource to get the metadata. - * @param dataSource DataSource to use to find metadata and establish + * from the DataSource to get the meta-data. + * @param dataSource DataSource to use to find meta-data and establish * which error codes are usable * @see SQLErrorCodesFactory */ @@ -100,7 +100,7 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep /** * Create a SQL error code translator for the given database product name. * Invoking this constructor will avoid obtaining a Connection from the - * DataSource to get the metadata. + * DataSource to get the meta-data. * @param dbName the database product name that identifies the error codes entry * @see SQLErrorCodesFactory * @see java.sql.DatabaseMetaData#getDatabaseProductName() @@ -112,7 +112,7 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep /** * Create a SQLErrorCode translator given these error codes. - * Does not require a database metadata lookup to be performed using a connection. + * Does not require a database meta-data lookup to be performed using a connection. * @param sec error codes */ public SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec) { @@ -124,8 +124,8 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep /** * Set the DataSource for this translator. *

    Setting this property will cause a Connection to be obtained from - * the DataSource to get the metadata. - * @param dataSource DataSource to use to find metadata and establish + * the DataSource to get the meta-data. + * @param dataSource DataSource to use to find meta-data and establish * which error codes are usable * @see SQLErrorCodesFactory#getErrorCodes(javax.sql.DataSource) * @see java.sql.DatabaseMetaData#getDatabaseProductName() @@ -137,7 +137,7 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep /** * Set the database product name for this translator. *

    Setting this property will avoid obtaining a Connection from the DataSource - * to get the metadata. + * to get the meta-data. * @param dbName the database product name that identifies the error codes entry * @see SQLErrorCodesFactory#getErrorCodes(String) * @see java.sql.DatabaseMetaData#getDatabaseProductName() diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java index 3d6569a5fb4..2301700f9cb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java @@ -153,7 +153,7 @@ public class SQLErrorCodesFactory { /** * Return the {@link SQLErrorCodes} instance for the given database. - *

    No need for a database metadata lookup. + *

    No need for a database meta-data lookup. * @param databaseName the database name (must not be {@code null}) * @return the {@code SQLErrorCodes} instance for the given database * @throws IllegalArgumentException if the supplied database name is {@code null} diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java index ac434886b59..83226f9f540 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/SqlRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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. @@ -27,18 +27,17 @@ import java.util.Map; import org.springframework.jdbc.InvalidResultSetAccessException; /** - * Mirror interface for {@link javax.sql.RowSet}, representing - * disconnected {@link java.sql.ResultSet} data. + * Mirror interface for {@link javax.sql.RowSet}, representing a disconnected variant of + * {@link java.sql.ResultSet} data. * - *

    The main difference to the standard JDBC RowSet is that a - * {@link java.sql.SQLException} is never thrown here. This allows a - * SqlRowSet to be used without having to deal with checked exceptions. - * A SqlRowSet will throw Spring's {@link InvalidResultSetAccessException} + *

    The main difference to the standard JDBC RowSet is that a {@link java.sql.SQLException} + * is never thrown here. This allows a SqlRowSet to be used without having to deal with + * checked exceptions. A SqlRowSet will throw Spring's {@link InvalidResultSetAccessException} * instead (when appropriate). * - *

    Note: This interface extends the {@code java.io.Serializable} marker - * interface. Implementations, which typically hold disconnected data, - * are encouraged to be actually serializable (as far as possible). + *

    Note: This interface extends the {@code java.io.Serializable} marker interface. + * Implementations, which typically hold disconnected data, are encouraged to be actually + * serializable (as far as possible). * * @author Thomas Risberg * @author Juergen Hoeller @@ -51,7 +50,7 @@ import org.springframework.jdbc.InvalidResultSetAccessException; public interface SqlRowSet extends Serializable { /** - * Retrieve the meta data, i.e. number, types and properties + * Retrieve the meta-data, i.e. number, types and properties * for the columns of this row set. * @return a corresponding SqlRowSetMetaData instance * @see java.sql.ResultSet#getMetaData() @@ -70,8 +69,7 @@ public interface SqlRowSet extends Serializable { // RowSet methods for extracting data values /** - * Retrieve the value of the indicated column in the current row - * as a BigDecimal object. + * Retrieve the value of the indicated column in the current row as a BigDecimal object. * @param columnIndex the column index * @return an BigDecimal object representing the column value * @see java.sql.ResultSet#getBigDecimal(int) @@ -79,8 +77,7 @@ public interface SqlRowSet extends Serializable { BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a BigDecimal object. + * Retrieve the value of the indicated column in the current row as a BigDecimal object. * @param columnLabel the column label * @return an BigDecimal object representing the column value * @see java.sql.ResultSet#getBigDecimal(String) @@ -88,8 +85,7 @@ public interface SqlRowSet extends Serializable { BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a boolean. + * Retrieve the value of the indicated column in the current row as a boolean. * @param columnIndex the column index * @return a boolean representing the column value * @see java.sql.ResultSet#getBoolean(int) @@ -97,8 +93,7 @@ public interface SqlRowSet extends Serializable { boolean getBoolean(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a boolean. + * Retrieve the value of the indicated column in the current row as a boolean. * @param columnLabel the column label * @return a boolean representing the column value * @see java.sql.ResultSet#getBoolean(String) @@ -106,8 +101,7 @@ public interface SqlRowSet extends Serializable { boolean getBoolean(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a byte. + * Retrieve the value of the indicated column in the current row as a byte. * @param columnIndex the column index * @return a byte representing the column value * @see java.sql.ResultSet#getByte(int) @@ -115,8 +109,7 @@ public interface SqlRowSet extends Serializable { byte getByte(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a byte. + * Retrieve the value of the indicated column in the current row as a byte. * @param columnLabel the column label * @return a byte representing the column value * @see java.sql.ResultSet#getByte(String) @@ -124,8 +117,7 @@ public interface SqlRowSet extends Serializable { byte getByte(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Date object. + * Retrieve the value of the indicated column in the current row as a Date object. * @param columnIndex the column index * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(int) @@ -133,8 +125,7 @@ public interface SqlRowSet extends Serializable { Date getDate(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Date object. + * Retrieve the value of the indicated column in the current row as a Date object. * @param columnLabel the column label * @return a Date object representing the column value * @see java.sql.ResultSet#getDate(String) @@ -142,8 +133,7 @@ public interface SqlRowSet extends Serializable { Date getDate(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Date object. + * Retrieve the value of the indicated column in the current row as a Date object. * @param columnIndex the column index * @param cal the Calendar to use in constructing the Date * @return a Date object representing the column value @@ -152,8 +142,7 @@ public interface SqlRowSet extends Serializable { Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Date object. + * Retrieve the value of the indicated column in the current row as a Date object. * @param columnLabel the column label * @param cal the Calendar to use in constructing the Date * @return a Date object representing the column value @@ -162,8 +151,7 @@ public interface SqlRowSet extends Serializable { Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Double object. + * Retrieve the value of the indicated column in the current row as a Double object. * @param columnIndex the column index * @return a Double object representing the column value * @see java.sql.ResultSet#getDouble(int) @@ -171,8 +159,7 @@ public interface SqlRowSet extends Serializable { double getDouble(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Double object. + * Retrieve the value of the indicated column in the current row as a Double object. * @param columnLabel the column label * @return a Double object representing the column value * @see java.sql.ResultSet#getDouble(String) @@ -180,8 +167,7 @@ public interface SqlRowSet extends Serializable { double getDouble(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a float. + * Retrieve the value of the indicated column in the current row as a float. * @param columnIndex the column index * @return a float representing the column value * @see java.sql.ResultSet#getFloat(int) @@ -189,8 +175,7 @@ public interface SqlRowSet extends Serializable { float getFloat(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a float. + * Retrieve the value of the indicated column in the current row as a float. * @param columnLabel the column label * @return a float representing the column value * @see java.sql.ResultSet#getFloat(String) @@ -198,8 +183,7 @@ public interface SqlRowSet extends Serializable { float getFloat(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an int. + * Retrieve the value of the indicated column in the current row as an int. * @param columnIndex the column index * @return an int representing the column value * @see java.sql.ResultSet#getInt(int) @@ -207,8 +191,7 @@ public interface SqlRowSet extends Serializable { int getInt(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an int. + * Retrieve the value of the indicated column in the current row as an int. * @param columnLabel the column label * @return an int representing the column value * @see java.sql.ResultSet#getInt(String) @@ -216,8 +199,7 @@ public interface SqlRowSet extends Serializable { int getInt(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a long. + * Retrieve the value of the indicated column in the current row as a long. * @param columnIndex the column index * @return a long representing the column value * @see java.sql.ResultSet#getLong(int) @@ -225,8 +207,7 @@ public interface SqlRowSet extends Serializable { long getLong(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a long. + * Retrieve the value of the indicated column in the current row as a long. * @param columnLabel the column label * @return a long representing the column value * @see java.sql.ResultSet#getLong(String) @@ -234,8 +215,8 @@ public interface SqlRowSet extends Serializable { long getLong(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns). + * Retrieve the value of the indicated column in the current row as a String + * (for NCHAR, NVARCHAR, LONGNVARCHAR columns). * @param columnIndex the column index * @return a String representing the column value * @see java.sql.ResultSet#getNString(int) @@ -244,8 +225,8 @@ public interface SqlRowSet extends Serializable { String getNString(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns). + * Retrieve the value of the indicated column in the current row as a String + * (for NCHAR, NVARCHAR, LONGNVARCHAR columns). * @param columnLabel the column label * @return a String representing the column value * @see java.sql.ResultSet#getNString(String) @@ -254,8 +235,7 @@ public interface SqlRowSet extends Serializable { String getNString(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnIndex the column index * @return a Object representing the column value * @see java.sql.ResultSet#getObject(int) @@ -263,8 +243,7 @@ public interface SqlRowSet extends Serializable { Object getObject(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnLabel the column label * @return a Object representing the column value * @see java.sql.ResultSet#getObject(String) @@ -272,8 +251,7 @@ public interface SqlRowSet extends Serializable { Object getObject(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnIndex the column index * @param map a Map object containing the mapping from SQL types to Java types * @return a Object representing the column value @@ -282,8 +260,7 @@ public interface SqlRowSet extends Serializable { Object getObject(int columnIndex, Map> map) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnLabel the column label * @param map a Map object containing the mapping from SQL types to Java types * @return a Object representing the column value @@ -292,8 +269,7 @@ public interface SqlRowSet extends Serializable { Object getObject(String columnLabel, Map> map) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnIndex the column index * @param type the Java type to convert the designated column to * @return a Object representing the column value @@ -303,8 +279,7 @@ public interface SqlRowSet extends Serializable { T getObject(int columnIndex, Class type) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as an Object. + * Retrieve the value of the indicated column in the current row as an Object. * @param columnLabel the column label * @param type the Java type to convert the designated column to * @return a Object representing the column value @@ -314,8 +289,7 @@ public interface SqlRowSet extends Serializable { T getObject(String columnLabel, Class type) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a short. + * Retrieve the value of the indicated column in the current row as a short. * @param columnIndex the column index * @return a short representing the column value * @see java.sql.ResultSet#getShort(int) @@ -323,8 +297,7 @@ public interface SqlRowSet extends Serializable { short getShort(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a short. + * Retrieve the value of the indicated column in the current row as a short. * @param columnLabel the column label * @return a short representing the column value * @see java.sql.ResultSet#getShort(String) @@ -332,8 +305,7 @@ public interface SqlRowSet extends Serializable { short getShort(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a String. + * Retrieve the value of the indicated column in the current row as a String. * @param columnIndex the column index * @return a String representing the column value * @see java.sql.ResultSet#getString(int) @@ -341,8 +313,7 @@ public interface SqlRowSet extends Serializable { String getString(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a String. + * Retrieve the value of the indicated column in the current row as a String. * @param columnLabel the column label * @return a String representing the column value * @see java.sql.ResultSet#getString(String) @@ -350,8 +321,7 @@ public interface SqlRowSet extends Serializable { String getString(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Time object. + * Retrieve the value of the indicated column in the current row as a Time object. * @param columnIndex the column index * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(int) @@ -359,8 +329,7 @@ public interface SqlRowSet extends Serializable { Time getTime(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Time object. + * Retrieve the value of the indicated column in the current row as a Time object. * @param columnLabel the column label * @return a Time object representing the column value * @see java.sql.ResultSet#getTime(String) @@ -368,8 +337,7 @@ public interface SqlRowSet extends Serializable { Time getTime(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Time object. + * Retrieve the value of the indicated column in the current row as a Time object. * @param columnIndex the column index * @param cal the Calendar to use in constructing the Date * @return a Time object representing the column value @@ -378,8 +346,7 @@ public interface SqlRowSet extends Serializable { Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Time object. + * Retrieve the value of the indicated column in the current row as a Time object. * @param columnLabel the column label * @param cal the Calendar to use in constructing the Date * @return a Time object representing the column value @@ -388,8 +355,7 @@ public interface SqlRowSet extends Serializable { Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Timestamp object. + * Retrieve the value of the indicated column in the current row as a Timestamp object. * @param columnIndex the column index * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(int) @@ -397,8 +363,7 @@ public interface SqlRowSet extends Serializable { Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Timestamp object. + * Retrieve the value of the indicated column in the current row as a Timestamp object. * @param columnLabel the column label * @return a Timestamp object representing the column value * @see java.sql.ResultSet#getTimestamp(String) @@ -406,8 +371,7 @@ public interface SqlRowSet extends Serializable { Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Timestamp object. + * Retrieve the value of the indicated column in the current row as a Timestamp object. * @param columnIndex the column index * @param cal the Calendar to use in constructing the Date * @return a Timestamp object representing the column value @@ -416,8 +380,7 @@ public interface SqlRowSet extends Serializable { Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException; /** - * Retrieve the value of the indicated column in the current row - * as a Timestamp object. + * Retrieve the value of the indicated column in the current row as a Timestamp object. * @param columnLabel the column label * @param cal the Calendar to use in constructing the Date * @return a Timestamp object representing the column value @@ -429,11 +392,9 @@ public interface SqlRowSet extends Serializable { // RowSet navigation methods /** - * Move the cursor to the given row number in the row set, - * just after the last row. + * Move the cursor to the given row number in the row set, just after the last row. * @param row the number of the row where the cursor should move - * @return {@code true} if the cursor is on the row set, - * {@code false} otherwise + * @return {@code true} if the cursor is on the row set, {@code false} otherwise * @see java.sql.ResultSet#absolute(int) */ boolean absolute(int row) throws InvalidResultSetAccessException; @@ -445,16 +406,14 @@ public interface SqlRowSet extends Serializable { void afterLast() throws InvalidResultSetAccessException; /** - * Move the cursor to the front of this row set, - * just before the first row. + * Move the cursor to the front of this row set, just before the first row. * @see java.sql.ResultSet#beforeFirst() */ void beforeFirst() throws InvalidResultSetAccessException; /** * Move the cursor to the first row of this row set. - * @return {@code true} if the cursor is on a valid row, - * {@code false} otherwise + * @return {@code true} if the cursor is on a valid row, {@code false} otherwise * @see java.sql.ResultSet#first() */ boolean first() throws InvalidResultSetAccessException; @@ -468,74 +427,65 @@ public interface SqlRowSet extends Serializable { /** * Retrieve whether the cursor is after the last row of this row set. - * @return {@code true} if the cursor is after the last row, - * {@code false} otherwise + * @return {@code true} if the cursor is after the last row, {@code false} otherwise * @see java.sql.ResultSet#isAfterLast() */ boolean isAfterLast() throws InvalidResultSetAccessException; /** * Retrieve whether the cursor is before the first row of this row set. - * @return {@code true} if the cursor is before the first row, - * {@code false} otherwise + * @return {@code true} if the cursor is before the first row, {@code false} otherwise * @see java.sql.ResultSet#isBeforeFirst() */ boolean isBeforeFirst() throws InvalidResultSetAccessException; /** * Retrieve whether the cursor is on the first row of this row set. - * @return {@code true} if the cursor is after the first row, - * {@code false} otherwise + * @return {@code true} if the cursor is after the first row, {@code false} otherwise * @see java.sql.ResultSet#isFirst() */ boolean isFirst() throws InvalidResultSetAccessException; /** * Retrieve whether the cursor is on the last row of this row set. - * @return {@code true} if the cursor is after the last row, - * {@code false} otherwise + * @return {@code true} if the cursor is after the last row, {@code false} otherwise * @see java.sql.ResultSet#isLast() */ boolean isLast() throws InvalidResultSetAccessException; /** * Move the cursor to the last row of this row set. - * @return {@code true} if the cursor is on a valid row, - * {@code false} otherwise + * @return {@code true} if the cursor is on a valid row, {@code false} otherwise * @see java.sql.ResultSet#last() */ boolean last() throws InvalidResultSetAccessException; /** * Move the cursor to the next row. - * @return {@code true} if the new row is valid, - * {@code false} if there are no more rows + * @return {@code true} if the new row is valid, {@code false} if there are no more rows * @see java.sql.ResultSet#next() */ boolean next() throws InvalidResultSetAccessException; /** * Move the cursor to the previous row. - * @return {@code true} if the new row is valid, - * {@code false} if it is off the row set + * @return {@code true} if the new row is valid, {@code false} if it is off the row set * @see java.sql.ResultSet#previous() */ boolean previous() throws InvalidResultSetAccessException; /** - * Move the cursor a relative number of rows, - * either positive or negative. - * @return {@code true} if the cursor is on a row, - * {@code false} otherwise + * Move the cursor a relative number of rows, either positive or negative. + * @return {@code true} if the cursor is on a row, {@code false} otherwise * @see java.sql.ResultSet#relative(int) */ boolean relative(int rows) throws InvalidResultSetAccessException; /** * Report whether the last column read had a value of SQL {@code NULL}. - *

    Note that you must first call one of the getter methods - * and then call the {@code wasNull()} method. - * @return {@code true} if the most recent coumn retrieved was + *

    Note that you must first call one of the getter methods and then + * call the {@code wasNull()} method. + * @return {@code true} if the most recent column retrieved was * SQL {@code NULL}, {@code false} otherwise * @see java.sql.ResultSet#wasNull() */ diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java index b64ae749d10..b6017c04bae 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -147,11 +147,12 @@ public class SimpleMessageConverter implements MessageConverter { protected MapMessage createMessageForMap(Map map, Session session) throws JMSException { MapMessage message = session.createMapMessage(); for (Map.Entry entry : map.entrySet()) { - if (!(entry.getKey() instanceof String)) { + Object key = entry.getKey(); + if (!(key instanceof String)) { throw new MessageConversionException("Cannot convert non-String key of type [" + - ObjectUtils.nullSafeClassName(entry.getKey()) + "] to JMS MapMessage entry"); + ObjectUtils.nullSafeClassName(key) + "] to JMS MapMessage entry"); } - message.setObject((String) entry.getKey(), entry.getValue()); + message.setObject((String) key, entry.getValue()); } return message; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SubscriptionRegistry.java index ac9dc15e543..c16b914026e 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SubscriptionRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -45,11 +45,11 @@ public interface SubscriptionRegistry { void unregisterAllSubscriptions(String sessionId); /** - * Find all subscriptions that should receive the given message. The map - * returned is safe to iterate and will never be modified. + * Find all subscriptions that should receive the given message. + * The map returned is safe to iterate and will never be modified. * @param message the message - * @return a {@code MultiValueMap} with sessionId-subscriptionId pairs, - * possibly empty. + * @return a {@code MultiValueMap} with sessionId-subscriptionId pairs + * (possibly empty) */ MultiValueMap findSubscriptions(Message message); diff --git a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java index a101b25a670..e5bf3b5f6cc 100644 --- a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java @@ -241,8 +241,7 @@ public class JsonPathExpectationsHelper { return this.jsonPath.read(content); } catch (Throwable ex) { - String message = "No value at JSON path \"" + this.expression + "\""; - throw new AssertionError(message, ex); + throw new AssertionError("No value at JSON path \"" + this.expression + "\": " + ex); } } @@ -251,8 +250,7 @@ public class JsonPathExpectationsHelper { return JsonPath.parse(content).read(this.expression, targetType); } catch (Throwable ex) { - String message = "No value at JSON path \"" + this.expression + "\""; - throw new AssertionError(message, ex); + throw new AssertionError("No value at JSON path \"" + this.expression + "\": " + ex); } } diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index 3c875529d2a..a51917b964f 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import javax.servlet.ServletContext; @@ -139,7 +138,7 @@ public class ContentNegotiationManagerFactoryBean */ public void setMediaTypes(Properties mediaTypes) { if (!CollectionUtils.isEmpty(mediaTypes)) { - for (Entry entry : mediaTypes.entrySet()) { + for (Map.Entry entry : mediaTypes.entrySet()) { String extension = ((String)entry.getKey()).toLowerCase(Locale.ENGLISH); MediaType mediaType = MediaType.valueOf((String) entry.getValue()); this.mediaTypes.put(extension, mediaType); diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index 9c518c4eb43..397933b72ef 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -22,7 +22,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -56,7 +55,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten */ public MappingMediaTypeFileExtensionResolver(Map mediaTypes) { if (mediaTypes != null) { - for (Entry entries : mediaTypes.entrySet()) { + for (Map.Entry entries : mediaTypes.entrySet()) { String extension = entries.getKey().toLowerCase(Locale.ENGLISH); MediaType mediaType = entries.getValue(); this.mediaTypes.put(extension, mediaType); diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 560b3ff32e0..02d83653f3d 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -155,10 +155,8 @@ final class HierarchicalUriComponents extends UriComponents { queryBuilder.append('&'); } queryBuilder.append(name); - if (value != null) { - queryBuilder.append('='); - queryBuilder.append(value.toString()); + queryBuilder.append('=').append(value.toString()); } } } diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index 60fe9b7c210..e5d87d5153a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -20,7 +20,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import javax.servlet.http.HttpServletRequest; @@ -535,7 +534,7 @@ public class UrlPathHelper { } else { Map decodedVars = new LinkedHashMap(vars.size()); - for (Entry entry : vars.entrySet()) { + for (Map.Entry entry : vars.entrySet()) { decodedVars.put(entry.getKey(), decodeInternal(request, entry.getValue())); } return decodedVars; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java index fd1994d7d2b..57be99d174a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -448,7 +447,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce } } - for (Entry entry : this.exceptionHandlerAdviceCache.entrySet()) { + for (Map.Entry entry : this.exceptionHandlerAdviceCache.entrySet()) { ControllerAdviceBean advice = entry.getKey(); if (advice.isApplicableToBeanType(handlerType)) { ExceptionHandlerMethodResolver resolver = entry.getValue(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/WebSocketToJettyExtensionConfigAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/WebSocketToJettyExtensionConfigAdapter.java index 45fab4637b8..ee229f5027a 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/WebSocketToJettyExtensionConfigAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/WebSocketToJettyExtensionConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 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. @@ -30,8 +30,9 @@ public class WebSocketToJettyExtensionConfigAdapter extends ExtensionConfig { public WebSocketToJettyExtensionConfigAdapter(WebSocketExtension extension) { super(extension.getName()); - for (Map.Entry p : extension.getParameters().entrySet()) { - super.setParameter(p.getKey(), p.getValue()); + for (Map.Entry parameter : extension.getParameters().entrySet()) { + super.setParameter(parameter.getKey(), parameter.getValue()); } } + }