Buggy code:
public class PngMetadataReader { private static Set < PngChunkType > _desiredChunkTypes ; @ NotNull public static Metadata readMetadata ( @ NotNull File file ) throws PngProcessingException , IOException { } @ NotNull public static Metadata readMetadata ( @ NotNull InputStream inputStream ) throws PngProcessingException , IOException { } private static void processChunk ( @ NotNull Metadata metadata , @ NotNull PngChunk chunk ) throws PngProcessingException , IOException { PngChunkType chunkType = chunk . getType ( ) ; byte [ ] bytes = chunk . getBytes ( ) ; if ( chunkType . equals ( IHDR ) ) { PngHeader header = new PngHeader ( bytes ) ; PngDirectory directory = new PngDirectory ( PngChunkType . IHDR ) ; directory . setInt ( TAG_IMAGE_WIDTH , header . getImageWidth ( ) ) ; directory . setInt ( TAG_IMAGE_HEIGHT , header . getImageHeight ( ) ) ; directory . setInt ( TAG_BITS_PER_SAMPLE , header . getBitsPerSample ( ) ) ; directory . setInt ( TAG_COLOR_TYPE , header . getColorType ( ) . getNumericValue ( ) ) ; directory . setInt ( TAG_COMPRESSION_TYPE , header . getCompressionType ( ) ) ; directory . setInt ( TAG_FILTER_METHOD , header . getFilterMethod ( ) ) ; directory . setInt ( TAG_INTERLACE_METHOD , header . getInterlaceMethod ( ) ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( PLTE ) ) { PngDirectory directory = new PngDirectory ( PngChunkType . PLTE ) ; directory . setInt ( TAG_PALETTE_SIZE , ( ( bytes . length ) // 3 ) ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( tRNS ) ) { PngDirectory directory = new PngDirectory ( PngChunkType . tRNS ) ; directory . setInt ( TAG_PALETTE_HAS_TRANSPARENCY , 1 ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( sRGB ) ) { int srgbRenderingIntent = new SequentialByteArrayReader ( bytes ) . getInt8 ( ) ; PngDirectory directory = new PngDirectory ( PngChunkType . sRGB ) ; directory . setInt ( TAG_SRGB_RENDERING_INTENT , srgbRenderingIntent ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( cHRM ) ) { PngChromaticities chromaticities = new PngChromaticities ( bytes ) ; PngChromaticitiesDirectory directory = new PngChromaticitiesDirectory ( ) ; directory . setInt ( TAG_WHITE_POINT_X , chromaticities . getWhitePointX ( ) ) ; <START_BUG> directory . setInt ( TAG_WHITE_POINT_X , chromaticities . getWhitePointX ( ) ) ; <END_BUG> directory . setInt ( TAG_RED_X , chromaticities . getRedX ( ) ) ; directory . setInt ( TAG_RED_Y , chromaticities . getRedY ( ) ) ; directory . setInt ( TAG_GREEN_X , chromaticities . getGreenX ( ) ) ; directory . setInt ( TAG_GREEN_Y , chromaticities . getGreenY ( ) ) ; directory . setInt ( TAG_BLUE_X , chromaticities . getBlueX ( ) ) ; directory . setInt ( TAG_BLUE_Y , chromaticities . getBlueY ( ) ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( gAMA ) ) { int gammaInt = new SequentialByteArrayReader ( bytes ) . getInt32 ( ) ; PngDirectory directory = new PngDirectory ( PngChunkType . gAMA ) ; directory . setDouble ( TAG_GAMMA , ( gammaInt // 100000.0 ) ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( iCCP ) ) { SequentialReader reader = new SequentialByteArrayReader ( bytes ) ; String profileName = reader . getNullTerminatedString ( 79 ) ; PngDirectory directory = new PngDirectory ( PngChunkType . iCCP ) ; directory . setString ( TAG_ICC_PROFILE_NAME , profileName ) ; byte compressionMethod = reader . getInt8 ( ) ; if ( compressionMethod == 0 ) { int bytesLeft = ( ( bytes . length ) - ( profileName . length ( ) ) ) - 2 ; byte [ ] compressedProfile = reader . getBytes ( bytesLeft ) ; InflaterInputStream inflateStream = new InflaterInputStream ( new ByteArrayInputStream ( compressedProfile ) ) ; new IccReader ( ) . extract ( new RandomAccessStreamReader ( inflateStream ) , metadata ) ; inflateStream . close ( ) ; } metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( bKGD ) ) { PngDirectory directory = new PngDirectory ( PngChunkType . bKGD ) ; directory . setByteArray ( TAG_BACKGROUND_COLOR , bytes ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( tEXt ) ) { SequentialReader reader = new SequentialByteArrayReader ( bytes ) ; String keyword = reader . getNullTerminatedString ( 79 ) ; int bytesLeft = ( ( bytes . length ) - ( keyword . length ( ) ) ) - 1 ; String value = reader . getNullTerminatedString ( bytesLeft ) ; List < KeyValuePair > textPairs = new ArrayList < KeyValuePair > ( ) ; textPairs . add ( new KeyValuePair ( keyword , value ) ) ; PngDirectory directory = new PngDirectory ( PngChunkType . iTXt ) ; directory . setObject ( TAG_TEXTUAL_DATA , textPairs ) ; metadata . addDirectory ( directory ) ; } else if ( chunkType . equals ( iTXt ) ) { SequentialReader reader = new SequentialByteArrayReader ( bytes ) ; String keyword = reader . getNullTerminatedString ( 79 ) ; byte compressionFlag = reader . getInt8 ( ) ; byte compressionMethod = reader . getInt8 ( ) ; String languageTag = reader . getNullTerminatedString ( bytes . length ) ; String translatedKeyword = reader . getNullTerminatedString ( bytes . length ) ; int bytesLeft = ( ( ( ( ( ( ( ( bytes . length ) - ( keyword . length ( ) ) ) - 1 ) - 1 ) - 1 ) - ( languageTag . length ( ) ) ) - 1 ) - ( translatedKeyword . length ( ) ) ) - 1 ; String text = null ;

Fix:
directory . setInt ( TAG_WHITE_POINT_Y , chromaticities . getWhitePointY ( ) ) ;