Re: [netcdf-java] IOSP open file risk

  • Subject: Re: [netcdf-java] IOSP open file risk
  • From: John Caron <caron@xxxxxxxxxxxxxxxx>
  • Date: Sun, 06 Dec 2009 06:32:50 -0700
Ethan Davis wrote:
Hi Doug,

I think the real problem is the lack of documentation on the
AbstractIOServiceProvider. The IOServiceProvider is pretty clear that it
is the IOSP implementations job to close the RAF in the close() method.
But AbstractIOSP doesn't explain what it is doing with the raf variable
or the close() method.

I thinking adding an open(...) method to AbstractIOServiceProvider that
sets the raf variable would both move all the basic raf stuff into
AbstractIOServiceProvider and make it easier to understand.

Here's the javadoc I just wrote to add to AbstractIOServiceProvider:

/**
 * Abstract base class for IOSP implementations that provides default 
implementations
 * of readToByteChannel(...) and readSection(...).
 *
 * <p>Implementations should make sure to handle the RandomAccessFile properly 
by
 * doing one of the following:
 *
 * <ol>
 *   <li> Write your own open(...) and close() methods that keep track of the
 *     RandomAccessFile, be sure to close the RandomAccessFile in your close()
 *     method.</li>
 *   <li> Write your own open(...) and close() methods that call the open(...)
 *     and close() methods defined here, use the "raf" variable also defined
 *     here.</li>
 *   <li> Don't write an open(...) or close() method, so that those defined
 *     here are used.</li>
 * </ol>
 *
 */

that seems reasonable. perhaps add this also:

 /**
  * subclasses should use this (instead of their own private variable) if they 
want to use AbstractIOServiceProvider.close().
  */
 protected ucar.unidata.io.RandomAccessFile raf;



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: