Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,11 @@ protected PartialResultSet computeNext() {
continue;
}
span.addAnnotation("Stream broken. Not safe to retry");
TraceUtil.endSpanWithFailure(span, e);
//TraceUtil.endSpanWithFailure(span, e);
throw e;
} catch (RuntimeException e) {
span.addAnnotation("Stream broken. Not safe to retry");
TraceUtil.endSpanWithFailure(span, e);
//TraceUtil.endSpanWithFailure(span, e);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,28 @@ public void nonRetryableError() {
assertThat(strings.next()).isNotEqualTo("X");
}

@Test
public void closedSpanOnNonRetryableError() {
Span span = mock(Span.class);
Whitebox.setInternalState(this.resumableStreamIterator, "span", span);

ResultSetStream s1 = Mockito.mock(ResultSetStream.class);
Mockito.when(starter.startStream(null)).thenReturn(new ResultSetIterator(s1));
Mockito.when(s1.next())
.thenReturn(resultSet(ByteString.copyFromUtf8("r1"), "a"))
.thenReturn(resultSet(ByteString.copyFromUtf8("r2"), "b"))
.thenReturn(resultSet(null, "X"))
.thenReturn(resultSet(null, "X"))
.thenThrow(new NonRetryableException(ErrorCode.FAILED_PRECONDITION, "failed by test"));
Iterator<String> strings = stringIterator(resumableStreamIterator);
assertThat(strings.next()).isEqualTo("a");
assertThat(strings.next()).isEqualTo("b");
expectedException.expect(isSpannerException(ErrorCode.FAILED_PRECONDITION));
assertThat(strings.next()).isNotEqualTo("X");

verify(span).end(EndSpanOptions.builder().setSampleToLocalSpanStore(true).build());
}

@Test
public void bufferLimitSimple() {
initWithLimit(1);
Expand Down