Resolve ClusterLuaScript warnings/suggestions
This commit is contained in:
parent
2383aaaa3d
commit
863969c77c
|
@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ClusterLuaScript {
|
public class ClusterLuaScript {
|
||||||
|
@ -33,17 +34,14 @@ public class ClusterLuaScript {
|
||||||
final String resource,
|
final String resource,
|
||||||
final ScriptOutputType scriptOutputType) throws IOException {
|
final ScriptOutputType scriptOutputType) throws IOException {
|
||||||
|
|
||||||
try (final InputStream inputStream = LuaScript.class.getClassLoader().getResourceAsStream(resource);
|
try (final InputStream inputStream = LuaScript.class.getClassLoader().getResourceAsStream(resource)) {
|
||||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
if (inputStream == null) {
|
||||||
|
throw new IllegalArgumentException("Script not found: " + resource);
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
int read;
|
|
||||||
|
|
||||||
while ((read = inputStream.read(buffer)) != -1) {
|
|
||||||
baos.write(buffer, 0, read);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ClusterLuaScript(redisCluster, new String(baos.toByteArray()), scriptOutputType);
|
return new ClusterLuaScript(redisCluster,
|
||||||
|
new String(inputStream.readAllBytes(), StandardCharsets.UTF_8),
|
||||||
|
scriptOutputType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +49,7 @@ public class ClusterLuaScript {
|
||||||
ClusterLuaScript(final FaultTolerantRedisCluster redisCluster,
|
ClusterLuaScript(final FaultTolerantRedisCluster redisCluster,
|
||||||
final String script,
|
final String script,
|
||||||
final ScriptOutputType scriptOutputType) {
|
final ScriptOutputType scriptOutputType) {
|
||||||
|
|
||||||
this.redisCluster = redisCluster;
|
this.redisCluster = redisCluster;
|
||||||
this.scriptOutputType = scriptOutputType;
|
this.scriptOutputType = scriptOutputType;
|
||||||
this.script = script;
|
this.script = script;
|
||||||
|
|
Loading…
Reference in New Issue