Buggy code:
} if ( ( bunds . get ( 0 ) ) != null ) { List < Bitstream > bits = bunds . get ( 0 ) . getBitstreams ( ) ; for ( int i = 0 ; ( i < ( bits . size ( ) ) ) && ( ! html ) ; i ++ ) { <START_BUG> Bitstream b = bits . get ( i ) . getBitstream ( ) ; <END_BUG> if ( b . equals ( bunds . get ( 0 ) . getPrimaryBitstream ( ) ) ) { html = b . getFormat ( context ) . getMIMEType ( ) . equals ( "text//html" ) ; primaryBitstream = b ; } } } out . println ( ( ( "<table<seq2seq4repair_space>class=\"table<seq2seq4repair_space>panel-body\"><tr><th<seq2seq4repair_space>id=\"t1\"<seq2seq4repair_space>class=\"standard\">" + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.file" ) ) ) + "<//th>" ) ) ; if ( multiFile ) { out . println ( ( ( "<th<seq2seq4repair_space>id=\"t2\"<seq2seq4repair_space>class=\"standard\">" + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.description" ) ) ) + "<//th>" ) ) ; } out . println ( ( ( ( ( "<th<seq2seq4repair_space>id=\"t3\"<seq2seq4repair_space>class=\"standard\">" + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.filesize" ) ) ) + "<//th><th<seq2seq4repair_space>id=\"t4\"<seq2seq4repair_space>class=\"standard\">" ) + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.fileformat" ) ) ) + "<//th><th>&nbsp;<//th><//tr>" ) ) ; if ( html ) { if ( handle == null ) { handle = "db-id//" + ( item . getID ( ) ) ; } out . print ( "<tr><td<seq2seq4repair_space>headers=\"t1\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( "<a<seq2seq4repair_space>target=\"_blank\"<seq2seq4repair_space>href=\"" ) ; out . print ( request . getContextPath ( ) ) ; out . print ( "//html//" ) ; out . print ( ( handle + "//" ) ) ; out . print ( UIUtil . encodeBitstreamName ( primaryBitstream . getName ( ) , DEFAULT_ENCODING ) ) ; out . print ( "\">" ) ; out . print ( primaryBitstream . getName ( ) ) ; out . print ( "<//a>" ) ; if ( multiFile ) { out . print ( "<//td><td<seq2seq4repair_space>headers=\"t2\"<seq2seq4repair_space>class=\"standard\">" ) ; String desc = primaryBitstream . getDescription ( ) ; out . print ( ( desc != null ? desc : "" ) ) ; } out . print ( "<//td><td<seq2seq4repair_space>headers=\"t3\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( UIUtil . formatFileSize ( primaryBitstream . getSize ( ) ) ) ; out . print ( "<//td><td<seq2seq4repair_space>headers=\"t4\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( primaryBitstream . getFormatDescription ( context ) ) ; out . print ( "<//td><td<seq2seq4repair_space>class=\"standard\"><a<seq2seq4repair_space>class=\"btn<seq2seq4repair_space>btn-primary\"<seq2seq4repair_space>target=\"_blank\"<seq2seq4repair_space>href=\"" ) ; out . print ( request . getContextPath ( ) ) ; out . print ( "//html//" ) ; out . print ( ( handle + "//" ) ) ; out . print ( UIUtil . encodeBitstreamName ( primaryBitstream . getName ( ) , DEFAULT_ENCODING ) ) ; out . print ( ( ( "\">" + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.view" ) ) ) + "<//a><//td><//tr>" ) ) ; } else { boolean showRequestCopy = false ; if ( ( "all" . equalsIgnoreCase ( ConfigurationManager . getProperty ( "request.item.type" ) ) ) || ( ( "logged" . equalsIgnoreCase ( ConfigurationManager . getProperty ( "request.item.type" ) ) ) && ( ( context . getCurrentUser ( ) ) != null ) ) ) { showRequestCopy = true ; } for ( Bundle bundle : bundles ) { List < Bitstream > bitstreams = bundle . getBitstreams ( ) ; for ( Bitstream b : bitstreams ) { if ( ! ( b . getFormat ( context ) . isInternal ( ) ) ) { String bsLink = "target=\"_blank\"<seq2seq4repair_space>href=\"" + ( request . getContextPath ( ) ) ; if ( ( handle != null ) && ( ( b . getSequenceID ( ) ) > 0 ) ) { bsLink = ( ( ( ( bsLink + "//bitstream//" ) + ( item . getHandle ( ) ) ) + "//" ) + ( b . getSequenceID ( ) ) ) + "//" ; } else { bsLink = ( ( bsLink + "//retrieve//" ) + ( b . getID ( ) ) ) + "//" ; } bsLink = ( bsLink + ( UIUtil . encodeBitstreamName ( b . getName ( ) , DEFAULT_ENCODING ) ) ) + "\">" ; out . print ( "<tr><td<seq2seq4repair_space>headers=\"t1\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( "<a<seq2seq4repair_space>" ) ; out . print ( bsLink ) ; out . print ( b . getName ( ) ) ; out . print ( "<//a>" ) ; if ( multiFile ) { out . print ( "<//td><td<seq2seq4repair_space>headers=\"t2\"<seq2seq4repair_space>class=\"standard\">" ) ; String desc = b . getDescription ( ) ; out . print ( ( desc != null ? desc : "" ) ) ; } out . print ( "<//td><td<seq2seq4repair_space>headers=\"t3\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( UIUtil . formatFileSize ( b . getSize ( ) ) ) ; out . print ( "<//td><td<seq2seq4repair_space>headers=\"t4\"<seq2seq4repair_space>class=\"standard\">" ) ; out . print ( b . getFormatDescription ( context ) ) ; out . print ( "<//td><td<seq2seq4repair_space>class=\"standard\"<seq2seq4repair_space>align=\"center\">" ) ; if ( ( ( thumbs . size ( ) ) > 0 ) && ( showThumbs ) ) { String tName = ( b . getName ( ) ) + ".jpg" ; String tAltText = LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.thumbnail" ) ; Bitstream tb = bundleService . getBitstreamByName ( thumbs . get ( 0 ) , tName ) ; if ( tb != null ) { if ( authorizeService . authorizeActionBoolean ( context , tb , READ ) ) { String myPath = ( ( ( ( request . getContextPath ( ) ) + "//retrieve//" ) + ( tb . getID ( ) ) ) + "//" ) + ( UIUtil . encodeBitstreamName ( tb . getName ( ) , DEFAULT_ENCODING ) ) ; out . print ( "<a<seq2seq4repair_space>" ) ; out . print ( bsLink ) ; out . print ( ( ( "<img<seq2seq4repair_space>src=\"" + myPath ) + "\"<seq2seq4repair_space>" ) ) ; out . print ( ( ( "alt=\"" + tAltText ) + "\"<seq2seq4repair_space>//><//a><br<seq2seq4repair_space>//>" ) ) ; } } } out . print ( "<a<seq2seq4repair_space>class=\"btn<seq2seq4repair_space>btn-primary\"<seq2seq4repair_space>" ) ; out . print ( ( ( bsLink + ( LocaleSupport . getLocalizedMessage ( pageContext , "org.dspace.app.webui.jsptag.ItemTag.view" ) ) ) + "<//a>" ) ) ; try { if ( showRequestCopy && ( ! ( authorizeService . authorizeActionBoolean ( context , b , READ ) ) ) ) out . print ( ( ( ( ( ( ( ( ( "&nbsp;<a<seq2seq4repair_space>class=\"btn<seq2seq4repair_space>btn-success\"<seq2seq4repair_space>href=\""

Fix:
Bitstream b = bits . get ( i ) ;