diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/FlightSqlExample.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/FlightSqlExample.java index fdf0ea00946ff..fbb60771a3182 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/FlightSqlExample.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/FlightSqlExample.java @@ -609,8 +609,8 @@ private static VectorSchemaRoot getSqlInfoRoot(final DatabaseMetaData metaData, @Override public void getStreamPreparedStatement(final CommandPreparedStatementQuery command, final CallContext context, final Ticket ticket, final ServerStreamListener listener) { - StatementContext statementContext = - preparedStatementLoadingCache.getIfPresent(command.getPreparedStatementHandle()); + ByteString handle = command.getPreparedStatementHandle(); + StatementContext statementContext = preparedStatementLoadingCache.getIfPresent(handle); assert statementContext != null; try (PreparedStatement statement = statementContext.getStatement(); ResultSet resultSet = statement.executeQuery()) { @@ -635,7 +635,7 @@ public void getStreamPreparedStatement(final CommandPreparedStatementQuery comma listener.error(e); } finally { listener.completed(); - commandExecutePreparedStatementLoadingCache.invalidate(command); + commandExecutePreparedStatementLoadingCache.invalidate(handle); } }