8006078: [findbugs] java.lang.management.ThreadInfo returns mutable objects
Summary: Cloned the array before returning to caller.
Reviewed-by: dholmes, fparain
Contributed-by: amit.sapre@oracle.com
--- a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java Tue Nov 01 17:20:45 2016 -0700
+++ b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java Thu Nov 03 12:04:40 2016 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -554,7 +554,7 @@
* @return an array of {@code StackTraceElement} objects of the thread.
*/
public StackTraceElement[] getStackTrace() {
- return stackTrace;
+ return stackTrace.clone();
}
/**
@@ -868,7 +868,7 @@
* @since 1.6
*/
public MonitorInfo[] getLockedMonitors() {
- return lockedMonitors;
+ return lockedMonitors.clone();
}
/**
@@ -885,7 +885,7 @@
* @since 1.6
*/
public LockInfo[] getLockedSynchronizers() {
- return lockedSynchronizers;
+ return lockedSynchronizers.clone();
}
private static final StackTraceElement[] NO_STACK_TRACE =