Buggy code:
public class Buffer implements IBuffer { protected BufferManager fManager ; protected IFile fFile ; protected int fFlags ; protected char [ ] fContents ; protected ArrayList fChangeListeners ; protected IOpenable fOwner ; protected int fGapStart = - 1 ; protected int fGapEnd = - 1 ; protected int fHighWatermark = 300 ; protected int fLowWatermark = 50 ; protected Object fLock = new Object ( ) ; String lineSeparator ; protected static final int F_HAS_UNSAVED_CHANGES = 1 ; protected static final int F_IS_READ_ONLY = 2 ; protected static final int F_IS_CLOSED = 4 ; protected Buffer ( BufferManager manager , char [ ] contents , IOpenable owner , boolean readOnly ) { } protected Buffer ( BufferManager manager , IFile file , char [ ] contents , IOpenable owner , boolean readOnly ) { } public void addBufferChangedListener ( IBufferChangedListener listener ) { } protected void adjustGap ( int position , int sizeHint ) { } public void append ( char [ ] text ) { } public void append ( char [ ] text , boolean convert ) { } public void append ( String text ) { } public void append ( String text , boolean convert ) { } public void close ( ) throws IllegalArgumentException { } private String findLineSeparator ( char [ ] text ) { } public char getChar ( int position ) { } public char [ ] getCharacters ( ) { } public String getContents ( ) { } public int getLength ( ) { } private String getLineSeparator ( char [ ] text ) { } public IOpenable getOwner ( ) { } public String getText ( int offset , int length ) { } public IResource getUnderlyingResource ( ) { } public boolean hasUnsavedChanges ( ) { } public boolean isClosed ( ) { } public boolean isReadOnly ( ) { } protected void moveAndResizeGap ( int position , int size ) { } private char [ ] normalizeCRs ( char [ ] text ) { } private String normalizeCRs ( String text ) { } protected void notifyChanged ( BufferChangedEvent event ) { } public void removeBufferChangedListener ( IBufferChangedListener listener ) { } public void replace ( int position , int length , char [ ] text ) { } public void replace ( int position , int length , char [ ] text , boolean convert ) { } public void replace ( int position , int length , String text ) { } public void replace ( int position , int length , String text , boolean convert ) { } public void save ( IProgressMonitor progress , boolean force ) throws JavaModelException { if ( ( isReadOnly ( ) ) || ( ( fFile ) == null ) ) { return ; } synchronized ( fLock ) { if ( ! ( hasUnsavedChanges ( ) ) ) return ; byte [ ] bytes = getContents ( ) . getBytes ( ) ; <START_BUG> BufferedInputStream stream = new BufferedInputStream ( new ByteArrayInputStream ( bytes ) ) ; <END_BUG> try { fFile . setContents ( stream , force , true , null ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } fFlags &= ~ ( Buffer . F_HAS_UNSAVED_CHANGES ) ; } } public void setContents ( char [ ] contents ) { } public void setContents ( char [ ] contents , boolean convert ) { } public void setContents ( String contents ) { } public void setContents ( String contents , boolean convert ) { } protected void setReadOnly ( boolean readOnly ) { } public void setWaterMarks ( int low , int high ) { } public String toString ( ) { } }

Fix:
ByteArrayInputStream stream = new ByteArrayInputStream ( bytes ) ;