Merge branch 'master' into 3.0.0

pull/1933/head
Nikita Koksharov 6 years ago
commit 1fb6f4e812

@ -15,8 +15,14 @@
*/
package org.redisson.tomcat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.apache.catalina.util.CustomObjectInputStream;
/**
*
* @author Nikita Koksharov
@ -31,10 +37,6 @@ public class AttributeMessage implements Serializable {
public AttributeMessage() {
}
public AttributeMessage(String sessionId) {
this.sessionId = sessionId;
}
public AttributeMessage(String nodeId, String sessionId) {
this.nodeId = nodeId;
this.sessionId = sessionId;
@ -48,4 +50,22 @@ public class AttributeMessage implements Serializable {
return nodeId;
}
protected byte[] toByteArray(Object value) throws IOException {
if (value == null) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(value);
out.flush();
return bos.toByteArray();
}
protected Object toObject(ClassLoader classLoader, byte[] value) throws IOException, ClassNotFoundException {
if (value == null) {
return null;
}
CustomObjectInputStream in = new CustomObjectInputStream(new ByteArrayInputStream(value), classLoader);
return in.readObject();
}
}

@ -28,11 +28,6 @@ public class AttributeRemoveMessage extends AttributeMessage {
super();
}
public AttributeRemoveMessage(String sessionId, String name) {
super(sessionId);
this.name = name;
}
public AttributeRemoveMessage(String nodeId, String sessionId, String name) {
super(nodeId, sessionId);
this.name = name;

@ -15,6 +15,8 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
/**
*
* @author Nikita Koksharov
@ -23,29 +25,23 @@ package org.redisson.tomcat;
public class AttributeUpdateMessage extends AttributeMessage {
private String name;
private Object value;
private byte[] value;
public AttributeUpdateMessage() {
}
public AttributeUpdateMessage(String sessionId, String name, Object value) {
super(sessionId);
this.name = name;
this.value = value;
}
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) {
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) throws IOException {
super(nodeId, sessionId);
this.name = name;
this.value = value;
this.value = toByteArray(value);
}
public String getName() {
return name;
}
public Object getValue() {
return value;
public Object getValue(ClassLoader classLoader) throws IOException, ClassNotFoundException {
return toObject(classLoader, value);
}
}

@ -25,10 +25,6 @@ public class AttributesClearMessage extends AttributeMessage {
public AttributesClearMessage() {
}
public AttributesClearMessage(String sessionId) {
super(sessionId);
}
public AttributesClearMessage(String nodeId, String sessionId) {
super(nodeId, sessionId);
}

@ -15,7 +15,10 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
*
@ -24,23 +27,32 @@ import java.util.Map;
*/
public class AttributesPutAllMessage extends AttributeMessage {
private Map<String, Object> attrs;
private Map<String, byte[]> attrs;
public AttributesPutAllMessage() {
}
public AttributesPutAllMessage(String sessionId, Map<String, Object> attrs) {
super(sessionId);
this.attrs = attrs;
}
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) {
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) throws IOException {
super(nodeId, sessionId);
this.attrs = attrs;
if (attrs != null) {
this.attrs = new HashMap<String, byte[]>();
for (Entry<String, Object> entry: attrs.entrySet()) {
this.attrs.put(entry.getKey(), toByteArray(entry.getValue()));
}
} else {
this.attrs = null;
}
}
public Map<String, Object> getAttrs() {
return attrs;
public Map<String, Object> getAttrs(ClassLoader classLoader) throws IOException, ClassNotFoundException {
if (attrs == null) {
return null;
}
Map<String, Object> result = new HashMap<String, Object>();
for (Entry<String, byte[]> entry: attrs.entrySet()) {
result.put(entry.getKey(), toObject(classLoader, entry.getValue()));
}
return result;
}
}

