changeset 391:5942fdde2af6 icedtea-2.2.9

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 1257bb90b9c0
children fee1b3fd5220
files sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java
diffstat 8 files changed, 33 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java	Wed May 22 17:57:04 2013 +0100
+++ b/sources/jaxws_src/src/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;
     }