diff --git a/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java index 80f9dcfb2fc..757c4c2859b 100644 --- a/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.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. @@ -41,6 +41,7 @@ public class DefaultParameterNameDiscoverer extends PrioritizedParameterNameDisc private static final boolean kotlinPresent = ClassUtils.isPresent("kotlin.Unit", DefaultParameterNameDiscoverer.class.getClassLoader()); + public DefaultParameterNameDiscoverer() { if (kotlinPresent) { addDiscoverer(new KotlinReflectionParameterNameDiscoverer()); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java index 95e8909bc0b..4e543368e7f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.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. @@ -25,9 +25,9 @@ import org.springframework.transaction.support.ResourceHolderSupport; import org.springframework.util.Assert; /** - * Connection holder, wrapping a JDBC Connection. + * Resource holder wrapping a JDBC {@link Connection}. * {@link DataSourceTransactionManager} binds instances of this class - * to the thread, for a specific DataSource. + * to the thread, for a specific {@link javax.sql.DataSource}. * *
Inherits rollback-only support for nested JDBC transactions * and reference count functionality from the base class. @@ -41,6 +41,9 @@ import org.springframework.util.Assert; */ public class ConnectionHolder extends ResourceHolderSupport { + /** + * Prefix for savepoint names. + */ public static final String SAVEPOINT_NAME_PREFIX = "SAVEPOINT_"; diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java b/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java index 5a09a0db851..5388a6afa07 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java @@ -38,9 +38,9 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; /** - * JMS resource holder, wrapping a JMS Connection and a JMS Session. - * JmsTransactionManager binds instances of this class to the thread, - * for a given JMS ConnectionFactory. + * Resource holder wrapping a JMS {@link Connection} and a JMS {@link Session}. + * {@link JmsTransactionManager} binds instances of this class to the thread, + * for a given JMS {@link ConnectionFactory}. * *
Note: This is an SPI class, not intended to be used by applications. * diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/LocallyExposedJmsResourceHolder.java b/spring-jms/src/main/java/org/springframework/jms/listener/LocallyExposedJmsResourceHolder.java index 118f179a8eb..18eb04cf7aa 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/LocallyExposedJmsResourceHolder.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/LocallyExposedJmsResourceHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 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,7 @@ import javax.jms.Session; import org.springframework.jms.connection.JmsResourceHolder; /** - * JmsResourceHolder marker subclass that indicates local exposure, + * {@link JmsResourceHolder} marker subclass that indicates local exposure, * i.e. that does not indicate an externally managed transaction. * * @author Juergen Hoeller diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java index 6cc98621022..975eec6925e 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java @@ -69,7 +69,7 @@ import org.springframework.util.ReflectionUtils; * *
NOTE: Hibernate access code can also be coded against the native Hibernate * {@link Session}. Hence, for newly started projects, consider adopting the standard - * Hibernate style of coding against {@link SessionFactory#getCurrentSession()}. + * Hibernate style of coding against {@link SessionFactory#getCurrentSession()}. * Alternatively, use {@link #execute(HibernateCallback)} with Java 8 lambda code blocks * against the callback-provided {@code Session} which results in elegant code as well, * decoupled from the Hibernate Session lifecycle. The remaining operations on this diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java index 4fa239aee5c..552500f0013 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.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. @@ -203,7 +203,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana * @see org.springframework.jdbc.core.JdbcTemplate */ public void setDataSource(@Nullable DataSource dataSource) { - if (dataSource != null && dataSource instanceof TransactionAwareDataSourceProxy) { + if (dataSource instanceof TransactionAwareDataSourceProxy) { // If we got a TransactionAwareDataSourceProxy, we need to perform transactions // for its underlying target DataSource, else data access code won't see // properly exposed transactions (i.e. transactions for the target DataSource). @@ -336,7 +336,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana @Nullable public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException { if (this.entityInterceptor instanceof Interceptor) { - return (Interceptor) entityInterceptor; + return (Interceptor) this.entityInterceptor; } else if (this.entityInterceptor instanceof String) { if (this.beanFactory == null) { @@ -777,7 +777,7 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana * from the {@code org.springframework.dao} hierarchy. *
Will automatically apply a specified SQLExceptionTranslator to a * Hibernate JDBCException, else rely on Hibernate's default translation. - * @param ex HibernateException that occurred + * @param ex the HibernateException that occurred * @return a corresponding DataAccessException * @see SessionFactoryUtils#convertHibernateAccessException */ diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionHolder.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionHolder.java index 591a19fad2e..a9c10a9fd3c 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionHolder.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionHolder.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. @@ -25,9 +25,9 @@ import org.springframework.transaction.support.ResourceHolderSupport; import org.springframework.util.Assert; /** - * Session holder, wrapping a Hibernate Session and a Hibernate Transaction. - * HibernateTransactionManager binds instances of this class to the thread, - * for a given SessionFactory. + * Resource holder wrapping a Hibernate {@link Session} (plus an optional {@link Transaction}). + * {@link HibernateTransactionManager} binds instances of this class to the thread, + * for a given {@link org.hibernate.SessionFactory}. * *
Note: This is an SPI class, not intended to be used by applications. * diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringSessionContext.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringSessionContext.java index df7dd0cb5f1..066c10a8809 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringSessionContext.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringSessionContext.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. @@ -32,9 +32,9 @@ import org.springframework.lang.Nullable; import org.springframework.transaction.support.TransactionSynchronizationManager; /** - * Implementation of Hibernate 3.1's CurrentSessionContext interface - * that delegates to Spring's SessionFactoryUtils for providing a - * Spring-managed current Session. + * Implementation of Hibernate 3.1's {@link CurrentSessionContext} interface + * that delegates to Spring's {@link SessionFactoryUtils} for providing a + * Spring-managed current {@link Session}. * *
This CurrentSessionContext implementation can also be specified in custom * SessionFactory setup through the "hibernate.current_session_context_class" @@ -110,7 +110,8 @@ public class SpringSessionContext implements CurrentSessionContext { if (this.transactionManager.getStatus() == Status.STATUS_ACTIVE) { Session session = this.jtaSessionContext.currentSession(); if (TransactionSynchronizationManager.isSynchronizationActive()) { - TransactionSynchronizationManager.registerSynchronization(new SpringFlushSynchronization(session)); + TransactionSynchronizationManager.registerSynchronization( + new SpringFlushSynchronization(session)); } return session; } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerHolder.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerHolder.java index 9dcb4094126..372ac553a8f 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerHolder.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerHolder.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. @@ -24,9 +24,9 @@ import org.springframework.transaction.support.ResourceHolderSupport; import org.springframework.util.Assert; /** - * Holder wrapping a JPA EntityManager. - * JpaTransactionManager binds instances of this class to the thread, - * for a given EntityManagerFactory. + * Resource holder wrapping a JPA {@link EntityManager}. + * {@link JpaTransactionManager} binds instances of this class to the thread, + * for a given {@link javax.persistence.EntityManagerFactory}. * *
Note: This is an SPI class, not intended to be used by applications.
*
diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java
index 840556a0aa3..674e72f2212 100644
--- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java
+++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.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.
@@ -138,7 +138,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
/**
* Create a new JpaTransactionManager instance.
- * @param emf EntityManagerFactory to manage transactions for
+ * @param emf the EntityManagerFactory to manage transactions for
*/
public JpaTransactionManager(EntityManagerFactory emf) {
this();
@@ -255,7 +255,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
* @see org.springframework.jdbc.core.JdbcTemplate
*/
public void setDataSource(@Nullable DataSource dataSource) {
- if (dataSource != null && dataSource instanceof TransactionAwareDataSourceProxy) {
+ if (dataSource instanceof TransactionAwareDataSourceProxy) {
// If we got a TransactionAwareDataSourceProxy, we need to perform transactions
// for its underlying target DataSource, else data access code won't see
// properly exposed transactions (i.e. transactions for the target DataSource).
diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java
index cd249657ef7..f60309d8dc5 100644
--- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java
+++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.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.
@@ -39,7 +39,8 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Juergen Hoeller
*/
-public abstract class AbstractContainerEntityManagerFactoryIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests {
+public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
+ extends AbstractEntityManagerFactoryIntegrationTests {
@Test
public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
@@ -78,7 +79,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests exte
}
@Test
- @SuppressWarnings({ "unused", "unchecked" })
+ @SuppressWarnings("unchecked")
public void testEntityManagerProxyIsProxy() {
assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass()));
Query q = sharedEntityManager.createQuery("select p from Person as p");
@@ -107,9 +108,8 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests exte
try {
Person notThere = sharedEntityManager.getReference(Person.class, 666);
- // We may get here (as with Hibernate).
- // Either behaviour is valid: throw exception on first access
- // or on getReference itself.
+ // We may get here (as with Hibernate). Either behaviour is valid:
+ // throw exception on first access or on getReference itself.
notThere.getFirstName();
fail("Should have thrown an EntityNotFoundException");
}
@@ -209,6 +209,8 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests exte
@Test
@SuppressWarnings("unchecked")
public void testQueryNoPersonsNotTransactional() {
+ endTransaction();
+
EntityManager em = entityManagerFactory.createEntityManager();
Query q = em.createQuery("select p from Person as p");
List CciLocalTransactionManager binds instances of this class
- * to the thread, for a given ConnectionFactory.
+ * Resource holder wrapping a CCI {@link Connection}.
+ * {@link CciLocalTransactionManager} binds instances of this class to the thread,
+ * for a given {@link javax.resource.cci.ConnectionFactory}.
*
* Note: This is an SPI class, not intended to be used by applications.
*
@@ -38,10 +37,12 @@ public class ConnectionHolder extends ResourceHolderSupport {
private final Connection connection;
+
public ConnectionHolder(Connection connection) {
this.connection = connection;
}
+
public Connection getConnection() {
return this.connection;
}