修复APP_EXECUTOR资源为null时inject报错的bug

This commit is contained in:
Redkale
2022-12-21 14:43:13 +08:00
parent 66a1850c49
commit f327378d18
3 changed files with 7 additions and 3 deletions

View File

@@ -299,8 +299,10 @@ public abstract class NodeServer {
public Object load(ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, final Object attachment) {
try {
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
if (!(srcObj instanceof Service)) throw new RuntimeException("CacheSource must be inject in Service, cannot " + srcObj);
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不需要注入 CacheSource
if (!(srcObj instanceof Service)) {
throw new RuntimeException("CacheSource must be inject in Service, cannot in " + srcObj);
}
final Service srcService = (Service) srcObj;
SncpClient client = Sncp.getSncpClient(srcService);
final InetSocketAddress sncpAddr = client == null ? null : client.getClientAddress();

View File

@@ -8,7 +8,7 @@ package org.redkale.service;
import java.util.concurrent.*;
import org.redkale.annotation.Resource;
import org.redkale.boot.Application;
import org.redkale.net.*;
import org.redkale.net.WorkThread;
import org.redkale.net.sncp.Sncp;
import org.redkale.util.ThreadHashExecutor;
@@ -18,7 +18,8 @@ import org.redkale.util.ThreadHashExecutor;
*/
public abstract class AbstractService implements Service {
@Resource(name = Application.RESNAME_APP_EXECUTOR)
//配置<executor threads="0"> APP_EXECUTOR资源为null
@Resource(name = Application.RESNAME_APP_EXECUTOR, required = false)
private ExecutorService workExecutor;
/**

View File

@@ -58,6 +58,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
@Resource(name = RESNAME_APP_CLIENT_ASYNCGROUP, required = false)
protected AsyncGroup clientAsyncGroup;
//配置<executor threads="0"> APP_EXECUTOR资源为null
@Resource(name = RESNAME_APP_EXECUTOR, required = false)
protected ExecutorService workExecutor;