Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6882#discussion_r33182808
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -2333,3 +2333,48 @@ private[spark] class RedirectThread(
         }
       }
     }
    +
    +/**
    + * An [[OutputStream]] that will store the last 10 kilobytes (by default) 
written to it
    + * in a circular buffer. The current contents of the buffer can be 
accessed using
    + * the toString method.
    + */
    +private[spark] class CircularBuffer(sizeInBytes: Int = 10240) extends 
java.io.OutputStream {
    +  var pos: Int = 0
    +  var buffer = new Array[Byte](sizeInBytes)
    +
    +  /**
    +   * Writes the specified byte to this output stream. The general
    +   * contract for [[write]] is that one byte is written
    +   * to the output stream. The byte to be written is the eight
    +   * low-order bits of the argument `i`. The 24
    +   * high-order bits of `i` are ignored.
    +   *
    +   * Subclasses of [[OutputStream]] must provide an
    +   * implementation for this method.
    +   *
    +   * @param i the byte to be written.
    +   */
    +  override def write(i: Int): Unit = {
    +    buffer(pos) = i.asInstanceOf[Byte]
    --- End diff --
    
    But now I think you are corrupting the data:
    ```
    scala> 255.asInstanceOf[Byte].asInstanceOf[Int]
    res2: Int = -1
    ```
    
    It would be better if you could avoid refactoring unrelated code in bug fix 
PRs, because they can cause regressions like this and I'm not always able to 
catch them.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to