From b5ba62b759c1dea37c9922a9ffe5a7d2de049a34 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 26 Jun 2023 15:00:41 +0900 Subject: [PATCH] Add ticket content to error message --- .../tests/ExpirationTimeProducer.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java index 81d97d5e2733e..42144f5ce204c 100644 --- a/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java +++ b/java/flight/flight-integration-tests/src/main/java/org/apache/arrow/flight/integration/tests/ExpirationTimeProducer.java @@ -105,17 +105,20 @@ public void getStream(CallContext context, Ticket ticket, ServerStreamListener l EndpointStatus status = statuses.get(index); if (status.cancelled) { listener.error(CallStatus.NOT_FOUND - .withDescription("Invalid flight: cancelled") + .withDescription("Invalid flight: cancelled: " + + new String(ticket.getBytes(), StandardCharsets.UTF_8)) .toRuntimeException()); return; } else if (status.expirationTime != null && Instant.now().isAfter(status.expirationTime)) { listener.error(CallStatus.NOT_FOUND - .withDescription("Invalid flight: expired") + .withDescription("Invalid flight: expired: " + + new String(ticket.getBytes(), StandardCharsets.UTF_8)) .toRuntimeException()); return; } else if (status.expirationTime == null && status.numGets > 0) { listener.error(CallStatus.NOT_FOUND - .withDescription("Invalid flight: can't read multiple times") + .withDescription("Invalid flight: can't read multiple times: " + + new String(ticket.getBytes(), StandardCharsets.UTF_8)) .toRuntimeException()); return; } @@ -157,7 +160,7 @@ public void doAction(CallContext context, Action action, StreamListener EndpointStatus status = statuses.get(index); if (status.cancelled) { listener.onError(CallStatus.INVALID_ARGUMENT - .withDescription("Invalid flight: cancelled") + .withDescription("Invalid flight: cancelled: " + index) .toRuntimeException()); return; } @@ -191,7 +194,7 @@ public void listActions(CallContext context, StreamListener listener } private FlightEndpoint addEndpoint(String ticket, Instant expirationTime) { - Ticket flightTicket = new Ticket(String.format("%d:%s", statuses.size(), ticket).getBytes(StandardCharsets.UTF_8)); + Ticket flightTicket = new Ticket(String.format("%d: %s", statuses.size(), ticket).getBytes(StandardCharsets.UTF_8)); statuses.add(new EndpointStatus(expirationTime)); return new FlightEndpoint(flightTicket, expirationTime); } @@ -200,7 +203,10 @@ private int parseIndexFromTicket(Ticket ticket) { final String contents = new String(ticket.getBytes(), StandardCharsets.UTF_8); int index = contents.indexOf(':'); if (index == -1) { - throw CallStatus.INVALID_ARGUMENT.withDescription("Invalid ticket").toRuntimeException(); + throw CallStatus.INVALID_ARGUMENT + .withDescription("Invalid ticket: " + + new String(ticket.getBytes(), StandardCharsets.UTF_8)) + .toRuntimeException(); } int endpointIndex = Integer.parseInt(contents.substring(0, index)); if (endpointIndex < 0 || endpointIndex >= statuses.size()) {