Merge branch 'master' of github.com:mrniko/redisson

pull/583/head
Nikita 9 years ago
commit 1cf0b40179

@ -59,10 +59,10 @@ Features
* Thread-safe implementation
* All commands executes in an atomic way
* Lua scripting
* [Spring cache](http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html) integration
* [Spring cache](https://github.com/mrniko/redisson/wiki/10.-additional-features/#104-spring-cache-integration) integration
* Supports [Reactive Streams](http://www.reactive-streams.org)
* Supports [Redis pipelining](http://redis.io/topics/pipelining) (command batches)
* Supports [Remote services](https://github.com/mrniko/redisson/wiki/6.-distributed-objects#69-remote-service)
* Supports [Remote services](https://github.com/mrniko/redisson/wiki/9.-distributed-services/#91-remote-service)
* Supports Android platform
* Supports auto-reconnect
* Supports failed to send command auto-retry

@ -82,7 +82,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
return asLiveObject(proxied).isExists() ? null : proxied;
} catch (Exception ex) {
unregisterClass(entityClass);
throw new RuntimeException(ex);
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
}
@ -93,7 +93,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
return asLiveObject(proxied).isExists() ? proxied : null;
} catch (Exception ex) {
unregisterClass(entityClass);
throw new RuntimeException(ex);
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
}
@ -103,7 +103,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
return instantiateLiveObject(getProxyClass(entityClass), id);
} catch (Exception ex) {
unregisterClass(entityClass);
throw new RuntimeException(ex);
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
}
@ -118,7 +118,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
getRIdFieldName(detachedObject.getClass())));
} catch (Exception ex) {
unregisterClass(entityClass);
throw new RuntimeException(ex);
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
}
@ -147,7 +147,7 @@ public class RedissonLiveObjectService implements RLiveObjectService {
BeanCopy.beans(attachedObject, detached).declared(false, true).copy();
return detached;
} catch (Exception ex) {
throw new RuntimeException(ex);
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
}
@ -210,6 +210,9 @@ public class RedissonLiveObjectService implements RLiveObjectService {
}
private <T, K> T instantiateLiveObject(Class<T> proxyClass, K id) throws Exception {
if (id == null) {
throw new IllegalStateException("Non-null value is required for the field with RId annotation.");
}
T instance = instantiate(proxyClass, id);
asLiveObject(instance).setLiveObjectId(id);
return instance;

@ -197,7 +197,7 @@ public interface RLiveObjectService {
/**
* Pre register the class with the service, registering all the classes on
* startup can speed up the instance creation. This is <b>NOT</b> mandatory
* since the class will also be registered lazyly when it first is used.
* since the class will also be registered lazily when it is first used.
*
* All classed registered with the service is stored in a class cache.
*

@ -327,7 +327,7 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
s.<TestREntityIdNested, TestREntity>getOrCreate(TestREntityIdNested.class, t1);
fail("Should not be here");
} catch (Exception e) {
assertEquals("Field with RId annotation cannot be a type of which class is annotated with REntity.", e.getCause().getMessage());
assertEquals("Field with RId annotation cannot be a type of which class is annotated with REntity.", e.getMessage());
}
}
@ -487,14 +487,14 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
service.getOrCreate(TestClass.class, new int[]{1, 2, 3, 4, 5});
fail("Should not be here");
} catch (Exception e) {
assertEquals("RId value cannot be an array.", e.getCause().getMessage());
assertEquals("RId value cannot be an array.", e.getMessage());
}
try {
service.getOrCreate(TestClass.class, new byte[]{1, 2, 3, 4, 5});
fail("Should not be here");
} catch (Exception e) {
assertEquals("RId value cannot be an array.", e.getCause().getMessage());
assertEquals("RId value cannot be an array.", e.getMessage());
}
}
@ -885,4 +885,51 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
}
@REntity
public static class MyObject implements Serializable {
@RId(generator = DistributedAtomicLongIdGenerator.class)
private Long id;
private Long myId;
private String name;
public MyObject() {
}
public MyObject(Long myId) {
super();
this.myId = myId;
}
public Long getMyId() {
return myId;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@Test
public void test() {
RLiveObjectService service = redisson.getLiveObjectService();
MyObject object = new MyObject(20L);
try {
service.attach(object);
} catch (Exception e) {
assertEquals("Non-null value is required for the field with RId annotation.", e.getMessage());
}
}
}

Loading…
Cancel
Save