Skip to content

Commit

Permalink
A lot of small linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Jun 3, 2024
1 parent 8f90998 commit 41d57f2
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ build
.classpath
.factorypath
kls_database.db
.kotlin
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ public String getSerdeDecl() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

if (!(o instanceof PayloadType)) return false;
PayloadType that = (PayloadType) o;

if (isEmpty != that.isEmpty) return false;
if (!Objects.equals(name, that.name)) return false;
if (!Objects.equals(boxed, that.boxed)) return false;
return Objects.equals(serdeDecl, that.serdeDecl);
return isEmpty == that.isEmpty
&& Objects.equals(name, that.name)
&& Objects.equals(boxed, that.boxed)
&& Objects.equals(serdeDecl, that.serdeDecl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private Handler fromExecutableElement(ServiceType serviceType, ExecutableElement
? HandlerType.SHARED
: isAnnotatedWithExclusive
? HandlerType.EXCLUSIVE
: defaultHandlerType(serviceType, element);
: defaultHandlerType(serviceType);

validateMethodSignature(serviceType, handlerType, element);

Expand All @@ -206,7 +206,7 @@ private Handler fromExecutableElement(ServiceType serviceType, ExecutableElement
}
}

private HandlerType defaultHandlerType(ServiceType serviceType, ExecutableElement element) {
private HandlerType defaultHandlerType(ServiceType serviceType) {
switch (serviceType) {
case SERVICE:
return HandlerType.STATELESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class KElementConverter(
if (isAnnotatedWithShared) HandlerType.SHARED
else if (isAnnotatedWithExclusive) HandlerType.EXCLUSIVE
else if (isAnnotatedWithWorkflow) HandlerType.WORKFLOW
else defaultHandlerType(data.serviceType, function)
else defaultHandlerType(data.serviceType)
handlerBuilder.withHandlerType(handlerType)

validateMethodSignature(data.serviceType, handlerType, function)
Expand Down Expand Up @@ -258,7 +258,7 @@ class KElementConverter(
")")
}

private fun defaultHandlerType(serviceType: ServiceType, node: KSNode): HandlerType {
private fun defaultHandlerType(serviceType: ServiceType): HandlerType {
when (serviceType) {
ServiceType.SERVICE -> return HandlerType.STATELESS
ServiceType.VIRTUAL_OBJECT -> return HandlerType.EXCLUSIVE
Expand Down
1 change: 1 addition & 0 deletions sdk-api/src/test/java/dev/restate/sdk/AwakeableIdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public class AwakeableIdTest extends AwakeableIdTestSuite {

@Override
protected TestInvocationBuilder returnAwakeableId() {
return testDefinitionForService(
"ReturnAwakeableId",
Expand Down
8 changes: 8 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/DeferredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

public class DeferredTest extends DeferredTestSuite {

@Override
protected TestInvocationBuilder reverseAwaitOrder() {
return testDefinitionForVirtualObject(
"ReverseAwaitOrder",
Expand All @@ -37,6 +38,7 @@ protected TestInvocationBuilder reverseAwaitOrder() {
});
}

@Override
protected TestInvocationBuilder awaitTwiceTheSameAwaitable() {
return testDefinitionForService(
"AwaitTwiceTheSameAwaitable",
Expand All @@ -49,6 +51,7 @@ protected TestInvocationBuilder awaitTwiceTheSameAwaitable() {
});
}

@Override
protected TestInvocationBuilder awaitAll() {
return testDefinitionForService(
"AwaitAll",
Expand All @@ -64,6 +67,7 @@ protected TestInvocationBuilder awaitAll() {
});
}

@Override
protected TestInvocationBuilder awaitAny() {
return testDefinitionForService(
"AwaitAny",
Expand All @@ -77,6 +81,7 @@ protected TestInvocationBuilder awaitAny() {
});
}

@Override
protected TestInvocationBuilder combineAnyWithAll() {
return testDefinitionForService(
"CombineAnyWithAll",
Expand All @@ -97,6 +102,7 @@ protected TestInvocationBuilder combineAnyWithAll() {
});
}

@Override
protected TestInvocationBuilder awaitAnyIndex() {
return testDefinitionForService(
"AwaitAnyIndex",
Expand All @@ -112,6 +118,7 @@ protected TestInvocationBuilder awaitAnyIndex() {
});
}

@Override
protected TestInvocationBuilder awaitOnAlreadyResolvedAwaitables() {
return testDefinitionForService(
"AwaitOnAlreadyResolvedAwaitables",
Expand All @@ -132,6 +139,7 @@ protected TestInvocationBuilder awaitOnAlreadyResolvedAwaitables() {
});
}

@Override
protected TestInvocationBuilder awaitWithTimeout() {
return testDefinitionForService(
"AwaitWithTimeout",
Expand Down
6 changes: 6 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/EagerStateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

public class EagerStateTest extends EagerStateTestSuite {

@Override
protected TestInvocationBuilder getEmpty() {
return testDefinitionForVirtualObject(
"GetEmpty",
Expand All @@ -27,6 +28,7 @@ protected TestInvocationBuilder getEmpty() {
String.valueOf(ctx.get(StateKey.of("STATE", JsonSerdes.STRING)).isEmpty()));
}

@Override
protected TestInvocationBuilder get() {
return testDefinitionForVirtualObject(
"GetEmpty",
Expand All @@ -35,6 +37,7 @@ protected TestInvocationBuilder get() {
(ctx, unused) -> ctx.get(StateKey.of("STATE", JsonSerdes.STRING)).get());
}

@Override
protected TestInvocationBuilder getAppendAndGet() {
return testDefinitionForVirtualObject(
"GetAppendAndGet",
Expand All @@ -48,6 +51,7 @@ protected TestInvocationBuilder getAppendAndGet() {
});
}

@Override
protected TestInvocationBuilder getClearAndGet() {
return testDefinitionForVirtualObject(
"GetClearAndGet",
Expand All @@ -62,6 +66,7 @@ protected TestInvocationBuilder getClearAndGet() {
});
}

@Override
protected TestInvocationBuilder getClearAllAndGet() {
return testDefinitionForVirtualObject(
"GetClearAllAndGet",
Expand All @@ -78,6 +83,7 @@ protected TestInvocationBuilder getClearAllAndGet() {
});
}

@Override
protected TestInvocationBuilder listKeys() {
return testDefinitionForVirtualObject(
"ListKeys",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public class InvocationIdTest extends InvocationIdTestSuite {

@Override
protected TestInvocationBuilder returnInvocationId() {
return testDefinitionForService(
"ReturnInvocationId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

public class OnlyInputAndOutputTest extends OnlyInputAndOutputTestSuite {

@Override
protected TestDefinitions.TestInvocationBuilder noSyscallsGreeter() {
return testDefinitionForService(
"NoSyscallsGreeter",
Expand Down
3 changes: 3 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/RandomTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class RandomTest extends RandomTestSuite {

@Override
protected TestInvocationBuilder randomShouldBeDeterministic() {
return testDefinitionForService(
"RandomShouldBeDeterministic",
Expand All @@ -25,6 +26,7 @@ protected TestInvocationBuilder randomShouldBeDeterministic() {
(ctx, unused) -> ctx.random().nextInt());
}

@Override
protected TestInvocationBuilder randomInsideSideEffect() {
return testDefinitionForService(
"RandomInsideSideEffect",
Expand All @@ -36,6 +38,7 @@ protected TestInvocationBuilder randomInsideSideEffect() {
});
}

@Override
protected int getExpectedInt(long seed) {
return new Random(seed).nextInt();
}
Expand Down
2 changes: 2 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/SleepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

public class SleepTest extends SleepTestSuite {

@Override
protected TestInvocationBuilder sleepGreeter() {
return testDefinitionForService(
"SleepGreeter",
Expand All @@ -30,6 +31,7 @@ protected TestInvocationBuilder sleepGreeter() {
});
}

@Override
protected TestInvocationBuilder manySleeps() {
return testDefinitionForService(
"ManySleeps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class StateMachineFailuresTest extends StateMachineFailuresTestSuite {
i -> Integer.toString(i).getBytes(StandardCharsets.UTF_8),
b -> Integer.parseInt(new String(b, StandardCharsets.UTF_8))));

@Override
protected TestInvocationBuilder getState(AtomicInteger nonTerminalExceptionsSeen) {
return testDefinitionForVirtualObject(
"GetState",
Expand All @@ -49,6 +50,7 @@ protected TestInvocationBuilder getState(AtomicInteger nonTerminalExceptionsSeen
});
}

@Override
protected TestInvocationBuilder sideEffectFailure(Serde<Integer> serde) {
return testDefinitionForVirtualObject(
"SideEffectFailure",
Expand Down
3 changes: 3 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/StateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class StateTest extends StateTestSuite {

@Override
protected TestInvocationBuilder getState() {
return testDefinitionForVirtualObject(
"GetState",
Expand All @@ -29,6 +30,7 @@ protected TestInvocationBuilder getState() {
});
}

@Override
protected TestInvocationBuilder getAndSetState() {
return testDefinitionForVirtualObject(
"GetState",
Expand All @@ -43,6 +45,7 @@ protected TestInvocationBuilder getAndSetState() {
});
}

@Override
protected TestInvocationBuilder setNullState() {
return testDefinitionForVirtualObject(
"GetState",
Expand Down
4 changes: 4 additions & 0 deletions sdk-api/src/test/java/dev/restate/sdk/UserFailuresTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

public class UserFailuresTest extends UserFailuresTestSuite {

@Override
protected TestInvocationBuilder throwIllegalStateException() {
return testDefinitionForService(
"ThrowIllegalStateException",
Expand All @@ -29,6 +30,7 @@ protected TestInvocationBuilder throwIllegalStateException() {
});
}

@Override
protected TestInvocationBuilder sideEffectThrowIllegalStateException(
AtomicInteger nonTerminalExceptionsSeen) {
return testDefinitionForService(
Expand Down Expand Up @@ -56,6 +58,7 @@ protected TestInvocationBuilder sideEffectThrowIllegalStateException(
});
}

@Override
protected TestInvocationBuilder throwTerminalException(int code, String message) {
return testDefinitionForService(
"ThrowTerminalException",
Expand All @@ -66,6 +69,7 @@ protected TestInvocationBuilder throwTerminalException(int code, String message)
});
}

@Override
protected TestInvocationBuilder sideEffectThrowTerminalException(int code, String message) {
return testDefinitionForService(
"SideEffectThrowTerminalException",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@ public int getStatusCode() {
}

@Override
public String toString() {
return "IngressException{"
+ "statusCode="
public String getMessage() {
return "["
+ statusCode
+ ", responseBody='"
+ new String(responseBody, StandardCharsets.UTF_8)
+ '\''
+ ", message='"
+ this.getMessage()
+ '\''
+ '}';
+ "] "
+ super.getMessage()
+ ". Got response body: "
+ new String(responseBody, StandardCharsets.UTF_8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class RequestOptions {
public static final RequestOptions DEFAULT = new RequestOptions();
Expand Down Expand Up @@ -47,10 +48,9 @@ public RequestOptions copy() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

if (!(o instanceof RequestOptions)) return false;
RequestOptions that = (RequestOptions) o;
return additionalHeaders.equals(that.additionalHeaders);
return Objects.equals(additionalHeaders, that.additionalHeaders);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public String getInvocationId() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

if (!(o instanceof SendResponse)) return false;
SendResponse that = (SendResponse) o;
return status == that.status && Objects.equals(invocationId, that.invocationId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public long toRandomSeed() {

// Generate the long
long n = 0;
n |= ((long) (digest[7] & 0xFF) << Byte.SIZE * 7);
n |= ((long) (digest[6] & 0xFF) << Byte.SIZE * 6);
n |= ((long) (digest[5] & 0xFF) << Byte.SIZE * 5);
n |= ((long) (digest[4] & 0xFF) << Byte.SIZE * 4);
n |= ((long) (digest[3] & 0xFF) << Byte.SIZE * 3);
n |= ((digest[2] & 0xFF) << Byte.SIZE * 2);
n |= ((long) (digest[7] & 0xFF) << (Byte.SIZE * 7));
n |= ((long) (digest[6] & 0xFF) << (Byte.SIZE * 6));
n |= ((long) (digest[5] & 0xFF) << (Byte.SIZE * 5));
n |= ((long) (digest[4] & 0xFF) << (Byte.SIZE * 4));
n |= ((long) (digest[3] & 0xFF) << (Byte.SIZE * 3));
n |= ((digest[2] & 0xFF) << (Byte.SIZE * 2));
n |= ((digest[1] & 0xFF) << Byte.SIZE);
n |= (digest[0] & 0xFF);
seed = n;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public HttpServer build() {

private static void handleStart(AsyncResult<HttpServer> ar) {
if (ar.succeeded()) {
LOG.info("Restate HTTP Endpoint server started on port " + ar.result().actualPort());
LOG.info("Restate HTTP Endpoint server started on port {}", ar.result().actualPort());
} else {
LOG.error("Restate HTTP Endpoint server start failed", ar.cause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String toString() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!(o instanceof Person)) return false;
Person person = (Person) o;
return Objects.equals(name, person.name);
}
Expand Down

0 comments on commit 41d57f2

Please sign in to comment.