Bug 39607 - [PATCH] NullPointerException in RtfTableRow : tableBorderAttributes
Summary: [PATCH] NullPointerException in RtfTableRow : tableBorderAttributes
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: rtf (show other bugs)
Version: 0.92
Hardware: PC Windows XP
: P2 regression
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-05-18 11:18 UTC by Julien Aymé
Modified: 2012-04-01 06:29 UTC (History)
0 users



Attachments
source of TestFop.java (1.24 KB, text/plain)
2006-05-18 11:20 UTC, Julien Aymé
Details
modified RtfTableRow.java (14.01 KB, text/plain)
2006-05-18 11:22 UTC, Julien Aymé
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Aymé 2006-05-18 11:18:39 UTC
The changes in the class RtfTableRow between 0.91 and 0.92 now generate a
NullPointerException, 
due to the variable tableBorderAttributes declared at line 189:
RtfAttributes tableBorderAttributes = getTable().getBorderAttributes();
being null when the code: 
tableBorderAttributes.getValue(....)   (line 209)
is called.

Example of java code which worked under 0.91 and doesn't work anymore:

// Start of class
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;

public class TestFop {

    public static void main(String[] args) {
        try {
            FileWriter writer = new FileWriter(new File("C:/test.doc"));
            RtfFile f = new RtfFile(writer);

            RtfDocumentArea doc = f.startDocumentArea();

            RtfSection section = doc.newSection();

            RtfParagraph paragraph = section.newParagraph();
            paragraph.newText("Testing fop - rtf module - class RtfTableRow");
            paragraph.close();

            RtfTable table = section.newTable(null); 
            RtfTableRow row = table.newTableRow();
            row.newTableCell(2000).newParagraph().newText("blah");
            row.newTableCell(5000).newParagraph().newText("doubleBlah");
            row.close();
            table.close();
            section.close();
            doc.close();
            f.flush();
            
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
//End of class


Stacktrace when the code is executed:
Exception in thread "main" java.lang.NullPointerException
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow.writeRowAndCellsDefintions(RtfTableRow.java:209)
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow.writeRtfContent(RtfTableRow.java:142)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
	at
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
	at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile.flush(RtfFile.java:218)
	at test.TestFop.main(TestFop.java:37)



Simple way to fix this:
add a test to check wether tableBorderAttributes is null.
(I will join the modified RtfTableRow.java later)
Comment 1 Julien Aymé 2006-05-18 11:20:24 UTC
Created attachment 18311 [details]
source of TestFop.java
Comment 2 Julien Aymé 2006-05-18 11:22:39 UTC
Created attachment 18312 [details]
modified RtfTableRow.java

I've added the following lines: 203,204,237
Comment 3 Jeremias Maerki 2006-05-18 14:03:03 UTC
Applied. Thanks, especially for the sample code to reproduce the problem!
http://svn.apache.org/viewvc?rev=407553&view=rev

Julien, please send proposed code changes as Subversion patches in the future.
That makes it a lot easier for us. Thank you! See:
http://xmlgraphics.apache.org/fop/dev/index.html#patches
Comment 4 Glenn Adams 2012-04-01 06:29:49 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed