changeset 530:e1116df2893f

8009008: Better manage management-api Summary: Preventing management-api methods from invoking reflection on inappropriate methods; fix reviewed also by Alexander Fomin Reviewed-by: mullan, skoivu
author mkos
date Thu, 21 Mar 2013 11:08:05 -0400
parents 9793150ad1aa
children 4635a58db6b0
files src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java
diffstat 8 files changed, 33 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 import com.sun.org.glassfish.external.statistics.AverageRangeStatistic;
@@ -139,6 +138,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        checkMethod(method);
+
         Object result;
         try {
             result = method.invoke(this, args);
@@ -147,7 +148,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 import com.sun.org.glassfish.external.statistics.BoundaryStatistic;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 
@@ -81,6 +80,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -89,7 +90,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 import com.sun.org.glassfish.external.statistics.BoundedRangeStatistic;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 
@@ -145,6 +144,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -153,7 +154,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 import com.sun.org.glassfish.external.statistics.CountStatistic;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 
@@ -103,6 +102,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -111,7 +112,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 import com.sun.org.glassfish.external.statistics.RangeStatistic;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 
@@ -125,6 +124,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -133,7 +134,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
 
 package com.sun.org.glassfish.external.statistics.impl;
 import com.sun.org.glassfish.external.statistics.Statistic;
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicLong;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -133,4 +133,13 @@
     protected static boolean isValidString(String str) {
         return (str!=null && str.length()>0);
     }
+
+    protected void checkMethod(Method method) {
+        if (method == null || method.getDeclaringClass() == null
+                || !Statistic.class.isAssignableFrom(method.getDeclaringClass())
+                || Modifier.isStatic(method.getModifiers())) {
+            throw new RuntimeException("Invalid method on invoke");
+        }
+    }
+
 }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,6 +90,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -98,7 +100,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }
--- a/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java	Tue Mar 19 14:31:38 2013 -0700
+++ b/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java	Thu Mar 21 11:08:05 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
 package com.sun.org.glassfish.external.statistics.impl;
 
 import com.sun.org.glassfish.external.statistics.TimeStatistic;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.Map;
 import java.lang.reflect.*;
 
@@ -145,6 +144,8 @@
 
     // todo: equals implementation
     public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+        checkMethod(m);
+
         Object result;
         try {
             result = m.invoke(this, args);
@@ -153,7 +154,6 @@
         } catch (Exception e) {
             throw new RuntimeException("unexpected invocation exception: " +
                        e.getMessage());
-        } finally {
         }
         return result;
     }