moremind commented on code in PR #5403:
URL: https://github.com/apache/shenyu/pull/5403#discussion_r1476075766
##########
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java:
##########
@@ -164,6 +164,22 @@ private void initCacheConfig() {
ruleTrie =
SpringBeanUtils.getInstance().getBean(TrieCacheTypeEnum.RULE.getTrieType());
}
}
+
+ private Mono<Void> isolationExecute(final ServerWebExchange exchange,
final ShenyuPluginChain chain, final SelectorData selector, final RuleData
rule) {
+// if (Objects.isNull(pluginClassLoader)) {
+// return doExecute(exchange, chain, selector, rule);
+// }
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ return doExecute(exchange, chain, selector, rule);
+ } catch (Throwable e) {
+ LogUtils.info(LOG, "Plugin class isolation execute failed. plugin:
{}, exception: {}", named(), e);
Review Comment:
error
##########
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/ExtendDataHandler.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.shenyu.plugin.base.cache;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The interface add data subscriber.
+ */
+public interface ExtendDataHandler<T> {
+
+ /**
+ * addHandlers.
+ *
+ * @param extendDatas extendDatas
+ */
+ void addHandlers(List<T> extendDatas);
+
+ /**
+ * addHandlers.
+ *
+ * @param dataSubscribers dataSubscribers
+ */
+ default void putExtendDataHandler(List<?> dataSubscribers) {
+ final Type[] genericInterfaces =
this.getClass().getGenericInterfaces();
+ if (genericInterfaces.length == 0 ||
CollectionUtils.isEmpty(dataSubscribers)) {
Review Comment:
ArraysUtils.isEmpty
##########
shenyu-common/src/main/java/org/apache/shenyu/common/isolation/ReverseClassLoader.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.shenyu.common.isolation;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * ReverseClassLoader.
+ */
+public class ReverseClassLoader extends URLClassLoader {
+
+ public ReverseClassLoader(final URL[] urls, final ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public ReverseClassLoader(final URL[] urls) {
+ super(urls);
+ }
+
+ /**
+ * Add URL.
+ * @param url the URL to be added to the search path of URLs
+ */
+ public void addURL(final URL url) {
+ super.addURL(url);
+ }
+
+ @Override
+ public Class<?> loadClass(final String name) throws ClassNotFoundException
{
+ return loadClass(name, false);
+ }
+
+ @Override
+ protected Class<?> loadClass(final String name, final boolean resolve)
throws ClassNotFoundException {
+ synchronized (getClassLoadingLock(name)) {
+ Class<?> c = findLoadedClass(name);
+ try {
+ if (c == null) {
+ c = findClass(name);
+ }
+ } catch (ClassNotFoundException e) {
+ // ignore
Review Comment:
add log
##########
shenyu-common/src/main/java/org/apache/shenyu/common/isolation/ReverseClassLoader.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.shenyu.common.isolation;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * ReverseClassLoader.
+ */
+public class ReverseClassLoader extends URLClassLoader {
+
+ public ReverseClassLoader(final URL[] urls, final ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public ReverseClassLoader(final URL[] urls) {
+ super(urls);
+ }
+
+ /**
+ * Add URL.
+ * @param url the URL to be added to the search path of URLs
+ */
+ public void addURL(final URL url) {
+ super.addURL(url);
+ }
+
+ @Override
+ public Class<?> loadClass(final String name) throws ClassNotFoundException
{
+ return loadClass(name, false);
+ }
+
+ @Override
+ protected Class<?> loadClass(final String name, final boolean resolve)
throws ClassNotFoundException {
+ synchronized (getClassLoadingLock(name)) {
+ Class<?> c = findLoadedClass(name);
+ try {
+ if (c == null) {
+ c = findClass(name);
+ }
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (c == null) {
Review Comment:
Objects.nonNull
##########
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/CommonMetaDataSubscriber.java:
##########
@@ -33,30 +34,49 @@
/**
* The type common meta data subscriber.
*/
-public class CommonMetaDataSubscriber implements MetaDataSubscriber {
+public class CommonMetaDataSubscriber implements MetaDataSubscriber,
ExtendDataHandler<MetaDataHandler> {
private static final Logger LOG =
LoggerFactory.getLogger(CommonMetaDataSubscriber.class);
- private final Map<String, MetaDataHandler> handlerMap;
+ private final Map<String, MetaDataHandler> handlerMap = new HashMap<>();
Review Comment:
concurrent?
##########
shenyu-client/shenyu-client-sofa/pom.xml:
##########
@@ -47,10 +47,26 @@
<version>${runtime-sofa-boot-starter.version}</version>
<scope>provided</scope>
</dependency>
+<!-- <dependency>-->
+<!-- <groupId>com.alipay.sofa</groupId>-->
+<!-- <artifactId>sofa-rpc-all</artifactId>-->
+<!-- <scope>provided</scope>-->
Review Comment:
provided
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]