Closed 805728578 closed 9 months ago
The context
@Configuration(proxyBeanMethods = false) @ConditionalOnClass({ NettyUDPFactory.class}) public class NettyClientStartConfiguration { @Bean(value = "nettyUDPClientFactory") @ConditionalOnClass({ NettyUDPFactory.class }) public NettyUDPFactory nettyUDPClientFactory() { return new NettyUDPFactory() } @Bean(value = "nettyUDPServerFactory") @ConditionalOnClass({ NettyUDPFactory.class }) public NettyUDPFactory nettyUDPServerFactory() { return new NettyUDPFactory() } @Component @Order(value = Integer.MAX_VALUE) public class NettyUDPClientStartConfiguration implements ApplicationRunner{ private NettyUDPFactory factory; public NettyUDPClientStartConfiguration(@Qualifier("nettyUDPClientFactory")NettyUDPFactory factory) { this.factory = factory; } @Override public void run(ApplicationArguments args) throws Exception { Executors.newScheduledThreadPool(1).scheduleAtFixedRate(()->{ if(factory.isEnabled()&&!factory.isSuccess()) { factory.start(); } }, 10, 1, TimeUnit.SECONDS); } } } public class NettyUDPFactory extends ConfigurableFactory,DisposableBean, AutoCloseable { static AtomicBoolean LOGGER_ENABLED = new AtomicBoolean(true); /** * TCP协议 */ static final String SCHEME_TCP = "tcp://"; /** * SSL协议 */ static final String SCHEME_SSL = "ssl://"; /** * HTTP协议 */ static final String SCHEME_HTTP = "http://"; /** * HTTPS协议 */ static final String SCHEME_HTTPS = "https://"; /** * 描述: 初始化服务 * * @author ZhangYi * @date 2023-09-20 12:30:34 */ public void initialize(){ }; /** * 描述: 启动服务 * * @author ZhangYi * @date 2019-10-25 12:30:34 */ public void start(){ }; /** * 描述: 关闭(销毁)服务 * * @author ZhangYi * @date 2019-10-25 12:30:34 */ public void reconnect() { }; /** * 描述: 是否延迟加载 * * @author ZhangYi * @date 2023-07-25 12:30:34 */ public boolean delay() { return false; }; /** * 描述: 是否延迟加载 * * @author ZhangYi * @date 2023-07-25 12:30:34 */ @Override public void close() throws Exception { } @Override public void destroy() throws Exception { close(); } }
What do you wish to achieve?
The bug
What's the problem? What's not working? What do you expect to happen.
Stacktrace and logs
Is there a stacktrace or a hint in the logs? (very important) Screenshots work as well, but don't screenshot your logs.
Steps to Reproduce
Steps to reproduce the behavior:
The application's environment
Which versions do you use?
Additional context
array out of bounds exception 这个之前因为使用多线程 出现过
Please provide a full stacktrace and a reproducible example.
The context
What do you wish to achieve?
The bug
What's the problem? What's not working? What do you expect to happen.
Stacktrace and logs
Is there a stacktrace or a hint in the logs? (very important) Screenshots work as well, but don't screenshot your logs.
Steps to Reproduce
Steps to reproduce the behavior:
The application's environment
Which versions do you use?
Additional context