pgshiping / jforum2

Automatically exported from code.google.com/p/jforum2
Other
0 stars 0 forks source link

SummaryDAO seems not working on Oracle. It tries to read a blob as a String which results a NullPointerException #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. install jforum 2.3.3
2. run SummaryTest
3.

What is the expected output? What do you see instead?
Expectation is success. Instead the test fails with following exception:

net.jforum.exceptions.MailException: freemarker.core.InvalidReferenceException: 
Expression post.text is undefined on line 9, column 3 in 
mail/en_US/summaryMessage.txt.
    at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
    at freemarker.core.Expression.getStringValue(Expression.java:118)
    at freemarker.core.Expression.getStringValue(Expression.java:93)
    at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
    at freemarker.core.Environment.visit(Environment.java:428)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.Environment.process(Environment.java:199)
    at freemarker.template.Template.process(Template.java:237)
    at net.jforum.util.mail.Spammer.processTemplate(Spammer.java:323)
    at net.jforum.util.mail.Spammer.prepareMessage(Spammer.java:267)
    at net.jforum.summary.SummaryModel.sendPostsSummary(SummaryModel.java:108)
    at net.jforum.summary.SummaryTest.testSendMails(SummaryTest.java:146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: freemarker.core.InvalidReferenceException: Expression post.text is 
undefined on line 9, column 3 in mail/en_US/summaryMessage.txt.
    ... 38 more

Please use labels and text to provide additional information.

The cause is that GenericSummaryDAO.fillPost(ResultSet rs) method tries to read
a blob as string:

post.setText(rs.getString("post_text"));

instead of that something like this should be done:

        Blob blob = rs.getBlob("post_text");
        String textString = new String(blob.getBytes(1, (int)blob.length()));
        post.setText(textString);

Original issue reported on code.google.com by peter.ri...@gmail.com on 23 Apr 2012 at 9:32

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r181.

This fixes the failing testcase. Please review and close.

Original comment by peter.ri...@gmail.com on 24 Apr 2012 at 9:22

GoogleCodeExporter commented 8 years ago
Close

Original comment by andow...@gmail.com on 24 May 2012 at 10:39