Program: 9018
Project: 9018
Buggy source:
/** 
 * Decodes a stream the multibyte chunks into a stream of strings that works on infinite streams and where handles when a multibyte character spans two chunks. This method allows for more control over how malformed and unmappable characters are handled.
 * @param src
 * @param charsetDecoder
 * @return
 */
public static Observable<String> decode(final Observable<byte[]> src,final CharsetDecoder charsetDecoder){
  return src.lift(new Operator<String,byte[]>(){
    @Override public Subscriber<? super byte[]> call(    final Subscriber<? super String> o){
      return new Subscriber<byte[]>(o){
        private ByteBuffer leftOver=null;
        @Override public void onCompleted(){
          if (process(null,leftOver,true))           o.onCompleted();
        }
        @Override public void onError(        Throwable e){
          if (process(null,leftOver,true))           o.onError(e);
        }
        @Override public void onNext(        byte[] bytes){
          process(bytes,leftOver,false);
        }
        public boolean process(        byte[] next,        ByteBuffer last,        boolean endOfInput){
          ByteBuffer bb;
          if (last != null) {
            if (next != null) {
              bb=ByteBuffer.allocate(last.remaining() + next.length);
              bb.put(last);
              bb.put(next);
              bb.flip();
            }
 else {
              bb=last;
            }
          }
 else {
            if (next != null) {
              bb=ByteBuffer.wrap(next);
            }
 else {
              return true;
            }
          }
          CharBuffer cb=CharBuffer.allocate((int)(bb.limit() * charsetDecoder.averageCharsPerByte()));
          CoderResult cr=charsetDecoder.decode(bb,cb,endOfInput);
          cb.flip();
          if (cr.isError()) {
            try {
              cr.throwException();
            }
 catch (            CharacterCodingException e) {
              o.onError(e);
              return false;
            }
          }
          if (bb.remaining() > 0) {
            leftOver=bb;
          }
 else {
            leftOver=null;
          }
          String string=cb.toString();
          if (!string.isEmpty())           o.onNext(string);
          return true;
        }
      }
;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Decodes a stream the multibyte chunks into a stream of strings that works on infinite streams and where it handles when a multibyte character spans two chunks. This method allows for more control over how malformed and unmappable characters are handled.
 * @param src
 * @param charsetDecoder
 * @return
 */
public static Observable<String> decode(final Observable<byte[]> src,final CharsetDecoder charsetDecoder){
  return src.lift(new Operator<String,byte[]>(){
    @Override public Subscriber<? super byte[]> call(    final Subscriber<? super String> o){
      return new Subscriber<byte[]>(o){
        private ByteBuffer leftOver=null;
        @Override public void onCompleted(){
          if (process(null,leftOver,true))           o.onCompleted();
        }
        @Override public void onError(        Throwable e){
          if (process(null,leftOver,true))           o.onError(e);
        }
        @Override public void onNext(        byte[] bytes){
          process(bytes,leftOver,false);
        }
        public boolean process(        byte[] next,        ByteBuffer last,        boolean endOfInput){
          if (o.isUnsubscribed())           return false;
          ByteBuffer bb;
          if (last != null) {
            if (next != null) {
              bb=ByteBuffer.allocate(last.remaining() + next.length);
              bb.put(last);
              bb.put(next);
              bb.flip();
            }
 else {
              bb=last;
            }
          }
 else {
            if (next != null) {
              bb=ByteBuffer.wrap(next);
            }
 else {
              return true;
            }
          }
          CharBuffer cb=CharBuffer.allocate((int)(bb.limit() * charsetDecoder.averageCharsPerByte()));
          CoderResult cr=charsetDecoder.decode(bb,cb,endOfInput);
          cb.flip();
          if (cr.isError()) {
            try {
              cr.throwException();
            }
 catch (            CharacterCodingException e) {
              o.onError(e);
              return false;
            }
          }
          if (bb.remaining() > 0) {
            leftOver=bb;
          }
 else {
            leftOver=null;
          }
          String string=cb.toString();
          if (!string.isEmpty())           o.onNext(string);
          return true;
        }
      }
;
    }
  }
);
}