This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f1f264  [type: refactor]: remove ByteArrayOutputStream. (#3051)
5f1f264 is described below

commit 5f1f264852485aa030293b7f02ffbc0bbe23dc6f
Author: YuI <[email protected]>
AuthorDate: Thu Mar 17 14:21:47 2022 +0800

    [type: refactor]: remove ByteArrayOutputStream. (#3051)
---
 .../agent/core/loader/ShenyuAgentPluginLoader.java | 10 +++------
 .../shenyu/web/loader/ShenyuPluginLoader.java      | 26 ++++++++++------------
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git 
a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/loader/ShenyuAgentPluginLoader.java
 
b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/loader/ShenyuAgentPluginLoader.java
index 106919f..cb4f2aa 100644
--- 
a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/loader/ShenyuAgentPluginLoader.java
+++ 
b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/loader/ShenyuAgentPluginLoader.java
@@ -26,7 +26,6 @@ import 
org.apache.shenyu.agent.core.locator.ShenyuAgentLocator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
@@ -86,12 +85,9 @@ public final class ShenyuAgentPluginLoader extends 
ClassLoader implements Closea
             return;
         }
         Map<String, ShenyuAgentJoinPoint> pointMap = new HashMap<>();
-        try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) 
{
-            for (File each : jarFiles) {
-                outputStream.reset();
-                JarFile jar = new JarFile(each, true);
-                jars.add(new PluginJar(jar, each));
-            }
+        for (File each : jarFiles) {
+            JarFile jar = new JarFile(each, true);
+            jars.add(new PluginJar(jar, each));
         }
         loadAgentPluginDefinition(pointMap);
         Map<String, ShenyuAgentJoinPoint> joinPointMap = ImmutableMap.<String, 
ShenyuAgentJoinPoint>builder().putAll(pointMap).build();
diff --git 
a/shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginLoader.java 
b/shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginLoader.java
index f9a5556..5aaecc9 100644
--- 
a/shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginLoader.java
+++ 
b/shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginLoader.java
@@ -29,7 +29,6 @@ import 
org.springframework.beans.factory.support.GenericBeanDefinition;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 
-import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
@@ -110,22 +109,21 @@ public final class ShenyuPluginLoader extends ClassLoader 
implements Closeable {
             return Collections.emptyList();
         }
         List<ShenyuLoaderResult> results = new ArrayList<>();
-        try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) 
{
-            for (File each : jarFiles) {
-                outputStream.reset();
-                JarFile jar = new JarFile(each, true);
-                jars.add(new PluginJar(jar, each));
-                Enumeration<JarEntry> entries = jar.entries();
-                while (entries.hasMoreElements()) {
-                    JarEntry jarEntry = entries.nextElement();
-                    String entryName = jarEntry.getName();
-                    if (entryName.endsWith(".class") && 
!entryName.contains("$")) {
-                        String className = entryName.substring(0, 
entryName.length() - 6).replaceAll("/", ".");
-                        names.add(className);
-                    }
+        for (File each : jarFiles) {
+
+            JarFile jar = new JarFile(each, true);
+            jars.add(new PluginJar(jar, each));
+            Enumeration<JarEntry> entries = jar.entries();
+            while (entries.hasMoreElements()) {
+                JarEntry jarEntry = entries.nextElement();
+                String entryName = jarEntry.getName();
+                if (entryName.endsWith(".class") && !entryName.contains("$")) {
+                    String className = entryName.substring(0, 
entryName.length() - 6).replaceAll("/", ".");
+                    names.add(className);
                 }
             }
         }
+
         names.forEach(className -> {
             Object instance;
             try {

Reply via email to