Buggy code:
public class JPEGTweaker { @ SuppressWarnings ( "unused" ) private static short copySOS ( InputStream is , OutputStream os ) throws IOException { } private static void copyToEnd ( InputStream is , OutputStream os ) throws IOException { } public static byte [ ] extractICCProfile ( InputStream is ) throws IOException { } public static void extractICCProfile ( InputStream is , String pathToICCProfile ) throws IOException { } public static void extractThumbnails ( InputStream is , String pathToThumbnail ) throws IOException { } public static ICCProfile getICCProfile ( InputStream is ) throws IOException { } public static void insertExif ( InputStream is , OutputStream os , Exif exif ) throws Exception { } public static void insertICCProfile ( InputStream is , OutputStream os , byte [ ] data ) throws Exception { } public static void insertICCProfile ( InputStream is , OutputStream os , ICC_Profile icc_profile ) throws Exception { } public static void insertICCProfile ( InputStream is , OutputStream os , ICCProfile icc_profile ) throws Exception { } public static void insertIPTC ( InputStream is , OutputStream os , List < IPTCDataSet > iptcs ) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; for ( IPTCDataSet iptc : iptcs ) iptc . write ( bout ) ; <START_BUG> _8BIM bim = new _8BIM ( IPTC_NAA . getValue ( ) , "" , bout . toByteArray ( ) ) ; <END_BUG> List < _8BIM > bims = new ArrayList < _8BIM > ( ) ; bims . add ( bim ) ; JPEGTweaker . insertIRB ( is , os , bims ) ; } public static void insertIRB ( InputStream is , OutputStream os , List < _8BIM > bims ) throws IOException { } private static void readAPP0 ( InputStream is ) throws IOException { } private static Metadata readAPP1 ( InputStream is ) throws IOException { } private static void readAPP12 ( InputStream is ) throws IOException { } private static Metadata readAPP13 ( InputStream is ) throws IOException { } private static void readAPP14 ( InputStream is ) throws IOException { } private static void readAPP2 ( InputStream is , ByteArrayOutputStream bo ) throws IOException { } private static Metadata readAPPn ( InputStream is , Marker marker , Map < MetadataType , Metadata > matadataMap ) throws IOException { } private static String readCOM ( InputStream is ) throws IOException { } private static void readDHT ( InputStream is , List < HTable > m_acTables , List < HTable > m_dcTables ) throws IOException { } private static void readDQT ( InputStream is , List < QTable > m_qTables ) throws IOException { } public static Map < MetadataType , Metadata > readMetadata ( InputStream is ) throws IOException { } private static SOFReader readSOF ( InputStream is , Marker marker ) throws IOException { } private static short readSOS ( InputStream is , SOFReader sofReader ) throws IOException { } public static void removeAPPn ( Marker APPn , InputStream is , OutputStream os ) throws IOException { } public static void removeExif ( InputStream is , OutputStream os ) throws IOException { } public static void showICCProfile ( InputStream is ) throws IOException { } @ SuppressWarnings ( "unused" ) private static short skipSOS ( InputStream is ) throws IOException { } public static void writeICCProfile ( OutputStream os , byte [ ] data ) throws IOException { } public static void writeICCProfile ( OutputStream os , ICC_Profile icc_profile ) throws IOException { } public static void writeICCProfile ( OutputStream os , ICCProfile icc_profile ) throws IOException { } private JPEGTweaker ( ) { } No newline ; at end ; of file ; }

Fix:
_8BIM bim = new _8BIM ( IPTC_NAA . getValue ( ) , "iptc" , bout . toByteArray ( ) ) ;