commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Pugh" <ep...@upstate.com>
Subject RE: [configuration] Closing opened input streams
Date Mon, 29 Mar 2004 16:29:25 GMT
Okay, I am thinking of this then:

public void load(String fileName) throws ConfigurationException
    {
		InputStream is=null;
    	try {
    	    is = getPropertyStream(fileName);
    		load(is);
    	}
    	catch (IOException ioe){
    		throw new ConfigurationException("Could not load from file " +
fileName,ioe);
    	}
    	finally{
    	    if(is !=null){
    	        try{
    	            is.close();
    	        }
    	        catch (IOException ioe2){
    	            ioe2.printStackTrace();
    	        }
    	    }
    	}
    }

I don't know, it seems though that if we can't close the stream, should we
keep going?

Eric

> -----Original Message-----
> From: Emmanuel Bourg [mailto:ebourg@micropole-univers.com]
> Sent: Monday, March 29, 2004 1:48 PM
> To: Jakarta Commons Developers List
> Subject: Re: [configuration] Closing opened input streams
>
>
> Eric Pugh wrote:
>
> > We can do that..  Just need to trap and throw the resulting
> IOException as a
> > ConfigurationException then...
>
> I wouldn't throw an exception if close() fails, it doesn't prevent using
> the configuration since we have finished reading the stream at this
> point. A warning or a stack trace would be enough.
>
> Emmanuel Bourg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message