druidry
druidry copied to clipboard
DruidJerseyClient is not thread-safe
The connect() and close() methods in DruidJerseyClient class are not thread-safe which will throw an exception in a multi-threaded environment.
Is there a solution? I get a problem, the DruidResponse cannot be resolved, and how to deal with it?
@Robinub You can use ThreadLocal in DruidJerseyClient class, please refer to this PR.
Or you can call connect() method when the application starts and close() method when the application exits.
@SpringBootApplication
public class MyApplication {
@Autowired
private DruidClient druidClient;
@PostConstruct
public void init() throws ConnectionException {
druidClient.connect();
}
@PreDestroy
public void destroy() throws ConnectionException {
druidClient.close();
}
public static void main(String[] args) {
SpringApplication.run(MyApplication .class, args);
}
}
the DruidResponse cannot be resolved
, Can you provide more detailed error information?
@ethendev Thank you! The DruidResponse class is not created in the jar file, but now I use the HashMap to receive the results of querying instead.