DATAREDIS-1104 - Suppress connection close failures when unbinding a connection.

We now no longer propagate exceptions that happen during connection disposal but instead we log them on DEBUG level to avoid exception masking.
This commit is contained in:
Mark Paluch
2020-02-25 13:53:46 +01:00
parent c758a042c8
commit aa4d12433b
2 changed files with 65 additions and 12 deletions

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 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
*
* https://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.data.redis.core;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
* Unit tests for {@link RedisConnectionUtils}.
*
* @author Mark Paluch
*/
public class RedisConnectionUtilsUnitTests {
@Test // DATAREDIS-1104
public void shouldSilentlyCloseRedisConnection() {
RedisConnection connectionMock = mock(RedisConnection.class);
RedisConnectionFactory factoryMock = mock(RedisConnectionFactory.class);
doThrow(new IllegalStateException()).when(connectionMock).close();
RedisConnectionUtils.releaseConnection(connectionMock, factoryMock, false);
verify(connectionMock).close();
}
}