Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A229200D4F for ; Sat, 28 Oct 2017 20:29:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 78FC9160BDC; Sat, 28 Oct 2017 18:29:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 28ADD160C0C for ; Sat, 28 Oct 2017 20:29:27 +0200 (CEST) Received: (qmail 82917 invoked by uid 500); 28 Oct 2017 18:29:26 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 82880 invoked by uid 99); 28 Oct 2017 18:29:26 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Oct 2017 18:29:26 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 5A6A33A16C5 for ; Sat, 28 Oct 2017 18:29:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1020166 [42/44] - in /websites/production/commons/content/proper/commons-pool: ./ api-2.4.3/ api-2.4.3/org/ api-2.4.3/org/apache/ api-2.4.3/org/apache/commons/ api-2.4.3/org/apache/commons/pool2/ api-2.4.3/org/apache/commons/pool2/class-us... Date: Sat, 28 Oct 2017 18:29:13 -0000 To: notifications@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20171028182919.5A6A33A16C5@svn01-us-west.apache.org> archived-at: Sat, 28 Oct 2017 18:29:30 -0000 Added: websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/SecurityManagerCallStack.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/SecurityManagerCallStack.html (added) +++ websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/SecurityManagerCallStack.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,179 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements. See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache license, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License. You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the license for the specific language governing permissions and
+015 * limitations under the license.
+016 */
+017package org.apache.commons.pool2.impl;
+018
+019import java.io.PrintWriter;
+020import java.lang.ref.WeakReference;
+021import java.security.AccessController;
+022import java.security.PrivilegedAction;
+023import java.text.DateFormat;
+024import java.text.SimpleDateFormat;
+025import java.util.ArrayList;
+026import java.util.List;
+027
+028/**
+029 * CallStack strategy using a {@link SecurityManager}. Obtaining the current call stack is much faster via a
+030 * SecurityManger, but access to the underlying method may be restricted by the current SecurityManager. In environments
+031 * where a SecurityManager cannot be created, {@link ThrowableCallStack} should be used instead.
+032 *
+033 * @see RuntimePermission
+034 * @see SecurityManager#getClassContext()
+035 * @since 2.4.3
+036 */
+037public class SecurityManagerCallStack implements CallStack {
+038
+039    private final String messageFormat;
+040    //@GuardedBy("dateFormat")
+041    private final DateFormat dateFormat;
+042    private final PrivateSecurityManager securityManager;
+043
+044    private volatile Snapshot snapshot;
+045
+046    public SecurityManagerCallStack(final String messageFormat, final boolean useTimestamp) {
+047        this.messageFormat = messageFormat;
+048        this.dateFormat = useTimestamp ? new SimpleDateFormat(messageFormat) : null;
+049        this.securityManager = AccessController.doPrivileged(new PrivilegedAction<PrivateSecurityManager>() {
+050            @Override
+051            public PrivateSecurityManager run() {
+052                return new PrivateSecurityManager();
+053            }
+054        });
+055    }
+056
+057    @Override
+058    public boolean printStackTrace(final PrintWriter writer) {
+059        final Snapshot snapshot = this.snapshot;
+060        if (snapshot == null) {
+061            return false;
+062        }
+063        final String message;
+064        if (dateFormat == null) {
+065            message = messageFormat;
+066        } else {
+067            synchronized (dateFormat) {
+068                message = dateFormat.format(snapshot.timestamp);
+069            }
+070        }
+071        writer.println(message);
+072        for (final WeakReference<Class<?>> reference : snapshot.stack) {
+073            writer.println(reference.get());
+074        }
+075        return true;
+076    }
+077
+078    @Override
+079    public void fillInStackTrace() {
+080        snapshot = new Snapshot(securityManager.getCallStack());
+081    }
+082
+083    @Override
+084    public void clear() {
+085        snapshot = null;
+086    }
+087
+088    private static class PrivateSecurityManager extends SecurityManager {
+089        private List<WeakReference<Class<?>>> getCallStack() {
+090            final Class<?>[] classes = getClassContext();
+091            final List<WeakReference<Class<?>>> stack = new ArrayList<WeakReference<Class<?>>>(classes.length);
+092            for (final Class<?> klass : classes) {
+093                stack.add(new WeakReference<Class<?>>(klass));
+094            }
+095            return stack;
+096        }
+097    }
+098
+099    private static class Snapshot {
+100        private final long timestamp = System.currentTimeMillis();
+101        private final List<WeakReference<Class<?>>> stack;
+102
+103        private Snapshot(final List<WeakReference<Class<?>>> stack) {
+104            this.stack = stack;
+105        }
+106    }
+107}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Added: websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/ThrowableCallStack.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/ThrowableCallStack.html (added) +++ websites/production/commons/content/proper/commons-pool/apidocs/src-html/org/apache/commons/pool2/impl/ThrowableCallStack.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,148 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements. See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache license, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License. You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the license for the specific language governing permissions and
+015 * limitations under the license.
+016 */
+017package org.apache.commons.pool2.impl;
+018
+019import java.io.PrintWriter;
+020import java.text.DateFormat;
+021import java.text.SimpleDateFormat;
+022
+023/**
+024 * CallStack strategy that uses the stack trace from a {@link Throwable}. While being the most portable method of
+025 * obtaining the current call stack, this is also the slowest way to do it. In environments where a new SecurityManager
+026 * can be created, it is preferred to use {@link SecurityManagerCallStack}.
+027 *
+028 * @see Throwable#fillInStackTrace()
+029 * @since 2.4.3
+030 */
+031public class ThrowableCallStack implements CallStack {
+032
+033    private final String messageFormat;
+034    //@GuardedBy("dateFormat")
+035    private final DateFormat dateFormat;
+036
+037    private volatile Snapshot snapshot;
+038
+039    public ThrowableCallStack(final String messageFormat, final boolean useTimestamp) {
+040        this.messageFormat = messageFormat;
+041        this.dateFormat = useTimestamp ? new SimpleDateFormat(messageFormat) : null;
+042    }
+043
+044    @Override
+045    public synchronized boolean printStackTrace(final PrintWriter writer) {
+046        final Snapshot snapshot = this.snapshot;
+047        if (snapshot == null) {
+048            return false;
+049        }
+050        final String message;
+051        if (dateFormat == null) {
+052            message = messageFormat;
+053        } else {
+054            synchronized (dateFormat) {
+055                message = dateFormat.format(snapshot.timestamp);
+056            }
+057        }
+058        writer.println(message);
+059        snapshot.printStackTrace(writer);
+060        return true;
+061    }
+062
+063    @Override
+064    public void fillInStackTrace() {
+065        snapshot = new Snapshot();
+066    }
+067
+068    @Override
+069    public void clear() {
+070        snapshot = null;
+071    }
+072
+073    private static class Snapshot extends Throwable {
+074        private final long timestamp = System.currentTimeMillis();
+075    }
+076}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Added: websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.BaseObject.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.BaseObject.html (added) +++ websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.BaseObject.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,106 @@ + + + + +Coverage Report + + + + +
Coverage Report - org.apache.commons.pool2.BaseObject
+
 
