[keycloak-dev] Reuse Apache HTTP client in the quickstarts and examples?

Marek Posolda mposolda at redhat.com
Fri May 6 05:24:37 EDT 2016


Right now, we always create new instance of Apache HTTP Client per each 
request. Like in the quickstarts [1] or in the examples [2] .

This is anti-pattern and not very good usage of Apache HTTP Client, 
which is supposed to be application-scoped object though. I know the 
point is to have examples as easy as possible. However shouldn't we 
avoid anti-patterns? Otherwise there might be possible risk that people 
will inspire and use the same pattern in their production apps :-)

[1] 
https://github.com/keycloak/keycloak-examples/blob/master/app-jee/src/main/java/org/keycloak/quickstart/appjee/ServiceClient.java#L148
[2] 
https://github.com/keycloak/keycloak/blob/master/examples/demo-template/customer-app/src/main/java/org/keycloak/example/CustomerDatabaseClient.java#L67

Marek


More information about the keycloak-dev mailing list