Changeset 3839


Ignore:
Timestamp:
03/20/08 10:25:17 (12 years ago)
Author:
melissa
Message:

Fixed close/reopen logic so that it no longer breaks with files constructed from a byte array.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/RandomAccessStream.java

    r3827 r3839  
    227227    afp = 0; 
    228228    length = raf.length(); 
    229     fileCache.put(this, Boolean.TRUE); 
    230     openFiles++; 
    231     if (openFiles > MAX_FILES) cleanCache(); 
    232229  } 
    233230 
     
    237234  public DataInputStream getInputStream() { 
    238235    try { 
    239       if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     236      if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    240237    } 
    241238    catch (IOException e) { 
     
    263260  /** Gets the number of bytes in the file. */ 
    264261  public long length() throws IOException { 
    265     if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     262    if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    266263    return length; 
    267264  } 
     
    277274    dis = null; 
    278275    buf = null; 
    279     if (((Boolean) fileCache.get(this)).booleanValue()) { 
     276    if (Boolean.TRUE.equals(fileCache.get(this))) { 
    280277      fileCache.put(this, Boolean.FALSE); 
    281278      openFiles--; 
     
    504501 
    505502  public int available() throws IOException { 
    506     if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     503    if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    507504    int available = dis != null ? dis.available() + ext : 
    508505      (int) (length() - getFilePointer()); 
     
    513510  public void mark(int readLimit) { 
    514511    try { 
    515       if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     512      if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    516513    } 
    517514    catch (IOException e) { } 
     
    522519 
    523520  public void reset() throws IOException { 
    524     if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     521    if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    525522    dis.reset(); 
    526523    fp = length() - dis.available(); 
     
    564561   */ 
    565562  protected int checkEfficiency(int toRead) throws IOException { 
    566     if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
     563    if (Boolean.FALSE.equals(fileCache.get(this))) reopen(); 
    567564    int oldBufferSize = bufferSizes[bufferSizes.length - 1]; 
    568565 
     
    769766    while (closed < toClose) { 
    770767      if (!this.equals(files[ndx]) && 
    771         !fileCache.get(files[ndx]).equals(Boolean.FALSE)) 
     768        !fileCache.get(files[ndx]).equals(Boolean.FALSE) && 
     769        files[ndx].file != null) 
    772770      { 
    773771        try { files[ndx].close(); } 
Note: See TracChangeset for help on using the changeset viewer.