You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2013/02/26 05:49:49 UTC

svn commit: r1450020 - /sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java

Author: ieb
Date: Tue Feb 26 04:49:48 2013
New Revision: 1450020

URL: http://svn.apache.org/r1450020
Log:
SLING-2742 added NPE protection should the repository method not be accessable.

Modified:
    sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java

Modified: sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java?rev=1450020&r1=1450019&r2=1450020&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/jmx/StatisticsMBeanImpl.java Tue Feb 26 04:49:48 2013
@@ -107,6 +107,9 @@ public class StatisticsMBeanImpl impleme
     public Object getAttribute(String attribute)
             throws AttributeNotFoundException, MBeanException,
             ReflectionException {
+        if ( statistics == null ) {
+            throw new AttributeNotFoundException("No Statistics Available");
+        }
         try {
             if (attribute.startsWith("PerSecond_")) {
                 return getTimeSeries(attribute.substring("PerSecond_".length()))
@@ -149,6 +152,9 @@ public class StatisticsMBeanImpl impleme
      * @see javax.management.DynamicMBean#getAttributes(java.lang.String[])
      */
     public AttributeList getAttributes(String[] attributes) {
+        if ( statistics == null ) {
+            return new AttributeList();
+        }
         AttributeList al = new AttributeList();
         Iterator<Entry<Type, TimeSeries>> statIter = statistics.iterator();
         while (statIter.hasNext()) {
@@ -184,6 +190,10 @@ public class StatisticsMBeanImpl impleme
      * @see javax.management.DynamicMBean#getMBeanInfo()
      */
     public MBeanInfo getMBeanInfo() {
+        if ( statistics == null ) {
+            return new MBeanInfo(this.getClass().getName(),
+                "Repository Statistics Unavailable", null, null, null, null);
+        }
         List<MBeanAttributeInfo> attributesList = new ArrayList<MBeanAttributeInfo>();
         Set<Type> types = new HashSet<Type>();
         Iterator<Entry<Type, TimeSeries>> statIter = statistics.iterator();
@@ -280,6 +290,9 @@ public class StatisticsMBeanImpl impleme
      * .apache.jackrabbit.api.stats.RepositoryStatistics.Type)
      */
     public TimeSeries getTimeSeries(Type type) {
+        if ( statistics == null ) {
+            throw new IllegalStateException("Repository statistics are not available");
+        }
         return statistics.getTimeSeries(type);
     }