Skip to content
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

DruidJerseyClient is not thread-safe #96

Open
ethendev opened this issue Jun 10, 2019 · 3 comments
Open

DruidJerseyClient is not thread-safe #96

ethendev opened this issue Jun 10, 2019 · 3 comments
Labels

Comments

@ethendev
Copy link

The connect() and close() methods in DruidJerseyClient class are not thread-safe which will throw an exception in a multi-threaded environment.

截图

@Robinub
Copy link

Robinub commented Jun 18, 2019

Is there a solution? I get a problem, the DruidResponse cannot be resolved, and how to deal with it?

@ethendev
Copy link
Author

@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?

@Robinub
Copy link

Robinub commented Jun 19, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants