thomasmueller commented on PR #2795:
URL: https://github.com/apache/jackrabbit-oak/pull/2795#issuecomment-4040206080

   > @thomasmueller How often do you expect these warnings to occur? 
   
   The warning is very rare. Hopefully, it never occurs:
   
   `if (actualType == BINARY && type != BINARY) {`
   
   (Sonar for some reason thinks this is always true, but in reality it is 
almost never true. The test here is very fast.)
   
   If it does occur, we are already in "behavior is undefined" territory. And 
that's why logging a warning is important: if the binary is large, an exception 
is thrown (the one caught below). However, there might be some cases that do 
not trigger the exception, but because we are lucky and the binary is small 
enough to be inlined. But this is just pure luck. That's why I added this 
logic: so that we have warnings in the log file and don't rely on this pure 
luck.
   
   The reason why I added this logic is so that we can detect such incorrect 
behavior (possibly in the indexing code, but possibly in other code in Oak.)
   
   > As this is quite performance critical, can we perhaps move the warning and 
log generation in the exception handler
   
   That would defeat what I have done, mostly. I want that we detect cases 
where we call getString() on a binary, even if it does _not_ throw an exception.
   
   


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

Reply via email to