You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/10/14 04:30:26 UTC
[shardingsphere] branch master updated: Refactor
MetaDataConnectionAdapter.getSchema (#7784)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 7797282 Refactor MetaDataConnectionAdapter.getSchema (#7784)
7797282 is described below
commit 77972824ad4f181e8c275895ff66c0773622aefa
Author: xiaoyu <54...@qq.com>
AuthorDate: Wed Oct 14 12:30:14 2020 +0800
Refactor MetaDataConnectionAdapter.getSchema (#7784)
* Optional get refactor
* fix checkstyle
---
.../metadata/model/physical/jdbc/MetaDataConnectionAdapter.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/MetaDataConnectionAdapter.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/MetaDataConnectionAdapter.java
index feeff90..4de741e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/MetaDataConnectionAdapter.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/model/physical/jdbc/MetaDataConnectionAdapter.java
@@ -74,10 +74,10 @@ public final class MetaDataConnectionAdapter implements Connection {
@Override
public String getSchema() {
- Optional<JDBCSchemaHandler> handler = findJDBCSchemaHandler();
- if (handler.isPresent()) {
- return handler.get().getSchema(connection);
- }
+ return findJDBCSchemaHandler().map(handler -> handler.getSchema(connection)).orElse(getSchema(connection));
+ }
+
+ private String getSchema(final Connection connection) {
try {
return connection.getSchema();
} catch (final SQLException ex) {