United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5042109 NullPointerException in reading an rtf-file into a javax.swing.text.rtf.RTFEdito
JDK-5042109 : NullPointerException in reading an rtf-file into a javax.swing.text.rtf.RTFEdito

Details
Type:
Bug
Submit Date:
2004-05-04
Status:
Closed
Updated Date:
2004-07-22
Project Name:
JDK
Resolved Date:
2004-06-14
Component:
client-libs
OS:
solaris_9
Sub-Component:
javax.swing
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2_02
Fixed Versions:
1.4.2_06 (06)

Related Reports
Backport:

Sub Tasks

Description
###@###.### 2004-05-04

Note:
This sure looks like a same bug id #4822283 (same stack trace and the same problem description) which has not been evaluated yet.

Problem Description from Sun's ISV Software AG:

To describe a technical problem that occurs when reading an rtf-file into a javax.swing.text.rtf.RTFEditorKit object.

# Problem description:

We want to extract the document content from the attached rtf file (probably generated with Word 2002):
<<theDocument.rtf>>
Reading this file into a javax.swing.text.rtf.RTFEditorKit instance fails with a java.lang.NullpointerException.

      (For those in the cc:-list who know in the entire history of this problem: the document content to be returned from the RTFEditorKit object serves as input for Tamino's nonXML-indexer. Because we do not get the content but only the Exception, there is nothing we can write into our index.)

To ease analysis of this problem we have written a small stand-alone Java program which reads "theDocument.rtf" into an RTFEditorKit object. This fails with a java.lang.NullPointerException in an RTFReader object.

<<TestClass.java>>
We compiled and executed this program with java versions "1.4.1_01" and "1.4.2_02", respectively.
We also tried the "1.5.0-beta" runtime with a class that had been generated with a "1.4.2_02" compiler.
In all cases we get a stacktrace like this one:

      odessy@PCMGM2 XML PARIS D [181] --> $JDK_ROOT/bin/java -version
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
      odessy@PCMGM2 XML PARIS D [182] --> $JDK_ROOT/bin/java TestClass
      Exception in thread "main" java.lang.NullPointerException
              at javax.swing.text.rtf.RTFReader$StylesheetDestination$StyleDefiningDestination.close(RTFReader.java:914)
              at javax.swing.text.rtf.RTFReader.setRTFDestination(RTFReader.java:247)
              at javax.swing.text.rtf.RTFReader.handleKeyword(RTFReader.java:477)
              at javax.swing.text.rtf.RTFParser.write(RTFParser.java:232)
              at javax.swing.text.rtf.AbstractFilter.readFromReader(AbstractFilter.java:105)
              at javax.swing.text.rtf.RTFEditorKit.read(RTFEditorKit.java:111)
              at TestClass.main(TestClass.java:42)

# Our analysis and fix:
We had downloaded source code from http://wwws.sun.com/software/communitysource/j2se/java2/index.html. Our analysis with this code indicates that our document contains an unknown stylesheet definition. Handling of such unknown stylesheet definitions runs into a piece of code in RTFReader.java that should never be entered (according to the source code documentation).

We were looking for a fix and found two solutions which allowed us to read "theDocument.rtf" without problems.

    * Fix no. 1:

      With this modified source code the NullPointerException does no longer occur.
      <<RTFReader.java>>
    * Fix no. 2:

      We have tried another fix which is much simpler to implement and which also works fine with the given rtf-file, but we are not sure whether this is a valid solution:

      <<RTFReader_SimpleFix_.java>>

The current status is, that we could copy some classes of the javax.swing.text.rtf package, rename them, and implement one of our fixes in the RTFReader.java source code. However (of course), we are not allowed to do that.

On the other hand, as long as we do not have a fix for this, we (i.e. Nextance, i.e. Sun) cannot index such documents.
Do you have any ideas how we can find to a quick fix to this problem?

I hope you understand our problem, if not or if you have any questions don't hesitate to ask, I'll try to answer asap.

Best regards,

        Michael Gesmann 


**Business Justification sent from SoftwareAG**

Nextance/Software AG Critical Issue


Background:

Nextance (www.Nextance.com) provides a Contract Management System.  Because of t
he complex and unstructured nature of contracts, Nextance built their applicatio
n on top of Tamino, Software AG's XML Data Management system.

This Issue:

One of Nextance's largest customers is Sun Microsystems.  One deployment of the
Contract Management System  is in Sun's Market Development group.  Sun is curren
tly running a Proof of Concept for a  new group.  One of Sun's key requirements
is the storing, managing and quering of RTF documents.  Tamino supports non-XML
documents. However, there are problems storing the RTF documents as required by
Sun (see 5-3-2004 e-mail from Michael Gesmann, Software AG R&D for full details)
.  This issue is preventing Sun from deploying the Contract Management System.

The History:

March 11:  Nextance contacted Software AG and logged the issue as Critical in So
ftware AG's Customer Support Sytem
April 1:  Issue raised at Crisis in Software AG's Customer Support Sytem
R&D was able to isolate the problem to java code
Developed a work-around, but the work-around violated Java licensing
April 7:  Contacted Sun Alliance Management
Needed to locate right Java contact to address the issue
April 19:  Sun Java legal contact identified
Bill Lard identified at the legal contact, discussions started
April 30:  Call with MDE to identify how to address the issue
Must funnel all discussions with Sun Product Management through Market Developme
nt and Market Development Engineering (MDE)
May 3:  Software AG provided details of problem and proposed work-around to MDE

The Bottom Line:

Because this issue is impacting Software AG's best Global Alliance partners (Sun
) and one of Software AG's best Technology Partners (Nextance), we are pushing t
o get this resolved ASAP.  When resolved, Sun will be able to deploy their syste
m into production.


                                    

Comments
WORK AROUND

ISV provided a fix in the source file.  See problem description for two workarounds by ISV.
                                     
2004-07-23
EVALUATION

The simples way to avoid null pointer exception:

javax/swing/text/rtf/RTFReader.java

*** /tmp/geta2164       Mon May 10 11:28:35 2004
--- RTFReader.java      Fri May  7 17:07:29 2004
***************
*** 911,917 ****
        }                                                                                                     

        public void close() {
!           int semicolon = styleName.indexOf(';');
            if (semicolon > 0)
                styleName = styleName.substring(0, semicolon);
            definedStyles.put(new Integer(number), this);
--- 911,917 ----
        }                                                                                                     

        public void close() {
!           int semicolon = (styleName == null) ? 0 : styleName.indexOf(';');
            if (semicolon > 0)
                styleName = styleName.substring(0, semicolon);
            definedStyles.put(new Integer(number), this);

                                     
2004-07-23
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.2_06
generic
tiger-rc

FIXED IN:
1.4.2_06
tiger-rc

INTEGRATED IN:
1.4.2_06
tiger-b56
tiger-rc

VERIFIED IN:
1.4.2_06


                                     
2004-07-23



Hardware and Software, Engineered to Work Together