Copilot commented on code in PR #6312:
URL: https://github.com/apache/ignite-3/pull/6312#discussion_r2228093715
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/streamer/ItAbstractDataStreamerTest.java:
##########
@@ -607,22 +609,35 @@ public void testFailedItems() {
try {
publisher.submit(item);
invalidItemsAdded.add(item);
- } catch (Exception e) {
+ } catch (IllegalStateException e) {
+ assertEquals("Streamer is closed, can't add items.",
e.getMessage());
break;
+ } catch (RuntimeException e) {
+ if (unwrapCause(e) instanceof MarshallerException) {
+ // Item was added but failed on flush.
+ invalidItemsAdded.add(item);
+ break;
+ } else {
+ // Unexpected exception.
+ throw e;
+ }
}
}
}
var ex = assertThrows(CompletionException.class, () ->
streamerFut.orTimeout(1, TimeUnit.SECONDS).join());
DataStreamerException cause = (DataStreamerException) ex.getCause();
- Set<?> failedItems = cause.failedItems();
+ Set<DataStreamerItem<Tuple>> failedItems =
(Set<DataStreamerItem<Tuple>>) cause.failedItems();
Review Comment:
Unsafe cast without type checking. Consider using instanceof check or adding
@SuppressWarnings("unchecked") annotation to document the intentional unchecked
cast.
```suggestion
Object failedItemsObj = cause.failedItems();
if (!(failedItemsObj instanceof Set<?>)) {
throw new IllegalStateException("Expected failedItems to be of
type Set<DataStreamerItem<Tuple>>, but got: " + failedItemsObj.getClass());
}
@SuppressWarnings("unchecked")
Set<DataStreamerItem<Tuple>> failedItems =
(Set<DataStreamerItem<Tuple>>) failedItemsObj;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]