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 Robert Gurol <ro...@signavio.com> on 2013/05/08 16:47:48 UTC

Batik and FindBugs

Hi,

quite some time ago on the batik dev mailing list, a suggestion was made to
use the Java Byte Code checker FindBugs (http://findbugs.sourceforge.net)
to assist development for Batik.

I recently investigated an issue with the software I work on, running
FindBugs on batik as well. I think you may find the results interesting - I
will attach them as both a browseable html file (zipped, its browser URL is
referred to as <HTML_FILE> in the following for fragment addressing) and
FindBugs 2.0.2 project files (in case you want to use the (free) FindBugs
GUI software, cf. http://findbugs.sourceforge.net/downloads.html).

To mention a few issues that are found, let me give you some I noticed
among the ones output by FindBugs:
* In many places, String or Integer comparisons are done using the ==
operator where the equals(...) method may be more appropriate
(<HTML_FILE>#ES_COMPARING_STRINGS_WITH_EQ). Even if constants are used
throughout the code, the assumption that the variable will not get re-boxed
etc should not be made.

* this piece of code in org.apache.batik.util.Service may throw unexpected
NPEs (first if should use "!=") (<HTML_FILE>#NP_LOAD_OF_KNOWN_NULL_VALUE)
if ( br == null ){
    try{
        br.close();
    } catch ( IOException ignored ){}
    br = null;
}

* many static fields are not final (potentially dangerous issue with regard
to multiple instances of a class running)
(<HTML_FILE>#MS_SHOULD_BE_FINAL)

* MacRenderer, where there was some synchronization issue in the past, may
cause trouble as the synchronization variable may get re-assigned (Only
shows up in my IDE FindBugs plugin output somehow, sorry.
MacRenderer.workImg field,
http://findbugs.sourceforge.net/bugDescriptions.html#ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD;
similar AbstractDocument.elementsById
http://findbugs.sourceforge.net/bugDescriptions.html#ML_SYNC_ON_UPDATED_FIELD
)

Of course, the FindBugs GUI (or, alternatively, its Eclipse IDE plugin
equivalent) provides a much better breakdown, and provides functionality
for sorting, searching and classifying the issues found by different
criteria; the HTML is just there to give you a zero-threshold impression.
Filtering may also filter issues by severity, in case you are upset by the
sheer number of "mostly harmless" issues reported.

I'll gladly answer any FindBugs questions that may come up.

If any of the issues seem relevant for my own Batik use case (cf. users
mailing list), I'll gladly write a fix and submit a patch.

Best regards,

Robert



-- 
________________________________________________________

Besuchen Sie uns/Meet us:

Process Solutions Day <http://www.gfo-kongress.de/>: 2013: 14.+15.05.2013
in Frankfurt, Germany
Signavio Customer
Day<http://www.signavio.com/de/events/signavio-ladt-zum-kundentag-in-berlin-ein/>:
13.09.2013 in Berlin, Germany
Frankfurter Buchmesse <http://www.buchmesse.de/>: 09.-13.10.2013 in
Frankfurt, Germany
Messekongress "IT für
Versicherungsunternehmen"<http://www.assekuranz-messekongress.de/portal/de/messekongresse/it/aktuelles_2/index.xhtml>:
26.+27.11.2013
in Leipzig, Germany
________________________________________________________


Robert Gurol
Software Developer
robert.gurol@signavio.com
T +49 30 488 172 50
F +49 30 250 43 747

Signavio GmbH
Goethestr. 2-3
10623 Berlin

HRB 121584 B Amtsgericht Charlottenburg, Ust-ID: DE265675123
Geschäftsführer: Dr. Gero Decker, Torben Schreiter
________________________________________________________

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser E-Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.