You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/01/07 11:32:00 UTC

svn commit: r1056244 - in /tomcat/trunk: java/org/apache/naming/java/javaURLContextFactory.java res/findbugs/filter-false-positives.xml webapps/docs/changelog.xml

Author: markt
Date: Fri Jan  7 10:31:59 2011
New Revision: 1056244

URL: http://svn.apache.org/viewvc?rev=1056244&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50554
Various FindBugs / Eclipse warnings
Silence the false positives

Modified:
    tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
    tomcat/trunk/res/findbugs/filter-false-positives.xml
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java?rev=1056244&r1=1056243&r2=1056244&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java (original)
+++ tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java Fri Jan  7 10:31:59 2011
@@ -80,6 +80,8 @@ public class javaURLContextFactory
     /**
      * Crete a new Context's instance.
      */
+    @SuppressWarnings("unchecked")
+    @Override
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                     Hashtable<?,?> environment)
         throws NamingException {
@@ -94,6 +96,8 @@ public class javaURLContextFactory
     /**
      * Get a new (writable) initial context.
      */
+    @SuppressWarnings("unchecked")
+    @Override
     public Context getInitialContext(Hashtable<?,?> environment)
         throws NamingException {
         if (ContextBindings.isThreadBound() || 
@@ -105,7 +109,7 @@ public class javaURLContextFactory
 
         // If the thread is not bound, return a shared writable context
         if (initialContext == null) {
-            synchronized(getClass()) {
+            synchronized(javaURLContextFactory.class) {
                 if (initialContext == null) {
                     initialContext = new NamingContext(
                             (Hashtable<String,Object>)environment, MAIN);

Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1056244&r1=1056243&r2=1056244&view=diff
==============================================================================
--- tomcat/trunk/res/findbugs/filter-false-positives.xml (original)
+++ tomcat/trunk/res/findbugs/filter-false-positives.xml Fri Jan  7 10:31:59 2011
@@ -5,6 +5,10 @@
     <Method name="checkResources" />
     <Bug code="SWL" />
   </Match>
+  <Match>
+    <Class name="org.apache.naming.java.javaURLContextFactory" />
+    <Bug code="Nm" />
+  </Match>
   <!--  Generated code -->
   <Match>
     <Class name="org.apache.el.parser.ELParserTokenManager" />

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1056244&r1=1056243&r2=1056244&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan  7 10:31:59 2011
@@ -193,6 +193,9 @@
         ensure that a subsequent request for that directory does not result in a
         404 response. (markt)
       </fix>
+      <fix>
+        <bug>50554</bug>: Code clean up. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Re: svn commit: r1056244 - in /tomcat/trunk: java/org/apache/naming/java/javaURLContextFactory.java res/findbugs/filter-false-positives.xml webapps/docs/changelog.xml

Posted by sebb <se...@gmail.com>.
On 7 January 2011 10:32,  <ma...@apache.org> wrote:
> Author: markt
> Date: Fri Jan  7 10:31:59 2011
> New Revision: 1056244
>
> URL: http://svn.apache.org/viewvc?rev=1056244&view=rev
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50554
> Various FindBugs / Eclipse warnings
> Silence the false positives
>
> Modified:
>    tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
>    tomcat/trunk/res/findbugs/filter-false-positives.xml
>    tomcat/trunk/webapps/docs/changelog.xml
>
> Modified: tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java?rev=1056244&r1=1056243&r2=1056244&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java (original)
> +++ tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java Fri Jan  7 10:31:59 2011
> @@ -80,6 +80,8 @@ public class javaURLContextFactory
>     /**
>      * Crete a new Context's instance.
>      */
> +    @SuppressWarnings("unchecked")

It would be helpful to document which line(s) generate the warning,
and why it is safe to suppress it.

Ideally also localise the annotation to the specific line(s) that
causes the warning.
This can usually be done by adding a temporary local variable.
At present the suppression applies to the whole method, so subsequent
additions of "unchecked" casts won't be detected.

> +    @Override
>     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
>                                     Hashtable<?,?> environment)
>         throws NamingException {
> @@ -94,6 +96,8 @@ public class javaURLContextFactory
>     /**
>      * Get a new (writable) initial context.
>      */
> +    @SuppressWarnings("unchecked")

Ditto.

> +    @Override
>     public Context getInitialContext(Hashtable<?,?> environment)
>         throws NamingException {
>         if (ContextBindings.isThreadBound() ||
> @@ -105,7 +109,7 @@ public class javaURLContextFactory
>
>         // If the thread is not bound, return a shared writable context
>         if (initialContext == null) {
> -            synchronized(getClass()) {
> +            synchronized(javaURLContextFactory.class) {
>                 if (initialContext == null) {
>                     initialContext = new NamingContext(
>                             (Hashtable<String,Object>)environment, MAIN);
>
> Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml
> URL: http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1056244&r1=1056243&r2=1056244&view=diff
> ==============================================================================
> --- tomcat/trunk/res/findbugs/filter-false-positives.xml (original)
> +++ tomcat/trunk/res/findbugs/filter-false-positives.xml Fri Jan  7 10:31:59 2011
> @@ -5,6 +5,10 @@
>     <Method name="checkResources" />
>     <Bug code="SWL" />
>   </Match>
> +  <Match>
> +    <Class name="org.apache.naming.java.javaURLContextFactory" />
> +    <Bug code="Nm" />
> +  </Match>
>   <!--  Generated code -->
>   <Match>
>     <Class name="org.apache.el.parser.ELParserTokenManager" />
>
> Modified: tomcat/trunk/webapps/docs/changelog.xml
> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1056244&r1=1056243&r2=1056244&view=diff
> ==============================================================================
> --- tomcat/trunk/webapps/docs/changelog.xml (original)
> +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan  7 10:31:59 2011
> @@ -193,6 +193,9 @@
>         ensure that a subsequent request for that directory does not result in a
>         404 response. (markt)
>       </fix>
> +      <fix>
> +        <bug>50554</bug>: Code clean up. (markt)
> +      </fix>
>     </changelog>
>   </subsection>
>   <subsection name="Coyote">
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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