Skip to content

Commit 623060f

Browse files
committed
Fix a couple of compiler warnings that made sense
1 parent e06cc00 commit 623060f

File tree

7 files changed

+22
-40
lines changed

7 files changed

+22
-40
lines changed

sdk-common/src/main/java/dev/restate/sdk/common/CoreSerdes.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ public byte[] deserialize(byte[] value) {
105105
boxedN -> {
106106
int n = boxedN;
107107
byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE];
108-
encodedValue[3] = (byte) (n >> Byte.SIZE * 3);
109-
encodedValue[2] = (byte) (n >> Byte.SIZE * 2);
108+
encodedValue[3] = (byte) (n >> (Byte.SIZE * 3));
109+
encodedValue[2] = (byte) (n >> (Byte.SIZE * 2));
110110
encodedValue[1] = (byte) (n >> Byte.SIZE);
111111
encodedValue[0] = (byte) n;
112112
return encodedValue;
113113
},
114114
encodedValue -> {
115115
int n = 0;
116-
n |= (encodedValue[3] & 0xFF) << Byte.SIZE * 3;
117-
n |= (encodedValue[2] & 0xFF) << Byte.SIZE * 2;
116+
n |= (encodedValue[3] & 0xFF) << (Byte.SIZE * 3);
117+
n |= (encodedValue[2] & 0xFF) << (Byte.SIZE * 2);
118118
n |= (encodedValue[1] & 0xFF) << Byte.SIZE;
119119
n |= encodedValue[0] & 0xFF;
120120
return n;
@@ -125,24 +125,24 @@ public byte[] deserialize(byte[] value) {
125125
boxedN -> {
126126
long n = boxedN;
127127
byte[] encodedValue = new byte[Long.SIZE / Byte.SIZE];
128-
encodedValue[7] = (byte) (n >> Byte.SIZE * 7);
129-
encodedValue[6] = (byte) (n >> Byte.SIZE * 6);
130-
encodedValue[5] = (byte) (n >> Byte.SIZE * 5);
131-
encodedValue[4] = (byte) (n >> Byte.SIZE * 4);
132-
encodedValue[3] = (byte) (n >> Byte.SIZE * 3);
133-
encodedValue[2] = (byte) (n >> Byte.SIZE * 2);
128+
encodedValue[7] = (byte) (n >> (Byte.SIZE * 7));
129+
encodedValue[6] = (byte) (n >> (Byte.SIZE * 6));
130+
encodedValue[5] = (byte) (n >> (Byte.SIZE * 5));
131+
encodedValue[4] = (byte) (n >> (Byte.SIZE * 4));
132+
encodedValue[3] = (byte) (n >> (Byte.SIZE * 3));
133+
encodedValue[2] = (byte) (n >> (Byte.SIZE * 2));
134134
encodedValue[1] = (byte) (n >> Byte.SIZE);
135135
encodedValue[0] = (byte) n;
136136
return encodedValue;
137137
},
138138
encodedValue -> {
139139
long n = 0;
140-
n |= ((long) (encodedValue[7] & 0xFF) << Byte.SIZE * 7);
141-
n |= ((long) (encodedValue[6] & 0xFF) << Byte.SIZE * 6);
142-
n |= ((long) (encodedValue[5] & 0xFF) << Byte.SIZE * 5);
143-
n |= ((long) (encodedValue[4] & 0xFF) << Byte.SIZE * 4);
144-
n |= ((long) (encodedValue[3] & 0xFF) << Byte.SIZE * 3);
145-
n |= ((encodedValue[2] & 0xFF) << Byte.SIZE * 2);
140+
n |= ((long) (encodedValue[7] & 0xFF) << (Byte.SIZE * 7));
141+
n |= ((long) (encodedValue[6] & 0xFF) << (Byte.SIZE * 6));
142+
n |= ((long) (encodedValue[5] & 0xFF) << (Byte.SIZE * 5));
143+
n |= ((long) (encodedValue[4] & 0xFF) << (Byte.SIZE * 4));
144+
n |= ((long) (encodedValue[3] & 0xFF) << (Byte.SIZE * 3));
145+
n |= ((encodedValue[2] & 0xFF) << (Byte.SIZE * 2));
146146
n |= ((encodedValue[1] & 0xFF) << Byte.SIZE);
147147
n |= (encodedValue[0] & 0xFF);
148148
return n;

sdk-lambda/src/test/java/dev/restate/sdk/lambda/LambdaHandlerTest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.protobuf.MessageLite;
2323
import dev.restate.generated.service.discovery.Discovery;
2424
import dev.restate.generated.service.protocol.Protocol;
25-
import dev.restate.sdk.core.MessageHeader;
2625
import dev.restate.sdk.core.ProtoUtils;
2726
import dev.restate.sdk.lambda.testservices.CounterRequest;
2827
import dev.restate.sdk.lambda.testservices.JavaCounterGrpc;
@@ -127,23 +126,6 @@ private static byte[] serializeEntries(MessageLite... msgs) throws IOException {
127126
return outputStream.toByteArray();
128127
}
129128

130-
private static List<MessageLite> deserializeEntries(byte[] array) throws IOException {
131-
List<MessageLite> msgs = new ArrayList<>();
132-
ByteBuffer buffer = ByteBuffer.wrap(array);
133-
while (buffer.hasRemaining()) {
134-
MessageHeader header = MessageHeader.parse(buffer.getLong());
135-
136-
// Prepare the ByteBuffer and pass it to the Protobuf message parser
137-
ByteBuffer messageBuffer = buffer.slice();
138-
messageBuffer.limit(header.getLength());
139-
msgs.add(header.getType().messageParser().parseFrom(messageBuffer));
140-
141-
// Move the buffer after this message
142-
buffer.position(buffer.position() + header.getLength());
143-
}
144-
return msgs;
145-
}
146-
147129
private Context mockContext() {
148130
return new Context() {
149131
@Override

sdk-lambda/src/test/java/dev/restate/sdk/lambda/testservices/JavaCounterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class JavaCounterService extends JavaCounterGrpc.JavaCounterImplBase
2626

2727
@Override
2828
public void get(CounterRequest request, StreamObserver<GetResponse> responseObserver) {
29-
var count = restateContext().get(COUNTER).orElse(0L) + 1;
29+
restateContext().get(COUNTER);
3030

3131
throw new IllegalStateException("We shouldn't reach this point");
3232
}

sdk-lambda/src/test/kotlin/dev/restate/sdk/lambda/testservices/KotlinCounterService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class KotlinCounterService :
1616
RestateKtService {
1717

1818
override suspend fun get(request: CounterRequest): GetResponse {
19-
val count = (restateContext().get(JavaCounterService.COUNTER) ?: 0) + 1
19+
(restateContext().get(JavaCounterService.COUNTER) ?: 0) + 1
2020

2121
throw IllegalStateException("We shouldn't reach this point")
2222
}

sdk-testing/src/main/java/dev/restate/sdk/testing/BaseRestateRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public boolean supportsParameter(
3232
|| (parameterContext.isAnnotated(RestateGrpcChannel.class)
3333
&& ManagedChannel.class.isAssignableFrom(parameterContext.getParameter().getType()))
3434
|| (parameterContext.isAnnotated(RestateURL.class)
35-
&& String.class.isAssignableFrom(parameterContext.getParameter().getType())
36-
|| URL.class.isAssignableFrom(parameterContext.getParameter().getType()));
35+
&& (String.class.isAssignableFrom(parameterContext.getParameter().getType())
36+
|| URL.class.isAssignableFrom(parameterContext.getParameter().getType())));
3737
}
3838

3939
@Override

sdk-testing/src/main/java/dev/restate/sdk/testing/ManualRestateRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void stop() {
162162
public void close() {
163163
runtimeContainer.stop();
164164
LOG.debug("Stopped Restate container");
165-
server.close().toCompletionStage().toCompletableFuture();
165+
server.close().toCompletionStage().toCompletableFuture().join();
166166
LOG.debug("Stopped Embedded Service endpoint server");
167167
}
168168

sdk-testing/src/test/java/dev/restate/sdk/testing/CounterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class CounterTest {
2121

2222
@RegisterExtension
23-
private static final RestateRunner restateRunner =
23+
private static final RestateRunner RESTATE_RUNNER =
2424
RestateRunnerBuilder.create()
2525
.withRestateContainerImage(
2626
"ghcr.io/restatedev/restate:main") // test against the latest main Restate image

0 commit comments

Comments
 (0)