Skip to content

Commit 1596005

Browse files
committed
set ThreadLocalMap HashMap to ConcurrentMap; check valid in executeWithConnection
1 parent bd6e7ff commit 1596005

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/com/alipay/oceanbase/rpc/table/ObTable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ public ObPayload executeWithConnection(final ObPayload request,
478478
AtomicReference<ObTableConnection> connectionRef)
479479
throws RemotingException,
480480
InterruptedException {
481+
if (!isValid()) {
482+
log.warn("[latency monitor] The server is not available, server address: " + ip + ":" + port);
483+
throw new ObTableServerConnectException("The server is not available, server address: " + ip + ":" + port);
484+
}
481485
ObTableConnection connection;
482486
try {
483487
if (connectionRef.get() == null) {

src/main/java/com/alipay/oceanbase/rpc/threadlocal/ThreadLocalMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
2222
import org.slf4j.Logger;
2323

24-
import java.util.HashMap;
2524
import java.util.Map;
25+
import java.util.concurrent.ConcurrentHashMap;
2626

2727
public class ThreadLocalMap {
2828

@@ -112,7 +112,7 @@ public static void transmitContextMap(Map<Object, Object> context) {
112112

113113
private static class MapThreadLocal extends ThreadLocal<Map<Object, Object>> {
114114
protected Map<Object, Object> initialValue() {
115-
return new HashMap<Object, Object>() {
115+
return new ConcurrentHashMap<Object, Object>() {
116116

117117
private static final long serialVersionUID = 3637958959138295593L;
118118

0 commit comments

Comments
 (0)