+ + + + +
Classes in this File Line Coverage Branch Coverage Complexity
BaseObject
87%
7/8
N/A
1
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.pool2;
 18  
 
 19  
 /**
 20  
  * A base class for common functionality.
 21  
  *
 22  
  * @since 2.4.3
 23  
  */
 24  751
 public abstract class BaseObject {
 25  
 
 26  
     @Override
 27  
     public String toString() {
 28  3
         final StringBuilder builder = new StringBuilder();
 29  3
         builder.append(getClass().getSimpleName());
 30  3
         builder.append(" [");
 31  3
         toStringAppendFields(builder);
 32  3
         builder.append("]");
 33  3
         return builder.toString();
 34  
     }
 35  
 
 36  
     /**
 37  
      * Used by sub-classes to include the fields defined by the sub-class in the
 38  
      * {@link #toString()} output.
 39  
      *
 40  
      * @param builder Field names and values are appended to this object
 41  
      */
 42  
     protected void toStringAppendFields(final StringBuilder builder) {
 43  
         // do nothing by default, needed for b/w compatibility.
 44  0
     }
 45  
 }
+ + + + Added: websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStack.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStack.html (added) +++ websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStack.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,132 @@ + + + + +Coverage Report + + + + +
Coverage Report - org.apache.commons.pool2.impl.CallStack
+
 
