Skip to content

Commit 9cdc7a3

Browse files
authored
Merge pull request #734 from pierredavidbelanger/732
An failing test to demonstrate #732
2 parents fd91856 + 46ea40e commit 9cdc7a3

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.jooby.issues;
2+
3+
import com.typesafe.config.ConfigFactory;
4+
import com.typesafe.config.ConfigValueFactory;
5+
import org.jooby.jedis.Redis;
6+
import org.jooby.test.ServerFeature;
7+
import org.junit.Test;
8+
import redis.clients.jedis.Jedis;
9+
10+
public class Issue732 extends ServerFeature {
11+
12+
{
13+
14+
use(ConfigFactory
15+
.empty()
16+
.withValue("db",
17+
ConfigValueFactory.fromAnyRef("redis://localhost:6379")));
18+
19+
use(new Redis());
20+
21+
get("/Issue732", () -> {
22+
try (Jedis jedis = require(Jedis.class)) {
23+
jedis.get("dummy");
24+
return "Hello World!";
25+
}
26+
});
27+
28+
}
29+
30+
@Test
31+
public void appShouldBeAbleToServeTwoRequestsWithJedisConnection() throws Exception {
32+
// request().get("/Issue732").expect(200);
33+
// request().get("/Issue732").expect(200);
34+
}
35+
}

jooby-jedis/src/main/java/org/jooby/jedis/Redis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void configure(final Env env, final Config config, final Binder binder) {
190190
ServiceKey serviceKey = env.serviceKey();
191191
serviceKey.generate(JedisPool.class, name, k -> binder.bind(k).toInstance(pool));
192192
serviceKey.generate(Jedis.class, name,
193-
k -> binder.bind(k).toProvider(jedis).asEagerSingleton());
193+
k -> binder.bind(k).toProvider(jedis));
194194
}
195195

196196
private GenericObjectPoolConfig poolConfig(final Config config, final String name) {

jooby-jedis/src/test/java/org/jooby/jedis/RedisTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ public void defaults() throws Exception {
8282
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
8383
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
8484
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
85-
jABB.asEagerSingleton();
86-
jABB.asEagerSingleton();
8785

8886
Binder binder = unit.get(Binder.class);
8987
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);
@@ -143,8 +141,6 @@ public void shouldGetJedisInstance() throws Exception {
143141
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
144142
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
145143
expect(jABB.toProvider(unit.capture(Provider.class))).andReturn(jABB);
146-
jABB.asEagerSingleton();
147-
jABB.asEagerSingleton();
148144

149145
Binder binder = unit.get(Binder.class);
150146
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);
@@ -206,8 +202,6 @@ public void jedisConfigOverride() throws Exception {
206202
AnnotatedBindingBuilder<Jedis> jABB = unit.mock(AnnotatedBindingBuilder.class);
207203
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
208204
expect(jABB.toProvider(isA(Provider.class))).andReturn(jABB);
209-
jABB.asEagerSingleton();
210-
jABB.asEagerSingleton();
211205

212206
Binder binder = unit.get(Binder.class);
213207
expect(binder.bind(Key.get(JedisPool.class))).andReturn(jpABB);

0 commit comments

Comments
 (0)