修复APP_EXECUTOR资源为null时inject报错的bug
This commit is contained in:
@@ -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) {
|
public Object load(ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, final Object attachment) {
|
||||||
try {
|
try {
|
||||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
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) && 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;
|
final Service srcService = (Service) srcObj;
|
||||||
SncpClient client = Sncp.getSncpClient(srcService);
|
SncpClient client = Sncp.getSncpClient(srcService);
|
||||||
final InetSocketAddress sncpAddr = client == null ? null : client.getClientAddress();
|
final InetSocketAddress sncpAddr = client == null ? null : client.getClientAddress();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package org.redkale.service;
|
|||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import org.redkale.annotation.Resource;
|
import org.redkale.annotation.Resource;
|
||||||
import org.redkale.boot.Application;
|
import org.redkale.boot.Application;
|
||||||
import org.redkale.net.*;
|
import org.redkale.net.WorkThread;
|
||||||
import org.redkale.net.sncp.Sncp;
|
import org.redkale.net.sncp.Sncp;
|
||||||
import org.redkale.util.ThreadHashExecutor;
|
import org.redkale.util.ThreadHashExecutor;
|
||||||
|
|
||||||
@@ -18,7 +18,8 @@ import org.redkale.util.ThreadHashExecutor;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractService implements Service {
|
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;
|
private ExecutorService workExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
|||||||
@Resource(name = RESNAME_APP_CLIENT_ASYNCGROUP, required = false)
|
@Resource(name = RESNAME_APP_CLIENT_ASYNCGROUP, required = false)
|
||||||
protected AsyncGroup clientAsyncGroup;
|
protected AsyncGroup clientAsyncGroup;
|
||||||
|
|
||||||
|
//配置<executor threads="0"> APP_EXECUTOR资源为null
|
||||||
@Resource(name = RESNAME_APP_EXECUTOR, required = false)
|
@Resource(name = RESNAME_APP_EXECUTOR, required = false)
|
||||||
protected ExecutorService workExecutor;
|
protected ExecutorService workExecutor;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user