From 7b28b214ffa4925497dac3c77e9d54b874bbe89f Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 4 Mar 2016 11:23:54 -0600 Subject: [PATCH] Polish JdbcOperationsSessionRepository * Fix whitepspaces * Remove Override from interfaces Issue gh-364 --- .../jdbc/JdbcOperationsSessionRepository.java | 20 ------------------- .../http/JdbcHttpSessionConfiguration.java | 1 - .../JdbcOperationsSessionRepositoryTests.java | 6 +++++- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java index 34c250c..487c4b7 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java @@ -197,7 +197,6 @@ public class JdbcOperationsSessionRepository this.conversionService = conversionService; } - @Override public JdbcSession createSession() { JdbcSession session = new JdbcSession(); if (this.defaultMaxInactiveInterval != null) { @@ -206,12 +205,10 @@ public class JdbcOperationsSessionRepository return session; } - @Override public void save(final JdbcSession session) { if (session.isNew()) { this.jdbcOperations.update(getQuery(CREATE_SESSION_QUERY), new PreparedStatementSetter() { - @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, session.getId()); ps.setLong(2, session.getLastAccessedTime()); @@ -226,7 +223,6 @@ public class JdbcOperationsSessionRepository if (session.isAttributesChanged()) { this.jdbcOperations.update(getQuery(UPDATE_SESSION_QUERY), new PreparedStatementSetter() { - @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, session.getLastAccessedTime()); ps.setString(2, session.getPrincipalName()); @@ -240,7 +236,6 @@ public class JdbcOperationsSessionRepository else if (session.isLastAccessTimeChanged()) { this.jdbcOperations.update(getQuery(UPDATE_SESSION_LAST_ACCESS_TIME_QUERY), new PreparedStatementSetter() { - @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, session.getLastAccessedTime()); ps.setString(2, session.getId()); @@ -255,7 +250,6 @@ public class JdbcOperationsSessionRepository session.clearChangeFlags(); } - @Override public JdbcSession getSession(String id) { ExpiringSession session = null; try { @@ -276,12 +270,10 @@ public class JdbcOperationsSessionRepository return null; } - @Override public void delete(String id) { this.jdbcOperations.update(getQuery(DELETE_SESSION_QUERY), id); } - @Override public Map findByIndexNameAndIndexValue(String indexName, String indexValue) { if (!PRINCIPAL_NAME_INDEX_NAME.equals(indexName)) { return Collections.emptyMap(); @@ -388,60 +380,49 @@ public class JdbcOperationsSessionRepository return PRINCIPAL_NAME_RESOLVER.resolvePrincipal(this); } - @Override public long getCreationTime() { return this.delegate.getCreationTime(); } - @Override public void setLastAccessedTime(long lastAccessedTime) { this.delegate.setLastAccessedTime(lastAccessedTime); this.lastAccessTimeChanged = true; } - @Override public long getLastAccessedTime() { return this.delegate.getLastAccessedTime(); } - @Override public void setMaxInactiveIntervalInSeconds(int interval) { this.delegate.setMaxInactiveIntervalInSeconds(interval); this.attributesChanged = true; } - @Override public int getMaxInactiveIntervalInSeconds() { return this.delegate.getMaxInactiveIntervalInSeconds(); } - @Override public boolean isExpired() { return this.delegate.isExpired(); } - @Override public String getId() { return this.delegate.getId(); } - @Override public T getAttribute(String attributeName) { return this.delegate.getAttribute(attributeName); } - @Override public Set getAttributeNames() { return this.delegate.getAttributeNames(); } - @Override public void setAttribute(String attributeName, Object attributeValue) { this.delegate.setAttribute(attributeName, attributeValue); this.attributesChanged = true; } - @Override public void removeAttribute(String attributeName) { this.delegate.removeAttribute(attributeName); this.attributesChanged = true; @@ -472,7 +453,6 @@ public class JdbcOperationsSessionRepository private class ExpiringSessionMapper implements RowMapper { - @Override public ExpiringSession mapRow(ResultSet rs, int rowNum) throws SQLException { return (ExpiringSession) JdbcOperationsSessionRepository.this.conversionService.convert( JdbcOperationsSessionRepository.this.lobHandler.getBlobAsBytes(rs, "SESSION_BYTES"), TypeDescriptor.valueOf(byte[].class), TypeDescriptor.valueOf(ExpiringSession.class)); diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java index a697db2..5204f25 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java @@ -108,7 +108,6 @@ public class JdbcHttpSessionConfiguration extends SpringHttpSessionConfiguration return System.getProperty("spring.session.jdbc.tableName", ""); } - @Override public void setImportMetadata(AnnotationMetadata importMetadata) { Map enableAttrMap = importMetadata.getAnnotationAttributes(EnableJdbcHttpSession.class.getName()); AnnotationAttributes enableAttrs = AnnotationAttributes.fromMap(enableAttrMap); diff --git a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java index ad39b2a..ff70f28 100644 --- a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.session.jdbc; import java.util.ArrayList; @@ -203,6 +202,7 @@ public class JdbcOperationsSessionRepositoryTests { } @Test + @SuppressWarnings("unchecked") public void getSessionNotFound() { String sessionId = "testSessionId"; @@ -214,6 +214,7 @@ public class JdbcOperationsSessionRepositoryTests { } @Test + @SuppressWarnings("unchecked") public void getSessionExpired() { MapSession expired = new MapSession(); expired.setMaxInactiveIntervalInSeconds(0); @@ -229,6 +230,7 @@ public class JdbcOperationsSessionRepositoryTests { } @Test + @SuppressWarnings("unchecked") public void getSessionFound() { MapSession saved = new MapSession(); saved.setAttribute("savedName", "savedValue"); @@ -265,6 +267,7 @@ public class JdbcOperationsSessionRepositoryTests { } @Test + @SuppressWarnings("unchecked") public void findByIndexNameAndIndexValuePrincipalIndexNameNotFound() { String principal = "username"; @@ -277,6 +280,7 @@ public class JdbcOperationsSessionRepositoryTests { } @Test + @SuppressWarnings("unchecked") public void findByIndexNameAndIndexValuePrincipalIndexNameFound() { String principal = "username"; Authentication authentication = new UsernamePasswordAuthenticationToken(