webtier@glassfish.java.net

fix for issue 7947 - disabling of HTTP listeners leads to ArithmeticException

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Wed, 22 Apr 2009 09:32:52 +1000

Hi Jan,

Thanks for fixing the other issue! I'll have a look at your diffs.

About the issue I just raised (issue #7947), an easy fix would be to
just add a 0 check (see attachment).

I could not reproduce the error on just the DAS, and I'm not sure the
Monitoring page should be showing disabled HTTP listeners at all, but
the source code (both in V2.1 and V3) is asking for an
ArithmeticException to occur, so I think this patch is a good start.

Regards,
Dies


Index: StatsUtil.java
===================================================================
RCS file: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/web/stats/StatsUtil.java,v
retrieving revision 1.8
diff -u -r1.8 StatsUtil.java
--- StatsUtil.java 5 May 2007 05:36:07 -0000 1.8
+++ StatsUtil.java 13 Feb 2009 12:51:54 -0000
@@ -229,8 +229,13 @@
                 num++;
             }
         }
-
- return total/num;
+
+ int result = 0;
+ if (0 < num) {
+ result = total/num;
+ }
+
+ return result;
     }