# HG changeset patch # User mkos # Date 1363878485 14400 # Node ID 3532f4415fd5df3b5c8e25ad35d980fae5432f25 # Parent 3b68ea3b56d8101f852bda1c6dcd8b600b7a1c62 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 diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java Wed May 22 18:20:24 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"); + } + } + } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java Wed May 22 18:20:24 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; } diff -r 3b68ea3b56d8 -r 3532f4415fd5 sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java --- a/sources/jaxws_src/src/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java Wed May 22 18:20:24 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; }