mbeckerle commented on a change in pull request #448:
URL: https://github.com/apache/incubator-daffodil/pull/448#discussion_r512691727



##########
File path: 
daffodil-io/src/main/scala/org/apache/daffodil/io/DirectOrBufferedDataOutputStream.scala
##########
@@ -885,8 +885,10 @@ class DirectOrBufferedDataOutputStream private[io] (
               bufOS.getFile.delete()
           }
           nBitsPut / 8
-        } else
-          directDOS.putBytes(bufOS.getBuf, 0, nBytes, finfo)
+        } else {
+          Assert.usage(nBytes <= Int.MaxValue)

Review comment:
       Assert.usage is for incorrect usage of the API of a method/function, 
i.e., the caller is not "using" it correctly. Generally this is for checking 
args, but also checking that state is proper for the use of the method. A good 
example is next/hasNext. You are not supposed to call next() unless hasNext() 
is true. So a next() implementation can do Assert.usage(this.hasNext()).  
Assert.invariant is just stating that at this point in the code this condition 
is an invariant, i.e., it is supposed to be true. It is more things that are 
deeper than arg or pre-condition checking of a call. One writes 
Assert.invariant in order to make clear the assumptions of the code, 
particularly those that are subtle, and so might get changed accidently as code 
is maintained. 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to