-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullpoint Exception for different thead #244
Comments
Exception in thread "Thread-1" java.lang.NullPointerException |
From the code in client, I found that it should be connect, execute and close in same thread. If then, I need to create the client every time when access graph data. If connect and close frequently, will it affect the performance? |
|
V1.1.0 |
I have put the switch space operation in sub-thread, but the result is same. import cn.hutool.core.util.StrUtil; import java.util.List; @slf4j
} |
Exception in thread "Thread-1" java.lang.NullPointerException |
As you said in #171 GraphClient graphClient = new GraphClientImpl(addresses); new Thread(() -> { Tsocket will be opened twice, and they are in different thread. For example: My App is based on springboot, event request may be in different threads, so we call nebula api, like this. that means we need to connect & close frequently, and socket will close frequently too, when there are a lot of requests. I don't know if anyone use it in springboot or othere micro service framework. |
TCP 192.168.101.1:8960 192.168.101.128:3699 TIME_WAIT 0 |
Your program throws NPE because the graphClient is closed in main thread, and NPE happens when sub-thread use graphClient to execute statements. Sorry that Client 1.x does not support connection pool, if you want to support multi-thread query in SpringClould or SpringBoot, you can use pools to manage graphClient and graphClient's status to avoid graphClient being used by mutil-thread at the same time. |
package com.coney.microservice.dashboard;
import cn.hutool.core.util.StrUtil;
import com.facebook.thrift.TException;
import com.google.common.collect.Lists;
import com.vesoft.nebula.client.graph.*;
import com.vesoft.nebula.data.Result;
import com.vesoft.nebula.graph.RowValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
@slf4j
public class NebulaTest {
}
The text was updated successfully, but these errors were encountered: