fuxiuzhan
fuxiuzhan
可以参见这个实现,非常通用的方式 https://github.com/fuxiuzhan/fuled-component/tree/master/fuled-env-encryptor-starter 或者直接使用jasypt插件。
是的。建议线程池的queue不要直接替换,而应该使用代理的方式,将原始的queue取出完成代理后使用反射(=jdk8)替换原始的queue引用就可以了。 只要线程池内在被代理前有活动线程或者queue里已经有任务时就会出现上边的情况。但只要queue替换前有线程启动就会有问题,问题的大小就看启动的线程多少了。
高版本jdk对反射修改做了限制,不过可以使用unsafe修改,juc里大量使用unsafe,所以unsafe就变得相对safe了。see this:https://github.com/fuxiuzhan/fuled-component/blob/master/fuled-dynamic-threadpool-starter/src/main/java/com/fxz/fuled/dynamic/threadpool/ThreadPoolRegistry.java
/** * Thread-pool param replace. * * @param executor dynamic thread-pool executor * @param threadPoolParameterInfo thread-pool parameter info */ private void threadPoolParamReplace(ThreadPoolExecutor executor, ThreadPoolParameterInfo threadPoolParameterInfo) { #如下直接生成新的queue替换原有的引用,如果原始的queue里已经有堆积的任务,直接替换是不是会丢任务? BlockingQueue workQueue =...
这个是springboot本身的问题导致的,如果存在map可以注册Listener,有配置变更后清空map,用Binder重新绑定就可以了。此外比如@ConfigurationProperties的变量配置中心删除后不会改变原值,不过可以用配置空值生效。
多线程初始化bean导致死锁了。