Skip to content

Commit 3a5fe38

Browse files
committed
supports JDK8 (#70)
* implement support for jdk8 * update docs * update ci * remove pid feature * fix unit tests fail
1 parent 27e3afa commit 3a5fe38

File tree

23 files changed

+41
-14
lines changed

23 files changed

+41
-14
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- uses: actions/checkout@v2
1414
with:
1515
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16-
- name: Set up JDK 11
16+
- name: Set up JDK 8
1717
uses: actions/setup-java@v1
1818
with:
19-
java-version: 11
19+
java-version: 8
2020
- name: Cache SonarCloud packages
2121
uses: actions/cache@v1
2222
with:

config/src/main/java/com/keva/config/ConfigLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public final class ConfigLoader {
1515
public static final String DEFAULT_FILE_PATH = Paths.get(".", "keva.properties").toString();
1616

1717
public static <T> T loadConfig(String[] args, Class<T> clazz) throws IOException {
18-
var returnConf = ConfigLoaderUtil.fromProperties(new Properties(), clazz);
18+
T returnConf = ConfigLoaderUtil.fromProperties(new Properties(), clazz);
1919
val config = ArgsParser.parse(args);
2020
val overrider = ConfigLoaderUtil.fromArgs(config, clazz);
2121

config/src/test/java/com/keva/config/ArgsParserTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import static org.junit.jupiter.api.Assertions.assertEquals;
77
import static org.junit.jupiter.api.Assertions.assertNull;
88

9+
import lombok.var;
10+
911
class ArgsParserTest {
1012

1113
@Test

core/src/main/java/dev/keva/core/command/impl/key/Del.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import dev.keva.protocol.resp.reply.IntegerReply;
1111
import dev.keva.store.KevaDatabase;
1212

13+
import lombok.var;
14+
1315
import static dev.keva.core.command.annotation.ParamLength.Type.AT_LEAST;
1416

1517
@Component

core/src/main/java/dev/keva/core/command/impl/key/Exists.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import dev.keva.protocol.resp.reply.Reply;
1010
import dev.keva.store.KevaDatabase;
1111

12+
import lombok.var;
13+
1214
import static dev.keva.core.command.annotation.ParamLength.Type.AT_LEAST;
1315

1416
@Component

core/src/main/java/dev/keva/core/command/impl/key/Expire.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import java.nio.charset.StandardCharsets;
1212

13+
import lombok.val;
14+
1315
@Component
1416
@CommandImpl("expire")
1517
@ParamLength(2)
@@ -24,7 +26,7 @@ public Expire(ExpirationManager expirationManager) {
2426
@Execute
2527
public IntegerReply execute(byte[] key, byte[] after) {
2628
try {
27-
var afterInMillis = Long.parseLong(new String(after, StandardCharsets.UTF_8));
29+
val afterInMillis = Long.parseLong(new String(after, StandardCharsets.UTF_8));
2830
expirationManager.expireAfter(key, afterInMillis);
2931
return new IntegerReply(1);
3032
} catch (Exception ignore) {

core/src/main/java/dev/keva/core/command/impl/key/ExpireAt.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import java.nio.charset.StandardCharsets;
1212

13+
import lombok.val;
14+
1315
@Component
1416
@CommandImpl("expireat")
1517
@ParamLength(2)
@@ -24,7 +26,7 @@ public ExpireAt(ExpirationManager expirationManager) {
2426
@Execute
2527
public IntegerReply execute(byte[] key, byte[] at) {
2628
try {
27-
var atInMillis = Long.parseLong(new String(at, StandardCharsets.UTF_8));
29+
val atInMillis = Long.parseLong(new String(at, StandardCharsets.UTF_8));
2830
expirationManager.expireAt(key, atInMillis);
2931
return new IntegerReply(1);
3032
} catch (Exception ignore) {

core/src/main/java/dev/keva/core/command/impl/key/Incrby.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import java.nio.charset.StandardCharsets;
1414

15+
import lombok.var;
16+
1517
import static dev.keva.core.command.annotation.ParamLength.Type.EXACT;
1618

1719
@Component

core/src/main/java/dev/keva/core/command/impl/pubsub/Publish.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import dev.keva.protocol.resp.reply.Reply;
1313
import io.netty.channel.Channel;
1414
import lombok.val;
15+
import lombok.var;
1516

1617
import java.util.Set;
1718

core/src/main/java/dev/keva/core/command/impl/pubsub/Subscribe.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.netty.channel.Channel;
1414
import io.netty.channel.ChannelHandlerContext;
1515
import lombok.val;
16+
import lombok.var;
1617

1718
import java.util.Set;
1819
import java.util.concurrent.ConcurrentHashMap;

core/src/main/java/dev/keva/core/command/impl/pubsub/Unsubscribe.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.netty.channel.Channel;
1313
import io.netty.channel.ChannelHandlerContext;
1414
import lombok.val;
15+
import lombok.var;
1516

1617
import java.util.Set;
1718
import java.util.concurrent.ConcurrentHashMap;

core/src/main/java/dev/keva/core/command/impl/transaction/Discard.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import dev.keva.protocol.resp.reply.StatusReply;
1010
import io.netty.channel.ChannelHandlerContext;
1111

12+
import lombok.val;
13+
1214
@Component
1315
@CommandImpl("discard")
1416
@ParamLength(0)
@@ -22,7 +24,7 @@ public Discard(TransactionManager manager) {
2224

2325
@Execute
2426
public StatusReply execute(ChannelHandlerContext ctx) {
25-
var txContext = manager.getTransactions().get(ctx.channel());
27+
val txContext = manager.getTransactions().get(ctx.channel());
2628
if (txContext != null) {
2729
txContext.discard();
2830
}

core/src/main/java/dev/keva/core/command/impl/transaction/Exec.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import dev.keva.store.KevaDatabase;
1111
import io.netty.channel.ChannelHandlerContext;
1212

13+
import lombok.val;
14+
1315
import static dev.keva.protocol.resp.reply.BulkReply.NIL_REPLY;
1416

1517
@Component
@@ -27,7 +29,7 @@ public Exec(TransactionManager manager, KevaDatabase database) {
2729

2830
@Execute
2931
public Reply<?> execute(ChannelHandlerContext ctx) throws InterruptedException {
30-
var txContext = manager.getTransactions().get(ctx.channel());
32+
val txContext = manager.getTransactions().get(ctx.channel());
3133
if (txContext == null) {
3234
return NIL_REPLY;
3335
}

core/src/main/java/dev/keva/core/command/impl/transaction/Multi.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import dev.keva.store.KevaDatabase;
1313
import io.netty.channel.ChannelHandlerContext;
1414

15+
import lombok.var;
16+
1517
@Component
1618
@CommandImpl("multi")
1719
@ParamLength(0)

core/src/main/java/dev/keva/core/command/impl/transaction/Unwatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Unwatch(TransactionManager manager) {
2222

2323
@Execute
2424
public StatusReply execute(ChannelHandlerContext ctx, byte[]... keys) {
25-
var txContext = manager.getTransactions().get(ctx.channel());
25+
val txContext = manager.getTransactions().get(ctx.channel());
2626
if (txContext != null) {
2727
if (keys.length == 0) {
2828
txContext.getWatchMap().clear();

core/src/main/java/dev/keva/core/command/impl/transaction/Watch.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import dev.keva.store.KevaDatabase;
1515
import io.netty.channel.ChannelHandlerContext;
1616
import lombok.val;
17+
import lombok.var;
1718

1819
import static dev.keva.core.command.annotation.ParamLength.Type.AT_LEAST;
1920

core/src/main/java/dev/keva/core/command/impl/transaction/manager/TransactionContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.netty.channel.ChannelHandlerContext;
1111
import lombok.Getter;
1212
import lombok.val;
13+
import lombok.var;
1314

1415
import java.util.*;
1516
import java.util.concurrent.locks.Lock;

core/src/main/java/dev/keva/core/server/KevaServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ public void run() {
103103
aofManager.init();
104104

105105
val sync = server.bind(config.getPort()).sync();
106-
log.info("{} server started at {}:{}, PID: {}, in {} ms",
106+
log.info("{} server started at {}:{}, in {} ms",
107107
KEVA_BANNER,
108108
config.getHostname(), config.getPort(),
109-
ProcessHandle.current().pid(),
110109
stopwatch.elapsed(TimeUnit.MILLISECONDS));
111110
log.info("Ready to accept connections");
112111

core/src/test/java/dev/keva/core/server/AbstractServerTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import redis.clients.jedis.exceptions.JedisDataException;
99

1010
import java.util.Arrays;
11+
import java.util.Collections;
1112
import java.util.concurrent.CompletableFuture;
1213
import java.util.concurrent.ExecutionException;
1314

15+
import lombok.var;
16+
1417
import static org.junit.jupiter.api.Assertions.*;
1518

1619
public abstract class AbstractServerTest {
@@ -245,7 +248,7 @@ void setAfterExpireAt() {
245248
void getSetLongString() {
246249
try {
247250
final int aKB = 1024;
248-
String testStr = "a".repeat(Math.max(0, aKB));
251+
String testStr = String.join("", Collections.nCopies(aKB, "a"));
249252
String setAbc = jedis.set("abc", testStr);
250253
String getAbc = jedis.get("abc");
251254
assertEquals("OK", setAbc);
@@ -260,7 +263,7 @@ void getSetLongString() {
260263
void getSetLongKeyString() {
261264
try {
262265
final int aKB = 1026;
263-
final String testStr = "a".repeat(Math.max(0, aKB));
266+
final String testStr = String.join("", Collections.nCopies(aKB, "a"));
264267
final String setAbc = jedis.set(testStr, "123");
265268
final String getAbc = jedis.get(testStr);
266269
assertEquals("OK", setAbc);

docs/src/guide/developer-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Build requirements
44

5-
- [OpenJDK 11](https://openjdk.java.net/projects/jdk/11/)
5+
- [JDK 8](https://openjdk.java.net/install/)
66
- Consider using [Jabba](https://github.com/shyiko/jabba) for convenient installation of JDK.
77

88
## How to build

docs/src/guide/overview/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Requirements
44

55
- Linux/macOS environment
6-
- Java 11 (JDK/JRE 11) or higher
6+
- Java 8 (JDK/JRE 8) or higher
77

88
## Download
99

store/src/main/java/dev/keva/store/impl/OffHeapDatabaseImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import lombok.Getter;
99
import lombok.extern.slf4j.Slf4j;
1010
import lombok.val;
11+
import lombok.var;
1112
import net.openhft.chronicle.map.ChronicleMap;
1213
import net.openhft.chronicle.map.ChronicleMapBuilder;
1314
import org.apache.commons.lang3.SerializationUtils;

store/src/main/java/dev/keva/store/impl/OnHeapDatabaseImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dev.keva.store.lock.SpinLock;
77
import lombok.Getter;
88
import lombok.val;
9+
import lombok.var;
910
import org.apache.commons.lang3.SerializationUtils;
1011

1112
import java.nio.charset.StandardCharsets;

0 commit comments

Comments
 (0)