You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by wg...@apache.org on 2005/01/05 15:56:53 UTC
svn commit: r124215 - /jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
Author: wglass
Date: Wed Jan 5 06:56:50 2005
New Revision: 124215
URL: http://svn.apache.org/viewcvs?view=rev&rev=124215
Log:
Fix potential NPE in DataResourceLoader.
http://issues.apache.org/bugzilla/show_bug.cgi?id=19440
Modified:
jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
Modified: jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
Url: http://svn.apache.org/viewcvs/jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?view=diff&rev=124215&p1=jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java&r1=124214&p2=jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java&r2=124215
==============================================================================
--- jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Wed Jan 5 06:56:50 2005
@@ -104,7 +104,7 @@
* @author <a href="mailto:david.kinnvall@alertir.com">David Kinnvall</a>
* @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
* @author <a href="mailto:lachiewicz@plusnet.pl">Sylwester Lachiewicz</a>
- * @version $Id: DataSourceResourceLoader.java,v 1.12 2004/03/20 03:35:51 dlr Exp $
+ * @version $Id$
*/
public class DataSourceResourceLoader extends ResourceLoader
{
@@ -168,8 +168,16 @@
{
if (rs.next())
{
- return new
- BufferedInputStream(rs.getAsciiStream(templateColumn));
+ InputStream ascStream = rs.getAsciiStream(templateColumn);
+ if (ascStream != null)
+ return new BufferedInputStream(ascStream);
+ else {
+ String msg = "DataSourceResourceLoader Error: cannot find resource "
+ + name;
+ rsvc.error(msg);
+
+ throw new ResourceNotFoundException(msg);
+ }
}
else
{
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: svn commit: r124215 - /jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
Posted by Will Glass-Husain <wg...@forio.com>.
Thanks. This was already pointed out to me in a private email. Genuinely
appreciate any tips on this stuff, especially from other committers.
WILL
----- Original Message -----
From: "Henning P. Schmiedehausen" <hp...@intermeta.de>
Newsgroups: hometree.jakarta.velocity.dev
To: <ve...@jakarta.apache.org>
Sent: Friday, January 07, 2005 12:55 AM
Subject: Re: svn commit: r124215 -
/jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
> wglass@apache.org writes:
>
>>- return new
>>-
>>BufferedInputStream(rs.getAsciiStream(templateColumn));
>>+ InputStream ascStream =
>>rs.getAsciiStream(templateColumn);
>>+ if (ascStream != null)
>>+ return new BufferedInputStream(ascStream);
>>+ else {
>>+ String msg = "DataSourceResourceLoader
>>Error: cannot find resource "
>>+ + name;
>>+ rsvc.error(msg);
>>+
>>+ throw new ResourceNotFoundException(msg);
>>+ }
>
> I have to be obnoxcious, but:
>
> http://jakarta.apache.org/velocity/code-standards.html
>
> InputStream ascStream = rs.getAsciiStream(templateColumn);
> if (ascStream != null)
> {
> return new BufferedInputStream(ascStream);
> }
> else
> {
> String msg = "DataSourceResourceLoader Error: cannot find resource "
> + name;
> rsvc.error(msg);
>
> throw new ResourceNotFoundException(msg);
> }
>
> While I'm trying to stay out of the "becoming-jon-stevens-syndrome", I
> know that especially for new committers it is hard to get rid of ones
> well-used coding style. I'd prefer if we keep the code base in an
> uniform code style (i.e. the one that is documented on the
> code-standards page).
>
> Regards
> Henning
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
>
> RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
> Linux, Java, perl, Solaris -- Consulting, Training, Development
>
> What is more important to you...
> [ ] Product Security
> or [ ] Quality of Sales and Marketing Support
> -- actual question from a Microsoft customer survey
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: svn commit: r124215 - /jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
wglass@apache.org writes:
>- return new
>- BufferedInputStream(rs.getAsciiStream(templateColumn));
>+ InputStream ascStream = rs.getAsciiStream(templateColumn);
>+ if (ascStream != null)
>+ return new BufferedInputStream(ascStream);
>+ else {
>+ String msg = "DataSourceResourceLoader Error: cannot find resource "
>+ + name;
>+ rsvc.error(msg);
>+
>+ throw new ResourceNotFoundException(msg);
>+ }
I have to be obnoxcious, but:
http://jakarta.apache.org/velocity/code-standards.html
InputStream ascStream = rs.getAsciiStream(templateColumn);
if (ascStream != null)
{
return new BufferedInputStream(ascStream);
}
else
{
String msg = "DataSourceResourceLoader Error: cannot find resource "
+ name;
rsvc.error(msg);
throw new ResourceNotFoundException(msg);
}
While I'm trying to stay out of the "becoming-jon-stevens-syndrome", I
know that especially for new committers it is hard to get rid of ones
well-used coding style. I'd prefer if we keep the code base in an
uniform code style (i.e. the one that is documented on the
code-standards page).
Regards
Henning
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
What is more important to you...
[ ] Product Security
or [ ] Quality of Sales and Marketing Support
-- actual question from a Microsoft customer survey
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org