Browse Source
Merge remote-tracking branch 'origin/lts-4.2' into lts-4.3
pull/15455/head
Viacheslav Klimov
1 month ago
Failed to extract signature
2 changed files with
12 additions and
1 deletions
-
common/cache/src/main/java/org/thingsboard/server/cache/TbJsonRedisSerializer.java
-
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeTest.java
|
|
|
@ -18,6 +18,8 @@ package org.thingsboard.server.cache; |
|
|
|
import org.springframework.data.redis.serializer.SerializationException; |
|
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
public class TbJsonRedisSerializer<K, V> implements TbRedisSerializer<K, V> { |
|
|
|
|
|
|
|
private final Class<V> clazz; |
|
|
|
@ -33,6 +35,13 @@ public class TbJsonRedisSerializer<K, V> implements TbRedisSerializer<K, V> { |
|
|
|
|
|
|
|
@Override |
|
|
|
public V deserialize(K key, byte[] bytes) throws SerializationException { |
|
|
|
return JacksonUtil.fromBytes(bytes, clazz); |
|
|
|
if (bytes == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
try { |
|
|
|
return JacksonUtil.IGNORE_UNKNOWN_PROPERTIES_JSON_MAPPER.readValue(bytes, clazz); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new SerializationException("Failed to deserialize cached value", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -27,6 +27,7 @@ import org.apache.http.protocol.HttpRequestHandler; |
|
|
|
import org.junit.jupiter.api.AfterEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.junit.jupiter.api.parallel.ResourceLock; |
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.ValueSource; |
|
|
|
@ -70,6 +71,7 @@ import static org.mockito.Mockito.timeout; |
|
|
|
import static org.mockito.Mockito.verify; |
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
@ResourceLock("SsrfProtectionValidator") // to avoid race conditions when modifying SsrfProtectionValidator's static configuration
|
|
|
|
public class TbRestApiCallNodeTest extends AbstractRuleNodeUpgradeTest { |
|
|
|
|
|
|
|
static final long TIMEOUT = TimeUnit.SECONDS.toMillis(30); |
|
|
|
|