This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 2b9d23dc795 Refactor AgentPluginClassLoader (#30279)
2b9d23dc795 is described below
commit 2b9d23dc795e5b6440b9e78fbfcb105f44841708
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Feb 25 01:29:53 2024 +0800
Refactor AgentPluginClassLoader (#30279)
* Refactor ShardingSphereDriverUtils
* Refactor AgentPluginClassLoader
---
.../agent/core/plugin/classloader/AgentPluginClassLoader.java | 2 +-
.../agent/plugin/core/util/ShardingSphereDriverUtils.java | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/classloader/AgentPluginClassLoader.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/classloader/AgentPluginClassLoader.java
index deed99b8139..935a91a90d2 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/classloader/AgentPluginClassLoader.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/classloader/AgentPluginClassLoader.java
@@ -103,7 +103,7 @@ public final class AgentPluginClassLoader extends
ClassLoader {
ByteArrayOutputStream result = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[buffSize];
- int len = -1;
+ int len;
while ((len = inStream.read(buffer)) != -1) {
result.write(buffer, 0, len);
}
diff --git
a/agent/plugins/core/src/main/java/org/apache/shardingsphere/agent/plugin/core/util/ShardingSphereDriverUtils.java
b/agent/plugins/core/src/main/java/org/apache/shardingsphere/agent/plugin/core/util/ShardingSphereDriverUtils.java
index 3a4188238d4..9e7bc95b01b 100644
---
a/agent/plugins/core/src/main/java/org/apache/shardingsphere/agent/plugin/core/util/ShardingSphereDriverUtils.java
+++
b/agent/plugins/core/src/main/java/org/apache/shardingsphere/agent/plugin/core/util/ShardingSphereDriverUtils.java
@@ -44,8 +44,7 @@ public final class ShardingSphereDriverUtils {
* @return found data source
*/
public static Optional<Map<String, ShardingSphereDataSource>>
findShardingSphereDataSources() {
- Optional<ShardingSphereDriver> driver = findShardingSphereDriver();
- return
driver.flatMap(ShardingSphereDriverUtils::findShardingSphereDataSources);
+ return
findShardingSphereDriver().flatMap(ShardingSphereDriverUtils::findShardingSphereDataSources);
}
private static Optional<Map<String, ShardingSphereDataSource>>
findShardingSphereDataSources(final Driver driver) {