[ 
https://issues.apache.org/jira/browse/KAFKA-15768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17790835#comment-17790835
 ] 

Matthias J. Sax commented on KAFKA-15768:
-----------------------------------------

Thanks for the details [~vvcephei]!
{quote}In other words, it should return the result if and only if all queried 
partitions responded successfully AND at most one partition returned a non-null 
result.
{quote}
This was the unclear piece to me, ie, what's the actual user contract.

About exceptions vs FailedQueryResult – it seems we are in a somewhat mixed 
mode here – My understanding was, that IQv2 tries to avoid throwing exception, 
and that's why `FailedQueryResult` was introduced to begin with. Thus, I am 
wondering if `getOnlyPartitionResult` should ever throw an exception, or always 
return a `FailedQueryResult` (ie, one or multiple partition results returns 
`FailedQueryResult` and/or there was more than one non-empty successful query 
result)?
{quote}since the application isn't in an illegal state 
{quote}
Well, the `StateQueryResult` object is in an illegal state. I never interpreted 
IllegalState as a programming error, but just as "this object is corrupted – 
don't use it any longer"... The interpretation that `this` is an argument 
sounds a little bit far fetched to me... `getOnlyPartitionResult()` is a zero 
argument method IMHO... but yes, it might be philosophical, so let's not dig 
deeper (especially if we would agree to side step this question by not throwing 
an exception as all any longer...)

> StateQueryResult#getOnlyPartitionResult should not throw for FailedQueryResult
> ------------------------------------------------------------------------------
>
>                 Key: KAFKA-15768
>                 URL: https://issues.apache.org/jira/browse/KAFKA-15768
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Matthias J. Sax
>            Assignee: Hanyu Zheng
>            Priority: Major
>
> Calling `StateQueryResult#getOnlyPartitionResult` crashes with an incorrect 
> `IllegalArgumentException` if any result is a `FailedQueryResult` (and even 
> if there is only a single FailedQueryResult).
> The issue is the internal `filter(r -> r.getResult() != 0)` step, that 
> blindly (and incorrectly) calls `getResult`.
> Given the semantics of `getOnlyPartitionResult` we should not care if the 
> result is SuccessQueryResult or FailedQueryResult, but only check if there is 
> a single result or not. (The user has no means to avoid getting the 
> underlying error otherwise.)
> Side-note: why does `FailedQueryResult#getResult` throw an 
> IllegalArgumentException (there is no argument passed into the method – it 
> should rather be an `IllegalStateException` – but I guess we would need a KIP 
> for this fix?)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to