You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/01/04 12:18:11 UTC

DO NOT REPLY [Bug 52420] New: WordToHtmlConverter NullPointerException in compactChildNodesR method

https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

             Bug #: 52420
           Summary: WordToHtmlConverter NullPointerException in
                    compactChildNodesR method
           Product: POI
           Version: 3.8-dev
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: sachin.gorade@gmail.com
    Classification: Unclassified


While running Apache POI on android with simple application I found that
AbstractWordUtils class throws NullPointerException in compactChildNodesR
method.
This is due to -

 while ( child2.getChildNodes().getLength() > 0 )
  child1.appendChild( child2.getFirstChild() );
// following line causes NullPointerException
 child2.getParentNode().removeChild( child2 );
 i--;

I think a check should be there before removing this child. After adding a
check my simple application is able to convert doc files to html on Android
platform.

Following is the code change that I have done -

 while ( child2.getChildNodes().getLength() > 0 )
  child1.appendChild( child2.getFirstChild() );
 if(child2.getParentNode()!=null){
  child2.getParentNode().removeChild( child2 );
  i--;
 }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


[Bug 52420] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

--- Comment #3 from Yanis <ya...@gmail.com> ---
Created attachment 31044
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31044&action=edit
patch

Patch to fix this error.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 52420] [PATCH] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable
            Summary|WordToHtmlConverter         |[PATCH] WordToHtmlConverter
                   |NullPointerException in     |NullPointerException in
                   |compactChildNodesR method   |compactChildNodesR method

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 52420] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

Yanis <ya...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yanis.biziuk@gmail.com

--- Comment #2 from Yanis <ya...@gmail.com> ---
Created attachment 31043
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31043&action=edit
With this file you can reproduce exception

With this file you can reproduce exception

11-14 13:25:53.108: WARN/System.err(8630): Caused by:
java.lang.NullPointerException
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.AbstractWordUtils.compactChildNodesR(AbstractWordUtils.java:146)
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.WordToHtmlUtils.compactSpans(WordToHtmlUtils.java:238)
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.WordToHtmlConverter.processParagraph(WordToHtmlConverter.java:596)
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.AbstractWordConverter.processParagraphes(AbstractWordConverter.java:1113)
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.WordToHtmlConverter.processSingleSection(WordToHtmlConverter.java:617)
11-14 13:25:53.108: WARN/System.err(8630): at
org.apache.poi.hwpf.converter.AbstractWordConverter.processDocument(AbstractWordConverter.java:722)

this code will solve this error

<code>
if(child2.getParentNode()!=null){
                child2.getParentNode().removeChild( child2 );
                i--;
            }
</code>

but converted html not contains all data from doc file (other bug?)

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 52420] [PATCH] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 52420] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

Sergey Vladimirov <vl...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Sergey Vladimirov <vl...@gmail.com> ---
Sachin,

Could you please provide an example file, that produces an exception?

Sergey

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 52420] [PATCH] WordToHtmlConverter NullPointerException in compactChildNodesR method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52420

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
I have tried to reproduce the issue that you reported, but couldn't, see
r1649147 for the related test-case that I added.

Can you please retry this with the latest version of POI and if you still see
the problem provide some more information, ideally via a self-contained
unit-test?

Also I could not find any text not contained in the resulting document, which
exact part was missing for you? Maybe this is fixed via some other changes in
the meanttime...

-- 
You are receiving this mail because:
You are the assignee for the bug.

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