pauloricardomg commented on code in PR #2058:
URL: https://github.com/apache/cassandra/pull/2058#discussion_r1065086943


##########
src/java/org/apache/cassandra/db/streaming/CassandraOutgoingFile.java:
##########
@@ -172,10 +174,11 @@ public void write(StreamSession session, 
StreamingDataOutputPlus out, int versio
             out.flush();
 
             CassandraStreamWriter writer = header.isCompressed() ?
-                                           new 
CassandraCompressedStreamWriter(sstable, header, session) :
-                                           new CassandraStreamWriter(sstable, 
header, session);
+                                           new 
CassandraCompressedStreamWriter(sstable, header, session, 
fileStreamMetricsListener) :
+                                           new CassandraStreamWriter(sstable, 
header, session, fileStreamMetricsListener);
             writer.write(out);
         }
+        fileStreamMetricsListener.onStreamSuccessful();

Review Comment:
   > May I ask, what happens when it actually throws that exception 
(AssertionError). What happens in runtime? Where it propagates and what 
eventually fails?
   
   The way I see it is that assertions shouldn't happen in runtime unless the 
code is broken, as they're errors targeted for developers to detect broken code 
assumptions. Unfortunately in Cassandra we overload assertions a bit and use it 
for error handling (which IMO is a bad smell), but this is not what is being 
done here.
   
   The assertion `assert lastSeenBytes == totalSize` on 
`FileStreamMetricsListener.onStreamSuccessful` is a runtime safety check to 
ensure that the behavior of the class `FileStreamMetricsListener` is working as 
expected and we don't report more streamed bytes than the expected amount. It's 
a future-proof safety check for programming errors, but should not be expected 
to fail during correct operation.  If this assertion is ever thrown, it means 
that there is a bug in the code that must be fixed.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to