+ + + + +
Classes in this File Line Coverage Branch Coverage Complexity
CallStack
N/A
N/A
N/A< /div>
1
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements. See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache license, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License. You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the license for the specific language governing permissions and
 15  
  * limitations under the license.
 16  
  */
 17  
 package org.apache.commons.pool2.impl;
 18  
 
 19  
 import org.apache.commons.pool2.PooledObject;
 20  
 import org.apache.commons.pool2.UsageTracking;
 21  
 
 22  
 import java.io.PrintWriter;
 23  
 
 24  
 /**
 25  
  * Strategy for obtaining and printing the current call stack. This is primarily useful for
 26  
  * {@linkplain UsageTracking usage tracking} so that different JVMs and configurations can use more efficient strategies
 27  
  * for obtaining the current call stack.
 28  
  *
 29  
  * @see CallStackUtils
 30  
  * @since 2.4.3
 31  
  */
 32  
 public interface CallStack {
 33  
 
 34  
     /**
 35  
      * Prints the current stack trace if available to a PrintWriter. The format is undefined and is primarily useful
 36  
      * for debugging issues with {@link PooledObject} usage in user code.
 37  
      *
 38  
      * @param writer a PrintWriter to write the curren stack trace to if available
 39  
      * @return true if a stack trace was available to print or false if nothing was printed
 40  
      */
 41  
     boolean printStackTrace(final PrintWriter writer);
 42  
 
 43  
     /**
 44  
      * Takes a snapshot of the current call stack. Subsequent calls to {@link #printStackTrace(PrintWriter)} will print
 45  
      * out that stack trace until it is {@linkplain #clear() cleared}.
 46  
      */
 47  
     void fillInStackTrace();
 48  
 
 49  
     /**
 50  
      * Clears the current stack trace snapshot. Subsequent calls to {@link #printStackTrace(PrintWriter)} will be
 51  
      * no-ops until another call to {@link #fillInStackTrace()}.
 52  
      */
 53  
     void clear();
 54  
 }
+ + + + Added: websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStackUtils.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStackUtils.html (added) +++ websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.CallStackUtils.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,136 @@ + + + + +Coverage Report + + + + +
Coverage Report - org.apache.commons.pool2.impl.CallStackUtils
+
 
+ + + + +
Classes in this File Line Coverage Branch Coverage Complexity
CallStackUtils
50%
6/12
50%
2/4
2.667
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements. See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache license, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License. You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the license for the specific language governing permissions and
 15  
  * limitations under the license.
 16  
  */
 17  
 package org.apache.commons.pool2.impl;
 18  
 
 19  
 import java.security.AccessControlException;
 20  
 
 21  
 /**
 22  
  * Utility methods for {@link CallStack}.
 23  
  *
 24  
  * @since 2.4.3
 25  
  */
 26  
 public final class CallStackUtils {
 27  
 
 28  
     private static final boolean CAN_CREATE_SECURITY_MANAGER;
 29  
 
 30  
     static {
 31  1
         CAN_CREATE_SECURITY_MANAGER = canCreateSecurityManager();
 32  1
     }
 33  
 
 34  
     private static boolean canCreateSecurityManager() {
 35  1
         final SecurityManager manager = System.getSecurityManager();
 36  1
         if (manager == null) {
 37  1
             return true;
 38  
         }
 39  
         try {
 40  0
             manager.checkPermission(new RuntimePermission("createSecurityManager"));
 41  0
             return true;
 42  0
         } catch (final AccessControlException ignored) {
 43  0
             return false;
 44  
         }
 45  
     }
 46  
 
 47  
     /**
 48  
      * Constructs a new {@link CallStack} using the fastest allowed strategy.
 49  
      *
 50  
      * @param messageFormat message (or format) to print first in stack traces
 51  
      * @param useTimestamp  if true, interpret message as a SimpleDateFormat and print the created timestamp; otherwise,
 52  
      *                      print message format literally
 53  
      * @return a new CallStack
 54  
      */
 55  
     public static CallStack newCallStack(final String messageFormat, final boolean useTimestamp) {
 56  23856
         return CAN_CREATE_SECURITY_MANAGER ? new SecurityManagerCallStack(messageFormat, useTimestamp)
 57  
             : new ThrowableCallStack(messageFormat, useTimestamp);
 58  
     }
 59  
 
 60  0
     private CallStackUtils() {
 61  0
     }
 62  
 }
+ + + + Added: websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.SecurityManagerCallStack.html ============================================================================== --- websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.SecurityManagerCallStack.html (added) +++ websites/production/commons/content/proper/commons-pool/cobertura/org.apache.commons.pool2.impl.SecurityManagerCallStack.html Sat Oct 28 18:29:09 2017 @@ -0,0 +1,207 @@ + + + + +Coverage Report + + + + +
Coverage Report - org.apache.commons.pool2.impl.SecurityManagerCallStack
+
 
