cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <...@apache.org>
Subject Re: svn commit: r124610 - in cocoon/branches/BRANCH_2_1_X/src/blocks: databases/java/org/apache/cocoon/acting databases/java/org/apache/cocoon/components/source/impl databases/java/org/apache/cocoon/reading hsqldb/java/org/apache/cocoon/components/hsqldb petstore/java/org/apache/cocoon/components/flow/javascript
Date Sat, 08 Jan 2005 13:41:25 GMT
> +                    ResultSet set = null;
> +                    try {
> +                        set = 
> conn.createStatement().executeQuery(selectQuery);

Assuming the preceding statement throws an exception ...

> +                        set.next();
> +                        int value = set.getInt("maxid") + 1;
> +
> +                        statement.setInt(currentIndex, value);
> +
> +                        
> request.setAttribute(keys[i].getAttribute("param"), 
> String.valueOf(value));
> +                    } catch (SQLException sqle){
> +                        getLogger().warn("There was an error closing 
> the ResultSet", sqle);
> +                        throw sqle;
> +                    } finally {
> +                        set.close();
> +                        set.getStatement().close();

... one of these last two statements will thrown a NPE, if I'm not 
mistaken. We should check that set and set.getStatement() are not null, 
right?

Moreover:

> +                        getLogger().warn("There was an error closing 
> the ResultSet", sqle);

The exception is not caught while closing the ResultSet, so the message 
is misleading.

	Ugo

-- 
Ugo Cei - http://beblogging.com/blojsom/blog/

Mime
View raw message