Skip to content

Commit

Permalink
Work around weird kt interop issue
Browse files Browse the repository at this point in the history
  • Loading branch information
HT154 committed Oct 28, 2024
1 parent 24b9fb8 commit 06708b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pkl-core/src/main/java/org/pkl/core/messaging/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public Type type() {
public record ReadResourceResponse(
long requestId, long evaluatorId, byte @Nullable [] contents, @Nullable String error)
implements Client.Response {

// workaround for kotlin bridging issue where `byte @Nullable [] contents` isn't detected as nullable
public ReadResourceResponse(long requestId, long evaluatorId, @Nullable String error) {
this(requestId, evaluatorId, null, error);
}

public Type type() {
return Type.READ_RESOURCE_RESPONSE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class ExternalReaderRuntime(
ReadResourceResponse(
req.requestId,
req.evaluatorId,
null,
"No resource reader found for scheme " + req.uri.scheme
)
)
Expand All @@ -186,9 +185,7 @@ class ExternalReaderRuntime(
ReadResourceResponse(req.requestId, req.evaluatorId, reader.read(req.uri), null)
)
} catch (e: Exception) {
transport.send(
ReadResourceResponse(req.requestId, req.evaluatorId, null, e.toString())
)
transport.send(ReadResourceResponse(req.requestId, req.evaluatorId, e.toString()))
}
}
else -> throw ProtocolException("Unexpected incoming request message: $msg")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ abstract class AbstractServerTest {
assertThat(readResourceMsg.uri.toString()).isEqualTo("bahumbug:/foo.pkl")
assertThat(readResourceMsg.evaluatorId).isEqualTo(evaluatorId)

client.send(ReadResourceResponse(readResourceMsg.requestId, evaluatorId, null, null))
client.send(ReadResourceResponse(readResourceMsg.requestId, evaluatorId, null))

val evaluateResponse = client.receive<EvaluateResponse>()
assertThat(evaluateResponse.error).isNull()
Expand Down Expand Up @@ -224,7 +224,7 @@ abstract class AbstractServerTest {
val readResourceMsg = client.receive<ReadResourceRequest>()

client.send(
ReadResourceResponse(readResourceMsg.requestId, evaluatorId, null, "cannot read my bahumbug")
ReadResourceResponse(readResourceMsg.requestId, evaluatorId, "cannot read my bahumbug")
)

val evaluateResponse = client.receive<EvaluateResponse>()
Expand Down

0 comments on commit 06708b6

Please sign in to comment.