You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2010/09/04 02:59:17 UTC

Small things by FindBugs

Hi to all,
some little things found by FindBugs:

core/src/org/apache/pivot/beans/BXMLSerializer.java:979 Load of known null value
core/src/org/apache/pivot/beans/BXMLSerializer.java:315 Method
org.apache.pivot.beans.BXMLSerializer$1.putAll(Map) makes inefficient
use of keySet iterator instead of entrySet iterator

wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java:75
org.apache.pivot.wtk.DesktopApplicationContext$DesktopDisplayHost$1
stored into non-transient field
DesktopApplicationContext$DesktopDisplayHost.rootOwnerListener
wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java:147
org.apache.pivot.wtk.DesktopApplicationContext$DesktopDisplayHost$3
stored into non-transient field
DesktopApplicationContext$DesktopDisplayHost.updateHostWindowTitleBarCallback
wtk/src/org/apache/pivot/wtk/ApplicationContext.java:72 Class
org.apache.pivot.wtk.ApplicationContext$DisplayHost defines
non-transient non-serializable instance field display
wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView.java:36
Should org.apache.pivot.wtk.skin.TextAreaSkinParagraphView$Row be a
_static_ inner class?
wtk/src/org/apache/pivot/wtk/TextArea2.java:42 Should
org.apache.pivot.wtk.TextArea2$Paragraph be a _static_ inner class?

wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraActivityIndicatorSkin.java:88
Dead store to increment
wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java:1049
Redundant nullcheck of activeTabButton, which is known to be non-null

Tell me if I have to fix them, or if someone wants to do it :-) .

Bye,
Sandro

Re: Small things by FindBugs

Posted by Sandro Martini <sa...@gmail.com>.
Ok, thanks for the moment.

Bye,
Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/Small-things-by-FindBugs-tp1415684p1426267.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Re: Small things by FindBugs

Posted by Greg Brown <gk...@mac.com>.
>> All of these are because DisplayHost is serializable by inheritance -
>> however, no one should be serializing it. You can ignore them.
> maybe we can try to make it transient ... and if this doesn't solve I agree
> that we can keep it as is.

There's nothing really to solve. DisplayHost shouldn't be serialized. Unfortunately, we can't make it unserializable. But you can make those fields transient if you like.

> tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java:45
> Write to static field
> org.apache.pivot.tutorials.webqueries.Expenses.instance from instance method
> new org.apache.pivot.tutorials.webqueries.Expenses()
>  -- I've seen that the static field is not read, so maybe could be removed
> ...

It is read - it is returned by getInstance().

> tests/src/org/apache/pivot/tests/sql/ResultListTest.java:40
> org.apache.pivot.tests.sql.ResultListTest.main(String[]) may fail to close
> Statement
>  -- just add a nested try/finally also for the close

This has come up before and is a false positive. The "statement" value is only assigned once, and will be closed along with the connection in the existing finally block. 

> demos-server/src/org/apache/pivot/demos/rest/server/RESTDemoServlet.java:133
> org.apache.pivot.demos.rest.server.RESTDemoServlet.doDelete(QueryServlet$Path)
> ignores exceptional return value of java.io.File.delete()
>  -- just catch also missing exceptions ...

I believe this refers to the boolean return value of delete(), not an exception (otherwise, it wouldn't compile). Either way, you can ignore it. It is just a demo application.




Re: Fwd: Small things by FindBugs

Posted by Sandro Martini <sa...@gmail.com>.
Hi Greg,
thanks for the fixes ...

> All of these are because DisplayHost is serializable by inheritance -
> however, no one should be serializing it. You can ignore them.
maybe we can try to make it transient ... and if this doesn't solve I agree
that we can keep it as is.


And, sorry these are still to check (are all trivial):

tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java:45
Write to static field
org.apache.pivot.tutorials.webqueries.Expenses.instance from instance method
new org.apache.pivot.tutorials.webqueries.Expenses()
  -- I've seen that the static field is not read, so maybe could be removed
...

tests/src/org/apache/pivot/tests/sql/ResultListTest.java:40
org.apache.pivot.tests.sql.ResultListTest.main(String[]) may fail to close
Statement
  -- just add a nested try/finally also for the close

demos-server/src/org/apache/pivot/demos/rest/server/RESTDemoServlet.java:133
org.apache.pivot.demos.rest.server.RESTDemoServlet.doDelete(QueryServlet$Path)
ignores exceptional return value of java.io.File.delete()
  -- just catch also missing exceptions ...

I can fix them this evening, tell me if I have to do ...

Thanks,
Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/Small-things-by-FindBugs-tp1415684p1426083.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Fwd: Small things by FindBugs

Posted by Sandro Martini <sa...@gmail.com>.
Sorry, some other small things:

tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java:45
Write to static field
org.apache.pivot.tutorials.webqueries.Expenses.instance from instance
method new org.apache.pivot.tutorials.webqueries.Expenses()

tests/src/org/apache/pivot/tests/sql/ResultListTest.java:40
org.apache.pivot.tests.sql.ResultListTest.main(String[]) may fail to
close Statement

demos-server/src/org/apache/pivot/demos/rest/server/RESTDemoServlet.java:133
org.apache.pivot.demos.rest.server.RESTDemoServlet.doDelete(QueryServlet$Path)
ignores exceptional return value of java.io.File.delete()

Again, tell me what to do.

Bye

Re: Small things by FindBugs

Posted by Greg Brown <gk...@mac.com>.
> core/src/org/apache/pivot/beans/BXMLSerializer.java:979 Load of known null value

This is OK.

> core/src/org/apache/pivot/beans/BXMLSerializer.java:315 Method
> org.apache.pivot.beans.BXMLSerializer$1.putAll(Map) makes inefficient
> use of keySet iterator instead of entrySet iterator

This one has come up before and can be ignored.

> wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java:75
> org.apache.pivot.wtk.DesktopApplicationContext$DesktopDisplayHost$1
> stored into non-transient field
> DesktopApplicationContext$DesktopDisplayHost.rootOwnerListener
> wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java:147
> org.apache.pivot.wtk.DesktopApplicationContext$DesktopDisplayHost$3
> stored into non-transient field
> DesktopApplicationContext$DesktopDisplayHost.updateHostWindowTitleBarCallback
> wtk/src/org/apache/pivot/wtk/ApplicationContext.java:72 Class
> org.apache.pivot.wtk.ApplicationContext$DisplayHost defines
> non-transient non-serializable instance field display

All of these are because DisplayHost is serializable by inheritance - however, no one should be serializing it. You can ignore them.

> wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView.java:36
> Should org.apache.pivot.wtk.skin.TextAreaSkinParagraphView$Row be a
> _static_ inner class?

Not sure about this one.

> wtk/src/org/apache/pivot/wtk/TextArea2.java:42 Should
> org.apache.pivot.wtk.TextArea2$Paragraph be a _static_ inner class?

Possibly. I'm still on the fence about that.

> wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraActivityIndicatorSkin.java:88
> Dead store to increment

This has come up before and is a false positive.

> wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java:1049
> Redundant nullcheck of activeTabButton, which is known to be non-null

Fixed.