@ -15,6 +15,7 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
@ -132,7 +133,11 @@ public class RedissonSession extends StandardSession {
for (Entry<String, Object> entry : newMap.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
try {
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
@ -148,7 +153,11 @@ public class RedissonSession extends StandardSession {
private void fastPut(String name, Object value) {
map.fastPut(name, value);
if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
try {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}

@ -158,7 +158,9 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
}
public RTopic getTopic() {
return redisson.getTopic("redisson:tomcat_session_updates:" + container.getName());
String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
final String name = keyPrefix + separator + "redisson:tomcat_session_updates:" + ((Context) getContainer()).getName();
return redisson.getTopic(name);
}
@Override
@ -228,6 +230,13 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
public void start() throws LifecycleException {
redisson = buildClient();
final ClassLoader applicationClassLoader;
if (Thread.currentThread().getContextClassLoader() != null) {
applicationClassLoader = Thread.currentThread().getContextClassLoader();
} else {
applicationClassLoader = getClass().getClassLoader();
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
getEngine().getPipeline().addValve(new UpdateValve(this));
}
@ -252,17 +261,17 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
if (msg instanceof AttributesPutAllMessage) {
AttributesPutAllMessage m = (AttributesPutAllMessage) msg;
for (Entry<String, Object> entry : m.getAttrs().entrySet()) {
for (Entry<String, Object> entry : m.getAttrs(applicationClassLoader).entrySet()) {
session.superSetAttribute(entry.getKey(), entry.getValue(), true);
}
}
if (msg instanceof AttributeUpdateMessage) {
AttributeUpdateMessage m = (AttributeUpdateMessage)msg;
session.superSetAttribute(m.getName(), m.getValue(), true);
session.superSetAttribute(m.getName(), m.getValue(applicationClassLoader), true);
}
}
} catch (IOException e) {
} catch (Exception e) {
log.error("Can't handle topic message", e);
}
}

@ -15,8 +15,14 @@
*/
package org.redisson.tomcat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.apache.catalina.util.CustomObjectInputStream;
/**
*
* @author Nikita Koksharov
@ -31,10 +37,6 @@ public class AttributeMessage implements Serializable {
public AttributeMessage() {
}
public AttributeMessage(String sessionId) {
this.sessionId = sessionId;
}
public AttributeMessage(String nodeId, String sessionId) {
this.nodeId = nodeId;
this.sessionId = sessionId;
@ -48,4 +50,22 @@ public class AttributeMessage implements Serializable {
return nodeId;
}
protected byte[] toByteArray(Object value) throws IOException {
if (value == null) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(value);
out.flush();
return bos.toByteArray();
}
protected Object toObject(ClassLoader classLoader, byte[] value) throws IOException, ClassNotFoundException {
if (value == null) {
return null;
}
CustomObjectInputStream in = new CustomObjectInputStream(new ByteArrayInputStream(value), classLoader);
return in.readObject();
}
}

@ -28,11 +28,6 @@ public class AttributeRemoveMessage extends AttributeMessage {
super();
}
public AttributeRemoveMessage(String sessionId, String name) {
super(sessionId);
this.name = name;
}
public AttributeRemoveMessage(String nodeId, String sessionId, String name) {
super(nodeId, sessionId);
this.name = name;

@ -15,6 +15,8 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
/**
*
* @author Nikita Koksharov
@ -23,29 +25,23 @@ package org.redisson.tomcat;
public class AttributeUpdateMessage extends AttributeMessage {
private String name;
private Object value;
private byte[] value;
public AttributeUpdateMessage() {
}
public AttributeUpdateMessage(String sessionId, String name, Object value) {
super(sessionId);
this.name = name;
this.value = value;
}
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) {
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) throws IOException {
super(nodeId, sessionId);
this.name = name;
this.value = value;
this.value = toByteArray(value);
}
public String getName() {
return name;
}
public Object getValue() {
return value;
public Object getValue(ClassLoader classLoader) throws IOException, ClassNotFoundException {
return toObject(classLoader, value);
}
}

@ -25,10 +25,6 @@ public class AttributesClearMessage extends AttributeMessage {
public AttributesClearMessage() {
}
public AttributesClearMessage(String sessionId) {
super(sessionId);
}
public AttributesClearMessage(String nodeId, String sessionId) {
super(nodeId, sessionId);
}

@ -15,7 +15,10 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
*
@ -24,23 +27,32 @@ import java.util.Map;
*/
public class AttributesPutAllMessage extends AttributeMessage {
private Map<String, Object> attrs;
private Map<String, byte[]> attrs;
public AttributesPutAllMessage() {
}
public AttributesPutAllMessage(String sessionId, Map<String, Object> attrs) {
super(sessionId);
this.attrs = attrs;
}
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) {
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) throws IOException {
super(nodeId, sessionId);
this.attrs = attrs;
if (attrs != null) {
this.attrs = new HashMap<String, byte[]>();
for (Entry<String, Object> entry: attrs.entrySet()) {
this.attrs.put(entry.getKey(), toByteArray(entry.getValue()));
}
} else {
this.attrs = null;
}
}
public Map<String, Object> getAttrs() {
return attrs;
public Map<String, Object> getAttrs(ClassLoader classLoader) throws IOException, ClassNotFoundException {
if (attrs == null) {
return null;
}
Map<String, Object> result = new HashMap<String, Object>();
for (Entry<String, byte[]> entry: attrs.entrySet()) {
result.put(entry.getKey(), toObject(classLoader, entry.getValue()));
}
return result;
}
}

@ -15,6 +15,7 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
@ -55,7 +56,7 @@ public class RedissonSession extends StandardSession {
private final RedissonSessionManager.ReadMode readMode;
private final UpdateMode updateMode;
public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode) {
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) {
super(manager);
this.redissonManager = manager;
this.readMode = readMode;
@ -132,7 +133,11 @@ public class RedissonSession extends StandardSession {
for (Entry<String, Object> entry : newMap.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
try {
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
@ -148,7 +153,11 @@ public class RedissonSession extends StandardSession {
private void fastPut(String name, Object value) {
map.fastPut(name, value);
if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
try {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}

@ -137,7 +137,9 @@ public class RedissonSessionManager extends ManagerBase {
}
public RTopic getTopic() {
return redisson.getTopic("redisson:tomcat_session_updates:" + container.getName());
String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
final String name = keyPrefix + separator + "redisson:tomcat_session_updates:" + ((Context) getContainer()).getName();
return redisson.getTopic(name);
}
@Override
@ -208,6 +210,13 @@ public class RedissonSessionManager extends ManagerBase {
super.startInternal();
redisson = buildClient();
final ClassLoader applicationClassLoader;
if (Thread.currentThread().getContextClassLoader() != null) {
applicationClassLoader = Thread.currentThread().getContextClassLoader();
} else {
applicationClassLoader = getClass().getClassLoader();
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
getEngine().getPipeline().addValve(new UpdateValve(this));
}
@ -232,17 +241,17 @@ public class RedissonSessionManager extends ManagerBase {
if (msg instanceof AttributesPutAllMessage) {
AttributesPutAllMessage m = (AttributesPutAllMessage) msg;
for (Entry<String, Object> entry : m.getAttrs().entrySet()) {
for (Entry<String, Object> entry : m.getAttrs(applicationClassLoader).entrySet()) {
session.superSetAttribute(entry.getKey(), entry.getValue(), true);
}
}
if (msg instanceof AttributeUpdateMessage) {
AttributeUpdateMessage m = (AttributeUpdateMessage)msg;
session.superSetAttribute(m.getName(), m.getValue(), true);
session.superSetAttribute(m.getName(), m.getValue(applicationClassLoader), true);
}
}
} catch (IOException e) {
} catch (Exception e) {
log.error("Can't handle topic message", e);
}
}

@ -15,8 +15,14 @@
*/
package org.redisson.tomcat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.apache.catalina.util.CustomObjectInputStream;
/**
*
* @author Nikita Koksharov
@ -31,10 +37,6 @@ public class AttributeMessage implements Serializable {
public AttributeMessage() {
}
public AttributeMessage(String sessionId) {
this.sessionId = sessionId;
}
public AttributeMessage(String nodeId, String sessionId) {
this.nodeId = nodeId;
this.sessionId = sessionId;
@ -48,4 +50,22 @@ public class AttributeMessage implements Serializable {
return nodeId;
}
protected byte[] toByteArray(Object value) throws IOException {
if (value == null) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(value);
out.flush();
return bos.toByteArray();
}
protected Object toObject(ClassLoader classLoader, byte[] value) throws IOException, ClassNotFoundException {
if (value == null) {
return null;
}
CustomObjectInputStream in = new CustomObjectInputStream(new ByteArrayInputStream(value), classLoader);
return in.readObject();
}
}

@ -28,11 +28,6 @@ public class AttributeRemoveMessage extends AttributeMessage {
super();
}
public AttributeRemoveMessage(String sessionId, String name) {
super(sessionId);
this.name = name;
}
public AttributeRemoveMessage(String nodeId, String sessionId, String name) {
super(nodeId, sessionId);
this.name = name;

@ -15,6 +15,8 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
/**
*
* @author Nikita Koksharov
@ -23,29 +25,23 @@ package org.redisson.tomcat;
public class AttributeUpdateMessage extends AttributeMessage {
private String name;
private Object value;
private byte[] value;
public AttributeUpdateMessage() {
}
public AttributeUpdateMessage(String sessionId, String name, Object value) {
super(sessionId);
this.name = name;
this.value = value;
}
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) {
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) throws IOException {
super(nodeId, sessionId);
this.name = name;
this.value = value;
this.value = toByteArray(value);
}
public String getName() {
return name;
}
public Object getValue() {
return value;
public Object getValue(ClassLoader classLoader) throws IOException, ClassNotFoundException {
return toObject(classLoader, value);
}
}

@ -25,10 +25,6 @@ public class AttributesClearMessage extends AttributeMessage {
public AttributesClearMessage() {
}
public AttributesClearMessage(String sessionId) {
super(sessionId);
}
public AttributesClearMessage(String nodeId, String sessionId) {
super(nodeId, sessionId);
}

@ -15,7 +15,10 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
*
@ -24,23 +27,32 @@ import java.util.Map;
*/
public class AttributesPutAllMessage extends AttributeMessage {
private Map<String, Object> attrs;
private Map<String, byte[]> attrs;
public AttributesPutAllMessage() {
}
public AttributesPutAllMessage(String sessionId, Map<String, Object> attrs) {
super(sessionId);
this.attrs = attrs;
}
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) {
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) throws IOException {
super(nodeId, sessionId);
this.attrs = attrs;
if (attrs != null) {
this.attrs = new HashMap<String, byte[]>();
for (Entry<String, Object> entry: attrs.entrySet()) {
this.attrs.put(entry.getKey(), toByteArray(entry.getValue()));
}
} else {
this.attrs = null;
}
}
public Map<String, Object> getAttrs() {
return attrs;
public Map<String, Object> getAttrs(ClassLoader classLoader) throws IOException, ClassNotFoundException {
if (attrs == null) {
return null;
}
Map<String, Object> result = new HashMap<String, Object>();
for (Entry<String, byte[]> entry: attrs.entrySet()) {
result.put(entry.getKey(), toObject(classLoader, entry.getValue()));
}
return result;
}
}

@ -15,6 +15,7 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
@ -132,7 +133,11 @@ public class RedissonSession extends StandardSession {
for (Entry<String, Object> entry : newMap.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
try {
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
@ -148,7 +153,11 @@ public class RedissonSession extends StandardSession {
private void fastPut(String name, Object value) {
map.fastPut(name, value);
if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
try {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}

@ -209,6 +209,13 @@ public class RedissonSessionManager extends ManagerBase {
super.startInternal();
redisson = buildClient();
final ClassLoader applicationClassLoader;
if (Thread.currentThread().getContextClassLoader() != null) {
applicationClassLoader = Thread.currentThread().getContextClassLoader();
} else {
applicationClassLoader = getClass().getClassLoader();
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
getEngine().getPipeline().addValve(new UpdateValve(this));
}
@ -233,17 +240,17 @@ public class RedissonSessionManager extends ManagerBase {
if (msg instanceof AttributesPutAllMessage) {
AttributesPutAllMessage m = (AttributesPutAllMessage) msg;
for (Entry<String, Object> entry : m.getAttrs().entrySet()) {
for (Entry<String, Object> entry : m.getAttrs(applicationClassLoader).entrySet()) {
session.superSetAttribute(entry.getKey(), entry.getValue(), true);
}
}
if (msg instanceof AttributeUpdateMessage) {
AttributeUpdateMessage m = (AttributeUpdateMessage)msg;
session.superSetAttribute(m.getName(), m.getValue(), true);
session.superSetAttribute(m.getName(), m.getValue(applicationClassLoader), true);
}
}
} catch (IOException e) {
} catch (Exception e) {
log.error("Can't handle topic message", e);
}
}

@ -15,8 +15,14 @@
*/
package org.redisson.tomcat;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.apache.catalina.util.CustomObjectInputStream;
/**
*
* @author Nikita Koksharov
@ -31,10 +37,6 @@ public class AttributeMessage implements Serializable {
public AttributeMessage() {
}
public AttributeMessage(String sessionId) {
this.sessionId = sessionId;
}
public AttributeMessage(String nodeId, String sessionId) {
this.nodeId = nodeId;
this.sessionId = sessionId;
@ -48,4 +50,22 @@ public class AttributeMessage implements Serializable {
return nodeId;
}
protected byte[] toByteArray(Object value) throws IOException {
if (value == null) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(value);
out.flush();
return bos.toByteArray();
}
protected Object toObject(ClassLoader classLoader, byte[] value) throws IOException, ClassNotFoundException {
if (value == null) {
return null;
}
CustomObjectInputStream in = new CustomObjectInputStream(new ByteArrayInputStream(value), classLoader);
return in.readObject();
}
}

@ -28,11 +28,6 @@ public class AttributeRemoveMessage extends AttributeMessage {
super();
}
public AttributeRemoveMessage(String sessionId, String name) {
super(sessionId);
this.name = name;
}
public AttributeRemoveMessage(String nodeId, String sessionId, String name) {
super(nodeId, sessionId);
this.name = name;

@ -15,6 +15,8 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
/**
*
* @author Nikita Koksharov
@ -23,29 +25,23 @@ package org.redisson.tomcat;
public class AttributeUpdateMessage extends AttributeMessage {
private String name;
private Object value;
private byte[] value;
public AttributeUpdateMessage() {
}
public AttributeUpdateMessage(String sessionId, String name, Object value) {
super(sessionId);
this.name = name;
this.value = value;
}
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) {
public AttributeUpdateMessage(String nodeId, String sessionId, String name, Object value) throws IOException {
super(nodeId, sessionId);
this.name = name;
this.value = value;
this.value = toByteArray(value);
}
public String getName() {
return name;
}
public Object getValue() {
return value;
public Object getValue(ClassLoader classLoader) throws IOException, ClassNotFoundException {
return toObject(classLoader, value);
}
}

@ -25,10 +25,6 @@ public class AttributesClearMessage extends AttributeMessage {
public AttributesClearMessage() {
}
public AttributesClearMessage(String sessionId) {
super(sessionId);
}
public AttributesClearMessage(String nodeId, String sessionId) {
super(nodeId, sessionId);
}

@ -15,7 +15,10 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
*
@ -24,23 +27,32 @@ import java.util.Map;
*/
public class AttributesPutAllMessage extends AttributeMessage {
private Map<String, Object> attrs;
private Map<String, byte[]> attrs;
public AttributesPutAllMessage() {
}
public AttributesPutAllMessage(String sessionId, Map<String, Object> attrs) {
super(sessionId);
this.attrs = attrs;
}
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) {
public AttributesPutAllMessage(String nodeId, String sessionId, Map<String, Object> attrs) throws IOException {
super(nodeId, sessionId);
this.attrs = attrs;
if (attrs != null) {
this.attrs = new HashMap<String, byte[]>();
for (Entry<String, Object> entry: attrs.entrySet()) {
this.attrs.put(entry.getKey(), toByteArray(entry.getValue()));
}
} else {
this.attrs = null;
}
}
public Map<String, Object> getAttrs() {
return attrs;
public Map<String, Object> getAttrs(ClassLoader classLoader) throws IOException, ClassNotFoundException {
if (attrs == null) {
return null;
}
Map<String, Object> result = new HashMap<String, Object>();
for (Entry<String, byte[]> entry: attrs.entrySet()) {
result.put(entry.getKey(), toObject(classLoader, entry.getValue()));
}
return result;
}
}

@ -15,6 +15,7 @@
*/
package org.redisson.tomcat;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
@ -132,7 +133,11 @@ public class RedissonSession extends StandardSession {
for (Entry<String, Object> entry : newMap.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
try {
return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
@ -148,7 +153,11 @@ public class RedissonSession extends StandardSession {
private void fastPut(String name, Object value) {
map.fastPut(name, value);
if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
try {
topic.publish(new AttributeUpdateMessage(redissonManager.getNodeId(), getId(), name, value));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}

@ -136,7 +136,9 @@ public class RedissonSessionManager extends ManagerBase {
}
public RTopic getTopic() {
return redisson.getTopic("redisson:tomcat_session_updates:" + getContext().getName());
String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
final String name = keyPrefix + separator + "redisson:tomcat_session_updates:" + getContext().getName();
return redisson.getTopic(name);
}
@Override
@ -207,6 +209,13 @@ public class RedissonSessionManager extends ManagerBase {
super.startInternal();
redisson = buildClient();
final ClassLoader applicationClassLoader;
if (Thread.currentThread().getContextClassLoader() != null) {
applicationClassLoader = Thread.currentThread().getContextClassLoader();
} else {
applicationClassLoader = getClass().getClassLoader();
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
getEngine().getPipeline().addValve(new UpdateValve(this));
}
@ -231,17 +240,17 @@ public class RedissonSessionManager extends ManagerBase {
if (msg instanceof AttributesPutAllMessage) {
AttributesPutAllMessage m = (AttributesPutAllMessage) msg;
for (Entry<String, Object> entry : m.getAttrs().entrySet()) {
for (Entry<String, Object> entry : m.getAttrs(applicationClassLoader).entrySet()) {
session.superSetAttribute(entry.getKey(), entry.getValue(), true);
}
}
if (msg instanceof AttributeUpdateMessage) {
AttributeUpdateMessage m = (AttributeUpdateMessage)msg;
session.superSetAttribute(m.getName(), m.getValue(), true);
session.superSetAttribute(m.getName(), m.getValue(applicationClassLoader), true);
}
}
} catch (IOException e) {
} catch (Exception e) {
log.error("Can't handle topic message", e);
}
}

@ -26,9 +26,7 @@ import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.Codec;
import org.redisson.config.Config;
/**
@ -63,15 +61,6 @@ public class JndiRedissonFactory implements ObjectFactory {
}
try {
try {
Config c = new Config(config);
Codec codec = c.getCodec().getClass().getConstructor(ClassLoader.class)
.newInstance(Thread.currentThread().getContextClassLoader());
config.setCodec(codec);
} catch (Exception e) {
throw new IllegalStateException("Unable to initialize codec with ClassLoader parameter", e);
}
return Redisson.create(config);
} catch (Exception e) {
NamingException ex = new NamingException();

@ -147,7 +147,7 @@ public class RedissonBitSet extends RedissonExpirable implements RBitSet {
params.add(getName());
params.add(getName());
params.addAll(Arrays.asList(bitSetNames));
return commandExecutor.writeAsync(getName(), codec, RedisCommands.BITOP, params.toArray());
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.BITOP, params.toArray());
}
@Override
@ -185,7 +185,7 @@ public class RedissonBitSet extends RedissonExpirable implements RBitSet {
@Override
public RFuture<Long> lengthAsync() {
return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_LONG,
return commandExecutor.evalReadAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_LONG,
"local fromBit = redis.call('bitpos', KEYS[1], 1, -1);"
+ "local toBit = 8*(fromBit/8 + 1) - fromBit % 8;"
+ "for i = toBit, fromBit, -1 do "

@ -185,7 +185,7 @@ public class LocalCacheView<K, V> {
if (o instanceof Map.Entry) {
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
CacheKey cacheKey = toCacheKey(e.getKey());
return cache.remove(cacheKey, new CacheValue(e.getKey(), e.getValue()));
return cache.remove(cacheKey) != null;
}
return false;
}

@ -15,8 +15,10 @@
*/
package org.redisson.client.codec;
import org.redisson.cache.LocalCachedMessageCodec;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
import org.redisson.jcache.JCacheEventCodec;
/**
*
@ -25,6 +27,23 @@ import org.redisson.client.protocol.Encoder;
*/
public abstract class BaseCodec implements Codec {
public static Codec copy(ClassLoader classLoader, Codec codec) {
if (codec instanceof StringCodec
|| codec instanceof ByteArrayCodec
|| codec instanceof LocalCachedMessageCodec
|| codec instanceof BitSetCodec
|| codec instanceof JCacheEventCodec
|| codec == null) {
return codec;
}
try {
return codec.getClass().getConstructor(ClassLoader.class, codec.getClass()).newInstance(classLoader, codec);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
@Override
public Decoder<Object> getMapValueDecoder() {
return getValueDecoder();

@ -96,6 +96,10 @@ public class JsonJacksonMapCodec extends JsonJacksonCodec {
public JsonJacksonMapCodec(TypeReference<?> keyTypeReference, TypeReference<?> valueTypeReference, ObjectMapper mapper) {
this(keyTypeReference, valueTypeReference, null, null, mapper);
}
public JsonJacksonMapCodec(ClassLoader classLoader, JsonJacksonMapCodec codec) {
this(codec.keyTypeReference, codec.valueTypeReference, codec.keyClass, codec.valueClass, createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
JsonJacksonMapCodec(TypeReference<?> keyTypeReference, TypeReference<?> valueTypeReference, Class<?> keyClass, Class<?> valueClass, ObjectMapper mapper) {
super(mapper);

@ -81,6 +81,10 @@ public class AvroJacksonCodec extends JsonJacksonCodec {
super(createObjectMapper(classLoader, new ObjectMapper(new AvroFactory())));
}
public AvroJacksonCodec(ClassLoader classLoader, AvroJacksonCodec codec) {
super(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
@Override
protected void initTypeInclusion(ObjectMapper mapObjectMapper) {
}

@ -33,4 +33,8 @@ public class CborJacksonCodec extends JsonJacksonCodec {
super(createObjectMapper(classLoader, new ObjectMapper(new CBORFactory())));
}
public CborJacksonCodec(ClassLoader classLoader, CborJacksonCodec codec) {
super(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
}

@ -15,6 +15,7 @@
*/
package org.redisson.codec;
import org.redisson.client.codec.BaseCodec;
import org.redisson.client.codec.Codec;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
@ -41,6 +42,13 @@ public class CompositeCodec implements Codec {
this.valueCodec = valueCodec;
}
public CompositeCodec(ClassLoader classLoader, CompositeCodec codec) {
super();
this.mapKeyCodec = BaseCodec.copy(classLoader, codec.mapKeyCodec);
this.mapValueCodec = BaseCodec.copy(classLoader, codec.mapValueCodec);
this.valueCodec = BaseCodec.copy(classLoader, codec.valueCodec);
}
@Override
public Decoder<Object> getMapValueDecoder() {
return mapValueCodec.getMapKeyDecoder();
@ -76,4 +84,41 @@ public class CompositeCodec implements Codec {
return getClass().getClassLoader();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((mapKeyCodec == null) ? 0 : mapKeyCodec.hashCode());
result = prime * result + ((mapValueCodec == null) ? 0 : mapValueCodec.hashCode());
result = prime * result + ((valueCodec == null) ? 0 : valueCodec.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CompositeCodec other = (CompositeCodec) obj;
if (mapKeyCodec == null) {
if (other.mapKeyCodec != null)
return false;
} else if (!mapKeyCodec.equals(other.mapKeyCodec))
return false;
if (mapValueCodec == null) {
if (other.mapValueCodec != null)
return false;
} else if (!mapValueCodec.equals(other.mapValueCodec))
return false;
if (valueCodec == null) {
if (other.valueCodec != null)
return false;
} else if (!valueCodec.equals(other.valueCodec))
return false;
return true;
}
}

@ -50,7 +50,27 @@ public class FstCodec extends BaseCodec {
public FstCodec(ClassLoader classLoader) {
this(createConfig(classLoader));
}
public FstCodec(ClassLoader classLoader, FstCodec codec) {
this(copy(classLoader, codec));
}
private static FSTConfiguration copy(ClassLoader classLoader, FstCodec codec) {
FSTConfiguration def = FSTConfiguration.createDefaultConfiguration();
def.setClassLoader(classLoader);
def.setCoderSpecific(codec.config.getCoderSpecific());
def.setCrossPlatform(codec.config.isCrossPlatform());
def.setForceClzInit(codec.config.isForceClzInit());
def.setForceSerializable(codec.config.isForceSerializable());
def.setInstantiator(codec.config.getInstantiator(null));
def.setName(codec.config.getName());
def.setPreferSpeed(codec.config.isPreferSpeed());
def.setShareReferences(codec.config.isShareReferences());
def.setStreamCoderFactory(codec.config.getStreamCoderFactory());
def.setVerifier(codec.config.getVerifier());
return def;
}
private static FSTConfiguration createConfig(ClassLoader classLoader) {
FSTConfiguration def = FSTConfiguration.createDefaultConfiguration();
def.setClassLoader(classLoader);

@ -33,4 +33,8 @@ public class IonJacksonCodec extends JsonJacksonCodec {
super(createObjectMapper(classLoader, new IonObjectMapper()));
}
public IonJacksonCodec(ClassLoader classLoader, IonJacksonCodec codec) {
super(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
}

@ -103,6 +103,10 @@ public class JsonJacksonCodec extends BaseCodec {
public JsonJacksonCodec(ClassLoader classLoader) {
this(createObjectMapper(classLoader, new ObjectMapper()));
}
public JsonJacksonCodec(ClassLoader classLoader, JsonJacksonCodec codec) {
this(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
protected static ObjectMapper createObjectMapper(ClassLoader classLoader, ObjectMapper om) {
TypeFactory tf = TypeFactory.defaultInstance().withClassLoader(classLoader);

@ -49,6 +49,8 @@ public class KryoCodec extends BaseCodec {
void yield(Kryo kryo);
ClassLoader getClassLoader();
List<Class<?>> getClasses();
}
@ -92,6 +94,10 @@ public class KryoCodec extends BaseCodec {
return kryo;
}
public List<Class<?>> getClasses() {
return classes;
}
@Override
public ClassLoader getClassLoader() {
return classLoader;
@ -166,6 +172,10 @@ public class KryoCodec extends BaseCodec {
this(Collections.<Class<?>>emptyList(), classLoader);
}
public KryoCodec(ClassLoader classLoader, KryoCodec codec) {
this(codec.kryoPool.getClasses(), classLoader);
}
public KryoCodec(List<Class<?>> classes) {
this(classes, null);
}

@ -61,6 +61,10 @@ public class LZ4Codec extends BaseCodec {
this(new FstCodec(classLoader));
}
public LZ4Codec(ClassLoader classLoader, LZ4Codec codec) {
this(copy(classLoader, codec.innerCodec));
}
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {

@ -61,6 +61,15 @@ public class MapCacheEventCodec implements Codec {
this.codec = codec;
this.isWindows = isWindows;
}
public MapCacheEventCodec(ClassLoader classLoader, MapCacheEventCodec codec) {
try {
this.codec = codec.codec.getClass().getConstructor(ClassLoader.class, codec.codec.getClass()).newInstance(classLoader, codec.codec);
} catch (Exception e) {
throw new IllegalStateException(e);
}
this.isWindows = codec.isWindows;
}
@Override
public Decoder<Object> getMapValueDecoder() {
@ -109,4 +118,32 @@ public class MapCacheEventCodec implements Codec {
return getClass().getClassLoader();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((codec == null) ? 0 : codec.hashCode());
result = prime * result + (isWindows ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MapCacheEventCodec other = (MapCacheEventCodec) obj;
if (codec == null) {
if (other.codec != null)
return false;
} else if (!codec.equals(other.codec))
return false;
if (isWindows != other.isWindows)
return false;
return true;
}
}

@ -35,4 +35,8 @@ public class MsgPackJacksonCodec extends JsonJacksonCodec {
super(createObjectMapper(classLoader, new ObjectMapper(new MessagePackFactory())));
}
public MsgPackJacksonCodec(ClassLoader classLoader, MsgPackJacksonCodec codec) {
super(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
}

@ -19,7 +19,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.BaseCodec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
@ -34,7 +34,7 @@ import io.netty.buffer.ByteBufOutputStream;
* @author Nikita Koksharov
*
*/
public class SerializationCodec implements Codec {
public class SerializationCodec extends BaseCodec {
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
@ -83,27 +83,11 @@ public class SerializationCodec implements Codec {
public SerializationCodec(ClassLoader classLoader) {
this.classLoader = classLoader;
}
@Override
public Decoder<Object> getMapValueDecoder() {
return getValueDecoder();
}
@Override
public Encoder getMapValueEncoder() {
return getValueEncoder();
}
@Override
public Decoder<Object> getMapKeyDecoder() {
return getValueDecoder();
}
@Override
public Encoder getMapKeyEncoder() {
return getValueEncoder();
public SerializationCodec(ClassLoader classLoader, SerializationCodec codec) {
this.classLoader = classLoader;
}
@Override
public Decoder<Object> getValueDecoder() {
return decoder;

@ -34,4 +34,8 @@ public class SmileJacksonCodec extends JsonJacksonCodec {
super(createObjectMapper(classLoader, new ObjectMapper(new SmileFactory())));
}
public SmileJacksonCodec(ClassLoader classLoader, SmileJacksonCodec codec) {
super(createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
}

@ -65,6 +65,10 @@ public class SnappyCodec extends BaseCodec {
this(new FstCodec(classLoader));
}
public SnappyCodec(ClassLoader classLoader, SnappyCodec codec) {
this(copy(classLoader, codec.innerCodec));
}
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override

@ -55,6 +55,10 @@ public class SnappyCodecV2 extends BaseCodec {
this(new FstCodec(classLoader));
}
public SnappyCodecV2(ClassLoader classLoader, SnappyCodecV2 codec) {
this(copy(classLoader, codec.innerCodec));
}
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override

@ -19,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.redisson.client.codec.JsonJacksonMapCodec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
@ -74,6 +75,14 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
private final Decoder<Object> valueDecoder;
private final Decoder<Object> mapValueDecoder;
private final Decoder<Object> mapKeyDecoder;
private final TypeReference<?> valueTypeReference;
private final TypeReference<?> mapKeyTypeReference;
private final TypeReference<?> mapValueTypeReference;
private final Class<?> valueClass;
private final Class<?> mapKeyClass;
private final Class<?> mapValueClass;
public TypedJsonJacksonCodec(Class<?> valueClass) {
this(valueClass, new ObjectMapper());
@ -122,6 +131,12 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
public TypedJsonJacksonCodec(TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference, ObjectMapper mapper) {
this(valueTypeReference, mapKeyTypeReference, mapValueTypeReference, null, null, null, mapper);
}
public TypedJsonJacksonCodec(ClassLoader classLoader, TypedJsonJacksonCodec codec) {
this(codec.valueTypeReference, codec.mapKeyTypeReference, codec.mapValueTypeReference,
codec.valueClass, codec.mapKeyClass, codec.mapValueClass,
createObjectMapper(classLoader, codec.mapObjectMapper.copy()));
}
TypedJsonJacksonCodec(
TypeReference<?> valueTypeReference, TypeReference<?> mapKeyTypeReference, TypeReference<?> mapValueTypeReference,
@ -130,6 +145,13 @@ public class TypedJsonJacksonCodec extends JsonJacksonCodec {
this.mapValueDecoder = createDecoder(mapValueClass, mapValueTypeReference);
this.mapKeyDecoder = createDecoder(mapKeyClass, mapKeyTypeReference);
this.valueDecoder = createDecoder(valueClass, valueTypeReference);
this.mapValueClass = mapValueClass;
this.mapValueTypeReference = mapValueTypeReference;
this.mapKeyClass = mapKeyClass;
this.mapKeyTypeReference = mapKeyTypeReference;
this.valueClass = valueClass;
this.valueTypeReference = valueTypeReference;
}
@Override

@ -21,11 +21,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -41,6 +43,8 @@ import org.redisson.api.RedissonClient;
import org.redisson.api.RedissonReactiveClient;
import org.redisson.api.RedissonRxClient;
import org.redisson.cache.LRUCacheMap;
import org.redisson.cache.LocalCachedMessageCodec;
import org.redisson.cache.ReferenceCacheMap;
import org.redisson.client.RedisAskException;
import org.redisson.client.RedisClient;
import org.redisson.client.RedisConnection;
@ -52,6 +56,8 @@ import org.redisson.client.RedisResponseTimeoutException;
import org.redisson.client.RedisTimeoutException;
import org.redisson.client.RedisTryAgainException;
import org.redisson.client.WriteRedisConnectionException;
import org.redisson.client.codec.BitSetCodec;
import org.redisson.client.codec.ByteArrayCodec;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.CommandData;
@ -68,6 +74,7 @@ import org.redisson.connection.ConnectionManager;
import org.redisson.connection.MasterSlaveEntry;
import org.redisson.connection.NodeSource;
import org.redisson.connection.NodeSource.Redirect;
import org.redisson.jcache.JCacheEventCodec;
import org.redisson.liveobject.core.RedissonObjectBuilder;
import org.redisson.misc.LogHelper;
import org.redisson.misc.RPromise;
@ -677,12 +684,14 @@ public class CommandAsyncService implements CommandAsyncExecutor {
return;
}
Codec codecToUse = getCodec(codec);
final AsyncDetails<V, R> details = AsyncDetails.acquire();
final RFuture<RedisConnection> connectionFuture = getConnection(readOnlyMode, source, command);
final RPromise<R> attemptPromise = new RedissonPromise<R>();
details.init(connectionFuture, attemptPromise,
readOnlyMode, source, codec, command, params, mainPromise, attempt);
readOnlyMode, source, codecToUse, command, params, mainPromise, attempt);
FutureListener<R> mainPromiseListener = new FutureListener<R>() {
@Override
@ -816,7 +825,48 @@ public class CommandAsyncService implements CommandAsyncExecutor {
}
});
}
private static final Map<ClassLoader, Map<Codec, Codec>> codecs = ReferenceCacheMap.weak(0, 0);
protected Codec getCodec(Codec codec) {
if (codec instanceof StringCodec
|| codec instanceof ByteArrayCodec
|| codec instanceof LocalCachedMessageCodec
|| codec instanceof BitSetCodec
|| codec instanceof JCacheEventCodec
|| codec == null) {
return codec;
}
Codec codecToUse = codec;
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
if (threadClassLoader != null) {
Map<Codec, Codec> map = codecs.get(threadClassLoader);
if (map == null) {
synchronized (codecs) {
map = codecs.get(threadClassLoader);
if (map == null) {
map = new ConcurrentHashMap<Codec, Codec>();
codecs.put(threadClassLoader, map);
}
}
}
codecToUse = map.get(codec);
if (codecToUse == null) {
try {
codecToUse = codec.getClass().getConstructor(ClassLoader.class, codec.getClass()).newInstance(threadClassLoader, codec);
} catch (NoSuchMethodException e) {
codecToUse = codec;
// skip
} catch (Exception e) {
throw new IllegalStateException(e);
}
map.put(codec, codecToUse);
}
}
return codecToUse;
}
protected <V> RFuture<RedisConnection> getConnection(final boolean readOnlyMode, final NodeSource source,
final RedisCommand<V> command) {
final RFuture<RedisConnection> connectionFuture;

@ -172,7 +172,8 @@ public class CommandBatchService extends CommandAsyncService {
if (!isRedisBasedQueue()) {
batchParams = params;
}
BatchCommandData<V, R> commandData = new BatchCommandData<V, R>(mainPromise, codec, command, batchParams, index.incrementAndGet());
Codec codecToUse = getCodec(codec);
BatchCommandData<V, R> commandData = new BatchCommandData<V, R>(mainPromise, codecToUse, command, batchParams, index.incrementAndGet());
entry.getCommands().add(commandData);
}

@ -281,10 +281,10 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
RLocalCachedMap<String, String> map = redisson.getLocalCachedMap("test", options);
map.put("1", "11");
map.put("2", "22");
assertThat(map.cachedKeySet()).containsExactly("1", "2");
assertThat(map.cachedKeySet()).containsExactlyInAnyOrder("1", "2");
assertThat(map.cachedValues()).containsExactlyInAnyOrder("11", "22");
assertThat(map.getCachedMap().keySet()).containsExactly("1", "2");
assertThat(map.getCachedMap().values()).containsExactly("11", "22");
assertThat(map.getCachedMap().keySet()).containsExactlyInAnyOrder("1", "2");
assertThat(map.getCachedMap().values()).containsExactlyInAnyOrder("11", "22");
}

Loading…
Cancel
Save