mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix null
This commit is contained in:
parent
ea7716a517
commit
16dfcf3154
@ -96,7 +96,7 @@ public class SimpleCache<K, V> implements Iterable<Map.Entry<K, V>>, Serializabl
|
|||||||
*/
|
*/
|
||||||
public V get(K key, Predicate<V> validPredicate, Func0<V> supplier) {
|
public V get(K key, Predicate<V> validPredicate, Func0<V> supplier) {
|
||||||
V v = get(key);
|
V v = get(key);
|
||||||
if((null != validPredicate && false == validPredicate.test(v))){
|
if((null != validPredicate && null != v && false == validPredicate.test(v))){
|
||||||
v = null;
|
v = null;
|
||||||
}
|
}
|
||||||
if (null == v && null != supplier) {
|
if (null == v && null != supplier) {
|
||||||
|
@ -42,7 +42,7 @@ public enum JschSessionPool {
|
|||||||
*/
|
*/
|
||||||
public Session getSession(String sshHost, int sshPort, String sshUser, String sshPass) {
|
public Session getSession(String sshHost, int sshPort, String sshUser, String sshPass) {
|
||||||
final String key = StrUtil.format("{}@{}:{}", sshUser, sshHost, sshPort);
|
final String key = StrUtil.format("{}@{}:{}", sshUser, sshHost, sshPort);
|
||||||
return this.cache.get(key, (conn)->null != conn && conn.isConnected(), ()-> JschUtil.openSession(sshHost, sshPort, sshUser, sshPass));
|
return this.cache.get(key, Session::isConnected, ()-> JschUtil.openSession(sshHost, sshPort, sshUser, sshPass));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +57,7 @@ public enum JschSessionPool {
|
|||||||
*/
|
*/
|
||||||
public Session getSession(String sshHost, int sshPort, String sshUser, String prvkey, byte[] passphrase) {
|
public Session getSession(String sshHost, int sshPort, String sshUser, String prvkey, byte[] passphrase) {
|
||||||
final String key = StrUtil.format("{}@{}:{}", sshUser, sshHost, sshPort);
|
final String key = StrUtil.format("{}@{}:{}", sshUser, sshHost, sshPort);
|
||||||
return this.cache.get(key, (conn)->null != conn && conn.isConnected(), ()->JschUtil.openSession(sshHost, sshPort, sshUser, prvkey, passphrase));
|
return this.cache.get(key, Session::isConnected, ()->JschUtil.openSession(sshHost, sshPort, sshUser, prvkey, passphrase));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user