Buggy code:
class FileWatcher implements Runnable { private static Logger LOG = Logger . getLogger ( FileWatcher . class ) ; private WatchService myWatcher ; private ProcessedIndex index ; private IPreferences preferences ; private ConfigJson configJson ; public FileWatcher ( WatchService myWatcher ) { } @ Override public void run ( ) { } private void processFile ( ) throws Exception { TransportClient client = null ; try { client = new TransportClient ( ) ; for ( String node : this . configJson . getNodes ( ) ) { client . addTransportAddress ( new InetSocketTransportAddress ( node , 9300 ) ) ; } JsonParser parser = new JsonParser ( ) ; JsonObject obj = null ; try { FileReader reader = new FileReader ( index . getPath ( ) ) ; <START_BUG> obj = parser . parse ( new FileReader ( reader . toString ( ) ) ) . getAsJsonObject ( ) ; <END_BUG> reader . close ( ) ; } catch ( Exception ex ) { FileWatcher . LOG . error ( ex , ex ) ; throw ex ; } JsonArray jsonArr = obj . getAsJsonArray ( ) ; Iterator < JsonElement > jai = jsonArr . iterator ( ) ; while ( jai . hasNext ( ) ) { JsonObject pageJObj = jai . next ( ) . getAsJsonObject ( ) ; String modifiedStr = pageJObj . get ( "modified" ) . getAsString ( ) ; String url = pageJObj . get ( "url" ) . getAsString ( ) . trim ( ) ; String title = pageJObj . get ( "title" ) . getAsString ( ) . trim ( ) ; String content = pageJObj . get ( "content" ) . getAsString ( ) . trim ( ) ; String path = pageJObj . get ( "path" ) . getAsString ( ) . trim ( ) ; String categoriesStr = pageJObj . get ( "categories" ) . getAsString ( ) . trim ( ) ; String tag = pageJObj . get ( "tag" ) . getAsString ( ) . trim ( ) ; String type = pageJObj . get ( "type" ) . getAsString ( ) . trim ( ) ; DateFormat format = new SimpleDateFormat ( "yyyy-MM-dd<seq2seq4repair_space>HH:mm:ss<seq2seq4repair_space>Z" , Locale . ENGLISH ) ; format . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; Date newModified = format . parse ( modifiedStr ) ; ProcessedPage processedPage = null ; if ( index . getProcessedPages ( ) . containsKey ( url ) ) { processedPage = index . getProcessedPages ( ) . get ( url ) ; Date lastModified = processedPage . getModified ( ) ; if ( newModified . after ( lastModified ) ) { processedPage = new ProcessedPage ( ) ; processedPage . setUrl ( url ) ; processedPage . setModified ( newModified ) ; processedPage . setTitle ( title ) ; processedPage . setContent ( content ) ; processedPage . setPath ( path ) ; processedPage . setType ( type ) ; for ( String category : categoriesStr . split ( "," ) ) { processedPage . getCategories ( ) . add ( category . trim ( ) ) ; } processedPage . getTags ( ) . add ( tag ) ; if ( updateIndex ( client , processedPage ) ) { index . getProcessedPages ( ) . put ( url , processedPage ) ; preferences . save ( ) ; } } } else { processedPage = new ProcessedPage ( ) ; processedPage . setUrl ( url ) ; processedPage . setModified ( newModified ) ; processedPage . setTitle ( title ) ; processedPage . setContent ( content ) ; processedPage . setPath ( path ) ; processedPage . setType ( type ) ; for ( String category : categoriesStr . split ( "," ) ) { processedPage . getCategories ( ) . add ( category . trim ( ) ) ; } processedPage . getTags ( ) . add ( tag ) ; if ( updateIndex ( client , processedPage ) ) { index . getProcessedPages ( ) . put ( url , processedPage ) ; preferences . save ( ) ; } } } } catch ( Exception ex ) { FileWatcher . LOG . error ( ex , ex ) ; throw ex ; } finally { if ( client != null ) { client . close ( ) ; } } } private boolean updateIndex ( Client client , ProcessedPage processedPage ) { } public void setProcessedIndex ( ProcessedIndex index ) { } public void setPreferences ( IPreferences preferences ) { } public void setConfigJson ( ConfigJson configJson ) { } }

Fix:
obj = parser . parse ( reader . toString ( ) ) . getAsJsonObject ( ) ;