+ + + + + + + +
Classes in this File Line Coverage Branch Coverage Complexity
SecurityManagerCallStack
100%
22/22
100%
8/8
1.857
SecurityManagerCallStack$1
100%
2/2
N/A
1.857
SecurityManagerCallStack$PrivateSecurityManager
100%
6/6
100%
2/2
1.857
SecurityManagerCallStack$Snapshot
100%
5/5
N/A
1.857
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements. See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache license, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License. You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the license for the specific language governing permissions and
 15  
  * limitations under the license.
 16  
  */
 17  
 package org.apache.commons.pool2.impl;
 18  
 
 19  
 import java.io.PrintWriter;
 20  
 import java.lang.ref.WeakReference;
 21  
 import java.security.AccessController;
 22  
 import java.security.PrivilegedAction;
 23  
 import java.text.DateFormat;
 24  
 import java.text.SimpleDateFormat;
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * CallStack strategy using a {@link SecurityManager}. Obtaining the current call stack is much faster via a
 30  
  * SecurityManger, but access to the underlying method may be restricted by the current SecurityManager. In environments
 31  
  * where a SecurityManager cannot be created, {@link ThrowableCallStack} should be used instead.
 32  
  *
 33  
  * @see RuntimePermission
 34  
  * @see SecurityManager#getClassContext()
 35  
  * @since 2.4.3
 36  
  */
 37  
 public class SecurityManagerCallStack implements CallStack {
 38  
 
 39  
     private final String messageFormat;
 40  
     //@GuardedBy("dateFormat")
 41  
     private final DateFormat dateFormat;
 42  
     private final PrivateSecurityManager securityManager;
 43  
 
 44  
     private volatile Snapshot snapshot;
 45  
 
 46  23854
     public SecurityManagerCallStack(final String messageFormat, final boolean useTimestamp) {
 47  23857
         this.messageFormat = messageFormat;
 48  23857
         this.dateFormat = useTimestamp ? new SimpleDateFormat(messageFormat) : null;
 49  47711
         this.securityManager = AccessController.doPrivileged(new PrivilegedAction<PrivateSecurityManager>() {
 50  
             @Override
 51  
             public PrivateSecurityManager run() {
 52  23859
                 return new PrivateSecurityManager();
 53  
             }
 54  
         });
 55  23860
     }
 56  
 
 57  
     @Override
 58  
     public boolean printStackTrace(final PrintWriter writer) {
 59  8
         final Snapshot snapshot = this.snapshot;
 60  8
         if (snapshot == null) {
 61  2
             return false;
 62  
         }
 63  
         final String message;
 64  6
         if (dateFormat == null) {
 65  2
             message = messageFormat;
 66  
         } else {
 67  4
             synchronized (dateFormat) {
 68  4
                 message = dateFormat.format(snapshot.timestamp);
 69  4
             }
 70  
         }
 71  6
         writer.println(message);
 72  6
         for (final WeakReference<Class<?>> reference : snapshot.stack) {
 73  174
             writer.println(reference.get());
 74  174
         }
 75  6
         return true;
 76  
     }
 77  
 
 78  
     @Override
 79  
     public void fillInStackTrace() {
 80  26
         snapshot = new Snapshot(securityManager.getCallStack());
 81  26
     }
 82  
 
 83  
     @Override
 84  
     public void clear() {
 85  132392
         snapshot = null;
 86  132464
     }
 87  
 
 88  47744
     private static class PrivateSecurityManager extends SecurityManager {
 89  
         private List<WeakReference<Class<?>>> getCallStack() {
 90  26
             final Class<?>[] classes = getClassContext();
 91  26
             final List<WeakReference<Class<?>>> stack = new ArrayList<WeakReference<Class<?>>>(classes.length);
 92  804
             for (final Class<?> klass : classes) {
 93  778
                 stack.add(new WeakReference<Class<?>>(klass));
 94  
             }
 95  26
             return stack;
 96  
         }
 97  
     }
 98  
 
 99  36
     private static class Snapshot {
 100  26
         private final long timestamp = System.currentTimeMillis();
 101  
         private final List<WeakReference<Class<?>>> stack;
 102  
 
 103  26
         private Snapshot(final List<WeakReference<Class<?>>> stack) {
 104  26
             this.stack = stack;
 105  26
         }
 106  
     }
 107  
 }
+ + + +