pjfanning commented on code in PR #3526:
URL: https://github.com/apache/pekko/pull/3526#discussion_r3947649263


##########
actor/src/main/scala/org/apache/pekko/util/ByteString.scala:
##########
@@ -1581,12 +1581,27 @@ object ByteString {
     /**
      * Scans for the fragment containing `offset` and records it as the hint. 
`hintIdx` and
      * `hintStart` are a previously read hint that missed, used to resume the 
scan from that
-     * fragment rather than from the start.
+     * fragment -- forward or backward, whichever side of it `offset` is on -- 
rather than
+     * from the start.
      */
     private def resolveFragment(offset: Int, hintIdx: Int, hintStart: Int): 
Long = {
       var pos = 0
       var seen = 0
       if (hintIdx >= 0) {
+        if (offset < hintStart) {
+          // moving backward before the remembered fragment: walk back from 
it. `offset >= 0`
+          // and fragment 0 starts at 0, so the walk stops at fragment 0 at 
the latest, and it
+          // is never longer than the scan from fragment 0 it replaces.
+          pos = hintIdx
+          seen = hintStart
+          while (offset < seen) {

Review Comment:
   I pushed a fix for this and made the hint volatile



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