From b722b12327f99f5eff5e4a45a5dd0c78ad2f763f Mon Sep 17 00:00:00 2001 From: Eleftheria Stein Date: Fri, 30 Oct 2020 14:34:37 +0100 Subject: [PATCH] Fix formatting Issue gh-1654 --- .../jdbc/JdbcIndexedSessionRepository.java | 16 ++++++++-------- .../jdbc/JdbcIndexedSessionRepositoryTests.java | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java b/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java index cd849fce..604e44f5 100644 --- a/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java +++ b/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java @@ -461,7 +461,7 @@ public class JdbcIndexedSessionRepository private void insertSessionAttributes(JdbcSession session, List attributeNames) { Assert.notEmpty(attributeNames, "attributeNames must not be null or empty"); - try (LobCreator lobCreator = lobHandler.getLobCreator()) { + try (LobCreator lobCreator = this.lobHandler.getLobCreator()) { if (attributeNames.size() > 1) { this.jdbcOperations.batchUpdate(this.createSessionAttributeQuery, new BatchPreparedStatementSetter() { @@ -469,8 +469,7 @@ public class JdbcIndexedSessionRepository public void setValues(PreparedStatement ps, int i) throws SQLException { String attributeName = attributeNames.get(i); ps.setString(1, attributeName); - lobCreator.setBlobAsBytes(ps, 2, - serialize(session.getAttribute(attributeName))); + lobCreator.setBlobAsBytes(ps, 2, serialize(session.getAttribute(attributeName))); ps.setString(3, session.getId()); } @@ -480,7 +479,8 @@ public class JdbcIndexedSessionRepository } }); - } else { + } + else { this.jdbcOperations.update(this.createSessionAttributeQuery, (ps) -> { String attributeName = attributeNames.get(0); ps.setString(1, attributeName); @@ -493,15 +493,14 @@ public class JdbcIndexedSessionRepository private void updateSessionAttributes(JdbcSession session, List attributeNames) { Assert.notEmpty(attributeNames, "attributeNames must not be null or empty"); - try (LobCreator lobCreator = lobHandler.getLobCreator()) { + try (LobCreator lobCreator = this.lobHandler.getLobCreator()) { if (attributeNames.size() > 1) { this.jdbcOperations.batchUpdate(this.updateSessionAttributeQuery, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { String attributeName = attributeNames.get(i); - lobCreator.setBlobAsBytes(ps, 1, - serialize(session.getAttribute(attributeName))); + lobCreator.setBlobAsBytes(ps, 1, serialize(session.getAttribute(attributeName))); ps.setString(2, session.primaryKey); ps.setString(3, attributeName); } @@ -512,7 +511,8 @@ public class JdbcIndexedSessionRepository } }); - } else { + } + else { this.jdbcOperations.update(this.updateSessionAttributeQuery, (ps) -> { String attributeName = attributeNames.get(0); lobCreator.setBlobAsBytes(ps, 1, serialize(session.getAttribute(attributeName))); diff --git a/spring-session-jdbc/src/test/java/org/springframework/session/jdbc/JdbcIndexedSessionRepositoryTests.java b/spring-session-jdbc/src/test/java/org/springframework/session/jdbc/JdbcIndexedSessionRepositoryTests.java index ef3828c9..d1e81c76 100644 --- a/spring-session-jdbc/src/test/java/org/springframework/session/jdbc/JdbcIndexedSessionRepositoryTests.java +++ b/spring-session-jdbc/src/test/java/org/springframework/session/jdbc/JdbcIndexedSessionRepositoryTests.java @@ -60,7 +60,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; /** * Tests for {@link JdbcIndexedSessionRepository}. @@ -719,7 +718,7 @@ class JdbcIndexedSessionRepositoryTests { void saveAndFreeTemporaryLob() { DefaultLobHandler lobHandler = mock(DefaultLobHandler.class); TemporaryLobCreator lobCreator = mock(TemporaryLobCreator.class); - when(lobHandler.getLobCreator()).thenReturn(lobCreator); + given(lobHandler.getLobCreator()).willReturn(lobCreator); lobHandler.setCreateTemporaryLob(true); this.repository.setLobHandler(lobHandler);