Changeset 18195

Show
Ignore:
Timestamp:
12.12.2008 15:04:56 (11 years ago)
Author:
ak19
Message:

Fixed a bug where GS3 crashed with infinite ?s printed to the screen when creating a new collection (or closing an open one). The bug turned out to be that the XML stream was read as chars instead of as ints.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/util/RemoveContentBeforeRootElementXMLReader.java

    r18170 r18195  
    1818 
    1919        //read up to the xml indicator 
    20         int foundBytes = 0;  
    21         char c = 0; 
     20        int foundBytes = 0; 
     21        int c = 0; 
    2222        while ( c != -1 ) { 
    2323            try { 
    24                 c = (char)ur.read(); 
     24                c = ur.read(); 
    2525            } catch( Exception e ) { 
    2626                System.err.println( "Exception while reading underlying Reader in RemoveContentBeforeRootElementXMLReader" ); 
    2727            } 
    28  
    29             if ( c == xmlIndicator[foundBytes] ) { 
     28             
     29            if ( c == (int)xmlIndicator[foundBytes] ) { 
    3030                foundBytes++; 
    31             } else { 
    32                 System.out.print( c ); 
     31            } else {                 
     32                if ( foundBytes != 0 ) { 
     33                for ( int i=0; i<foundBytes; i++ ) { 
     34                    System.out.print( (char)xmlIndicator[i] ); 
     35                } 
    3336                foundBytes = 0; 
     37                } 
     38                if ( c != -1 ) { 
     39                System.out.print( (char)c ); 
     40                } 
    3441            } 
    3542 
    3643            if ( foundBytes == xmlIndicator.length ) { 
    37                 //System.out.println(); 
    38                 return; 
     44                return; 
    3945            } 
    4046 
    4147        } 
     48         
    4249        System.err.println( "RemoveContentBeforeRootElementXMLReader:\n" + 
    43             "The XML being loaded was did not contain the '<?xml' string as expected" ); 
    44  
     50            "The XML being loaded did not contain the '<?xml' string as expected" ); 
    4551    } 
    4652