You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by bu...@apache.org on 2007/05/10 17:24:29 UTC

DO NOT REPLY [Bug 42381] New: - NullPointerException in JSVGScrollPane.getViewBoxRect when loading svg document with no viewBox attribute

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42381>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42381

           Summary: NullPointerException in JSVGScrollPane.getViewBoxRect
                    when loading svg document with no viewBox attribute
           Product: Batik
           Version: 1.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: ErrorMessage
          Severity: normal
          Priority: P4
         Component: SVG Viewer
        AssignedTo: batik-dev@xmlgraphics.apache.org
        ReportedBy: Jeff.Grigg@asolutions.com
                CC: Jeff.Grigg@asolutions.com


When loading a document with no 'viewBox' attribute in the header, the last line
of the JSVGScrollPane.getViewBoxRect method throws a NullPointerException.  This
happens because the GraphicsNode (gn) is present (not null), but 'getBounds()'
returns null, so 'gn.getBounds().clone()' on the last line of the method throws
NullPointerException.

Suggested fix:
at the end of the JSVGScrollPane.getViewBoxRect method,
change
        return (Rectangle2D)gn.getBounds().clone();
to
        Rectangle2D bounds = gn.getBounds();
        if (bounds == null) return null;

        return (Rectangle2D) bounds.clone();
[end patch]

Impact of bug:  The bug is annoying but not severe: 
EventDispatcher.dispatchEvent catches the exception (as Throwable) and does
'.printStackTrace()', sending it to System.err.  It's annoying and causes people
to get nervous, to see a NullPointerException in the output/log every time an
image is loaded.  But other than that, the effect of the exception is about the
same as more careful null checking and returning null, as is done in most other
cases in the JSVGScrollPane.getViewBoxRect method:  Returning null pretty much
causes the callers to avoid doing any further processing, and the exception
accomplishes the same result, less gracefully.   ;->

Has been observed in both Microsoft Windows and Linux environments.


Example problem document:
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" id="body" width="2048" height="1536" ></svg>

Example good document:
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" id="body" width="2048" height="1536"
viewBox="0 0 800 600" ></svg>


Stack trace:
java.lang.NullPointerException
	at org.apache.batik.swing.JSVGScrollPane.getViewBoxRect(JSVGScrollPane.java:607)
	at
org.apache.batik.swing.JSVGScrollPane.checkAndSetViewBoxRect(JSVGScrollPane.java:584)
	at org.apache.batik.swing.JSVGScrollPane.resizeScrollBars(JSVGScrollPane.java:451)
	at
org.apache.batik.swing.JSVGScrollPane$ScrollListener.gvtRenderingCompleted(JSVGScrollPane.java:391)
	at org.apache.batik.swing.gvt.GVTTreeRenderer$4.dispatch(GVTTreeRenderer.java:193)
	at org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103)
	at org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
	at org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

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

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


DO NOT REPLY [Bug 42381] - NullPointerException in JSVGScrollPane.getViewBoxRect when loading svg document with no viewBox attribute

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42381>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42381


cam@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From cam@apache.org  2007-09-26 20:56 -------
Yep agreed, thanks!  Fixed in SVN now.

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

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