This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new b0bc3ded8c Code clean-up - formatting. No functional change.
b0bc3ded8c is described below
commit b0bc3ded8c43fc086dc40edbbbb0098517468296
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Aug 29 11:46:13 2025 +0100
Code clean-up - formatting. No functional change.
---
java/org/apache/tomcat/util/Diagnostics.java | 166 ++++++++---------
java/org/apache/tomcat/util/ExceptionUtils.java | 17 +-
.../org/apache/tomcat/util/IntrospectionUtils.java | 198 ++++++++++-----------
java/org/apache/tomcat/util/MultiThrowable.java | 17 +-
.../tomcat/util/XReflectionIntrospectionUtils.java | 4 +-
5 files changed, 194 insertions(+), 208 deletions(-)
diff --git a/java/org/apache/tomcat/util/Diagnostics.java
b/java/org/apache/tomcat/util/Diagnostics.java
index c590677b58..f02934e153 100644
--- a/java/org/apache/tomcat/util/Diagnostics.java
+++ b/java/org/apache/tomcat/util/Diagnostics.java
@@ -76,34 +76,25 @@ public class Diagnostics {
private static final Log log = LogFactory.getLog(Diagnostics.class);
- private static final SimpleDateFormat timeformat =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ private static final SimpleDateFormat timeformat = new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
/* Some platform MBeans */
- private static final ClassLoadingMXBean classLoadingMXBean =
- ManagementFactory.getClassLoadingMXBean();
- private static final CompilationMXBean compilationMXBean =
- ManagementFactory.getCompilationMXBean();
- private static final OperatingSystemMXBean operatingSystemMXBean =
- ManagementFactory.getOperatingSystemMXBean();
- private static final RuntimeMXBean runtimeMXBean =
- ManagementFactory.getRuntimeMXBean();
- private static final ThreadMXBean threadMXBean =
- ManagementFactory.getThreadMXBean();
+ private static final ClassLoadingMXBean classLoadingMXBean =
ManagementFactory.getClassLoadingMXBean();
+ private static final CompilationMXBean compilationMXBean =
ManagementFactory.getCompilationMXBean();
+ private static final OperatingSystemMXBean operatingSystemMXBean =
ManagementFactory.getOperatingSystemMXBean();
+ private static final RuntimeMXBean runtimeMXBean =
ManagementFactory.getRuntimeMXBean();
+ private static final ThreadMXBean threadMXBean =
ManagementFactory.getThreadMXBean();
// XXX Not sure whether the following MBeans should better
// be retrieved on demand, i.e. whether they can change
// dynamically in the MBeanServer.
private static final PlatformLoggingMXBean loggingMXBean =
- ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);
- private static final MemoryMXBean memoryMXBean =
- ManagementFactory.getMemoryMXBean();
+ ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);
+ private static final MemoryMXBean memoryMXBean =
ManagementFactory.getMemoryMXBean();
private static final List<GarbageCollectorMXBean> garbageCollectorMXBeans =
- ManagementFactory.getGarbageCollectorMXBeans();
- private static final List<MemoryManagerMXBean> memoryManagerMXBeans =
- ManagementFactory.getMemoryManagerMXBeans();
- private static final List<MemoryPoolMXBean> memoryPoolMXBeans =
- ManagementFactory.getMemoryPoolMXBeans();
+ ManagementFactory.getGarbageCollectorMXBeans();
+ private static final List<MemoryManagerMXBean> memoryManagerMXBeans =
ManagementFactory.getMemoryManagerMXBeans();
+ private static final List<MemoryPoolMXBean> memoryPoolMXBeans =
ManagementFactory.getMemoryPoolMXBeans();
/**
* Check whether thread contention monitoring is enabled.
@@ -146,8 +137,8 @@ public class Diagnostics {
threadMXBean.setThreadCpuTimeEnabled(enable);
boolean checkValue = threadMXBean.isThreadCpuTimeEnabled();
if (enable != checkValue) {
- log.error(sm.getString("diagnostics.setPropertyFail",
"threadCpuTimeEnabled",
- Boolean.valueOf(enable), Boolean.valueOf(checkValue)));
+ log.error(sm.getString("diagnostics.setPropertyFail",
"threadCpuTimeEnabled", Boolean.valueOf(enable),
+ Boolean.valueOf(checkValue)));
}
}
@@ -167,8 +158,8 @@ public class Diagnostics {
classLoadingMXBean.setVerbose(verbose);
boolean checkValue = classLoadingMXBean.isVerbose();
if (verbose != checkValue) {
- log.error(sm.getString("diagnostics.setPropertyFail",
"verboseClassLoading",
- Boolean.valueOf(verbose), Boolean.valueOf(checkValue)));
+ log.error(sm.getString("diagnostics.setPropertyFail",
"verboseClassLoading", Boolean.valueOf(verbose),
+ Boolean.valueOf(checkValue)));
}
}
@@ -176,15 +167,14 @@ public class Diagnostics {
* Set logger level
*
* @param loggerName the name of the logger
- * @param levelName the level to set
+ * @param levelName the level to set
*/
public static void setLoggerLevel(String loggerName, String levelName) {
loggingMXBean.setLoggerLevel(loggerName, levelName);
String checkValue = loggingMXBean.getLoggerLevel(loggerName);
if (!checkValue.equals(levelName)) {
String propertyName = "loggerLevel[" + loggerName + "]";
- log.error(sm.getString("diagnostics.setPropertyFail", propertyName,
- levelName, checkValue));
+ log.error(sm.getString("diagnostics.setPropertyFail",
propertyName, levelName, checkValue));
}
}
@@ -197,8 +187,8 @@ public class Diagnostics {
memoryMXBean.setVerbose(verbose);
boolean checkValue = memoryMXBean.isVerbose();
if (verbose != checkValue) {
- log.error(sm.getString("diagnostics.setPropertyFail",
"verboseGarbageCollection",
- Boolean.valueOf(verbose), Boolean.valueOf(checkValue)));
+ log.error(sm.getString("diagnostics.setPropertyFail",
"verboseGarbageCollection", Boolean.valueOf(verbose),
+ Boolean.valueOf(checkValue)));
}
}
@@ -215,7 +205,7 @@ public class Diagnostics {
* @param name name of the MemoryPoolMXBean or "all"
*/
public static void resetPeakUsage(String name) {
- for (MemoryPoolMXBean mbean: memoryPoolMXBeans) {
+ for (MemoryPoolMXBean mbean : memoryPoolMXBeans) {
if (name.equals("all") || name.equals(mbean.getName())) {
mbean.resetPeakUsage();
}
@@ -225,12 +215,13 @@ public class Diagnostics {
/**
* Set usage threshold in MemoryPoolMXBean
*
- * @param name name of the MemoryPoolMXBean
+ * @param name name of the MemoryPoolMXBean
* @param threshold the threshold to set
+ *
* @return true if setting the threshold succeeded
*/
public static boolean setUsageThreshold(String name, long threshold) {
- for (MemoryPoolMXBean mbean: memoryPoolMXBeans) {
+ for (MemoryPoolMXBean mbean : memoryPoolMXBeans) {
if (name.equals(mbean.getName())) {
try {
mbean.setUsageThreshold(threshold);
@@ -247,12 +238,13 @@ public class Diagnostics {
/**
* Set collection usage threshold in MemoryPoolMXBean
*
- * @param name name of the MemoryPoolMXBean
+ * @param name name of the MemoryPoolMXBean
* @param threshold the collection threshold to set
+ *
* @return true if setting the threshold succeeded
*/
public static boolean setCollectionUsageThreshold(String name, long
threshold) {
- for (MemoryPoolMXBean mbean: memoryPoolMXBeans) {
+ for (MemoryPoolMXBean mbean : memoryPoolMXBeans) {
if (name.equals(mbean.getName())) {
try {
mbean.setCollectionUsageThreshold(threshold);
@@ -270,6 +262,7 @@ public class Diagnostics {
* Formats the thread dump header for one thread.
*
* @param ti the ThreadInfo describing the thread
+ *
* @return the formatted thread dump header
*/
private static String getThreadDumpHeader(ThreadInfo ti) {
@@ -297,6 +290,7 @@ public class Diagnostics {
* Formats the thread dump for one thread.
*
* @param ti the ThreadInfo describing the thread
+ *
* @return the formatted thread dump
*/
private static String getThreadDump(ThreadInfo ti) {
@@ -318,14 +312,15 @@ public class Diagnostics {
if (ti.getLockName() != null) {
sb.append(INDENT2 + "- waiting on (a
").append(ti.getLockName()).append(")");
if (ti.getLockOwnerName() != null) {
- sb.append(" owned by
").append(ti.getLockOwnerName()).append(" Id=").append(ti.getLockOwnerId());
+ sb.append(" owned by
").append(ti.getLockOwnerName()).append(" Id=")
+ .append(ti.getLockOwnerId());
}
sb.append(CRLF);
}
start = false;
}
if (monitorDepths[i] != null) {
- MonitorInfo mi = (MonitorInfo)monitorDepths[i];
+ MonitorInfo mi = (MonitorInfo) monitorDepths[i];
sb.append(INDENT2 + "- locked (a
").append(mi.toString()).append(")").append(" index ");
sb.append(mi.getLockedStackDepth()).append(" frame
").append(mi.getLockedStackFrame().toString());
sb.append(CRLF);
@@ -339,6 +334,7 @@ public class Diagnostics {
* Formats the thread dump for a list of threads.
*
* @param tinfos the ThreadInfo array describing the thread list
+ *
* @return the formatted thread dump
*/
private static String getThreadDump(ThreadInfo[] tinfos) {
@@ -351,17 +347,14 @@ public class Diagnostics {
}
/**
- * Check if any threads are deadlocked. If any, print
- * the thread dump for those threads.
+ * Check if any threads are deadlocked. If any, print the thread dump for
those threads.
*
- * @return a deadlock message and the formatted thread dump
- * of the deadlocked threads
+ * @return a deadlock message and the formatted thread dump of the
deadlocked threads
*/
public static String findDeadlock() {
long[] ids = threadMXBean.findDeadlockedThreads();
if (ids != null) {
- ThreadInfo[] tinfos =
threadMXBean.getThreadInfo(threadMXBean.findDeadlockedThreads(),
- true, true);
+ ThreadInfo[] tinfos =
threadMXBean.getThreadInfo(threadMXBean.findDeadlockedThreads(), true, true);
if (tinfos != null) {
return sm.getString("diagnostics.deadlockFound") + CRLF +
getThreadDump(tinfos);
}
@@ -370,8 +363,7 @@ public class Diagnostics {
}
/**
- * Retrieves a formatted JVM thread dump.
- * The default StringManager will be used.
+ * Retrieves a formatted JVM thread dump. The default StringManager will
be used.
*
* @return the formatted JVM thread dump
*/
@@ -380,29 +372,27 @@ public class Diagnostics {
}
/**
- * Retrieves a formatted JVM thread dump.
- * The given list of locales will be used
- * to retrieve a StringManager.
+ * Retrieves a formatted JVM thread dump. The given list of locales will
be used to retrieve a StringManager.
*
* @param requestedLocales list of locales to use
+ *
* @return the formatted JVM thread dump
*/
public static String getThreadDump(Enumeration<Locale> requestedLocales) {
- return getThreadDump(
- StringManager.getManager(PACKAGE, requestedLocales));
+ return getThreadDump(StringManager.getManager(PACKAGE,
requestedLocales));
}
/**
- * Retrieve a JVM thread dump formatted
- * using the given StringManager.
+ * Retrieve a JVM thread dump formatted using the given StringManager.
*
* @param requestedSm the StringManager to use
+ *
* @return the formatted JVM thread dump
*/
public static String getThreadDump(StringManager requestedSm) {
StringBuilder sb = new StringBuilder();
- synchronized(timeformat) {
+ synchronized (timeformat) {
sb.append(timeformat.format(new Date()));
}
sb.append(CRLF);
@@ -428,8 +418,10 @@ public class Diagnostics {
/**
* Format contents of a MemoryUsage object.
- * @param name a text prefix used in formatting
+ *
+ * @param name a text prefix used in formatting
* @param usage the MemoryUsage object to format
+ *
* @return the formatted contents
*/
private static String formatMemoryUsage(String name, MemoryUsage usage) {
@@ -445,8 +437,7 @@ public class Diagnostics {
}
/**
- * Retrieves a formatted JVM information text.
- * The default StringManager will be used.
+ * Retrieves a formatted JVM information text. The default StringManager
will be used.
*
* @return the formatted JVM information text
*/
@@ -455,11 +446,10 @@ public class Diagnostics {
}
/**
- * Retrieves a formatted JVM information text.
- * The given list of locales will be used
- * to retrieve a StringManager.
+ * Retrieves a formatted JVM information text. The given list of locales
will be used to retrieve a StringManager.
*
* @param requestedLocales list of locales to use
+ *
* @return the formatted JVM information text
*/
public static String getVMInfo(Enumeration<Locale> requestedLocales) {
@@ -467,16 +457,16 @@ public class Diagnostics {
}
/**
- * Retrieve a JVM information text formatted
- * using the given StringManager.
+ * Retrieve a JVM information text formatted using the given StringManager.
*
* @param requestedSm the StringManager to use
+ *
* @return the formatted JVM information text
*/
public static String getVMInfo(StringManager requestedSm) {
StringBuilder sb = new StringBuilder();
- synchronized(timeformat) {
+ synchronized (timeformat) {
sb.append(timeformat.format(new Date()));
}
sb.append(CRLF);
@@ -501,19 +491,25 @@ public class Diagnostics {
sb.append(INDENT1 + "name:
").append(operatingSystemMXBean.getName()).append(CRLF);
sb.append(INDENT1 + "version:
").append(operatingSystemMXBean.getVersion()).append(CRLF);
sb.append(INDENT1 + "architecture:
").append(operatingSystemMXBean.getArch()).append(CRLF);
- sb.append(INDENT1 + "availableProcessors:
").append(operatingSystemMXBean.getAvailableProcessors()).append(CRLF);
+ sb.append(INDENT1 + "availableProcessors:
").append(operatingSystemMXBean.getAvailableProcessors())
+ .append(CRLF);
sb.append(INDENT1 + "systemLoadAverage:
").append(operatingSystemMXBean.getSystemLoadAverage()).append(CRLF);
sb.append(CRLF);
sb.append(requestedSm.getString("diagnostics.vmInfoThreadMxBean"));
sb.append(":" + CRLF);
- sb.append(INDENT1 + "isCurrentThreadCpuTimeSupported:
").append(threadMXBean.isCurrentThreadCpuTimeSupported()).append(CRLF);
+ sb.append(INDENT1 + "isCurrentThreadCpuTimeSupported:
").append(threadMXBean.isCurrentThreadCpuTimeSupported())
+ .append(CRLF);
sb.append(INDENT1 + "isThreadCpuTimeSupported:
").append(threadMXBean.isThreadCpuTimeSupported()).append(CRLF);
sb.append(INDENT1 + "isThreadCpuTimeEnabled:
").append(threadMXBean.isThreadCpuTimeEnabled()).append(CRLF);
- sb.append(INDENT1 + "isObjectMonitorUsageSupported:
").append(threadMXBean.isObjectMonitorUsageSupported()).append(CRLF);
- sb.append(INDENT1 + "isSynchronizerUsageSupported:
").append(threadMXBean.isSynchronizerUsageSupported()).append(CRLF);
- sb.append(INDENT1 + "isThreadContentionMonitoringSupported:
").append(threadMXBean.isThreadContentionMonitoringSupported()).append(CRLF);
- sb.append(INDENT1 + "isThreadContentionMonitoringEnabled:
").append(threadMXBean.isThreadContentionMonitoringEnabled()).append(CRLF);
+ sb.append(INDENT1 + "isObjectMonitorUsageSupported:
").append(threadMXBean.isObjectMonitorUsageSupported())
+ .append(CRLF);
+ sb.append(INDENT1 + "isSynchronizerUsageSupported:
").append(threadMXBean.isSynchronizerUsageSupported())
+ .append(CRLF);
+ sb.append(INDENT1 + "isThreadContentionMonitoringSupported: ")
+
.append(threadMXBean.isThreadContentionMonitoringSupported()).append(CRLF);
+ sb.append(INDENT1 + "isThreadContentionMonitoringEnabled: ")
+
.append(threadMXBean.isThreadContentionMonitoringEnabled()).append(CRLF);
sb.append(CRLF);
sb.append(requestedSm.getString("diagnostics.vmInfoThreadCounts"));
@@ -526,7 +522,7 @@ public class Diagnostics {
sb.append(requestedSm.getString("diagnostics.vmInfoStartup"));
sb.append(":" + CRLF);
- for (String arg: runtimeMXBean.getInputArguments()) {
+ for (String arg : runtimeMXBean.getInputArguments()) {
sb.append(INDENT1).append(arg).append(CRLF);
}
sb.append(CRLF);
@@ -552,30 +548,31 @@ public class Diagnostics {
sb.append(":" + CRLF);
sb.append(INDENT1 + "name:
").append(compilationMXBean.getName()).append(CRLF);
sb.append(INDENT1 + "totalCompilationTime:
").append(compilationMXBean.getTotalCompilationTime()).append(CRLF);
- sb.append(INDENT1 + "isCompilationTimeMonitoringSupported:
").append(compilationMXBean.isCompilationTimeMonitoringSupported()).append(CRLF);
+ sb.append(INDENT1 + "isCompilationTimeMonitoringSupported: ")
+
.append(compilationMXBean.isCompilationTimeMonitoringSupported()).append(CRLF);
sb.append(CRLF);
- for (MemoryManagerMXBean mbean: memoryManagerMXBeans) {
+ for (MemoryManagerMXBean mbean : memoryManagerMXBeans) {
sb.append(requestedSm.getString("diagnostics.vmInfoMemoryManagers",
mbean.getName()));
sb.append(":" + CRLF);
sb.append(INDENT1 + "isValid:
").append(mbean.isValid()).append(CRLF);
sb.append(INDENT1 + "mbean.getMemoryPoolNames: " + CRLF);
String[] names = mbean.getMemoryPoolNames();
Arrays.sort(names);
- for (String name: names) {
+ for (String name : names) {
sb.append(INDENT2).append(name).append(CRLF);
}
sb.append(CRLF);
}
- for (GarbageCollectorMXBean mbean: garbageCollectorMXBeans) {
+ for (GarbageCollectorMXBean mbean : garbageCollectorMXBeans) {
sb.append(requestedSm.getString("diagnostics.vmInfoGarbageCollectors",
mbean.getName()));
sb.append(":" + CRLF);
sb.append(INDENT1 + "isValid:
").append(mbean.isValid()).append(CRLF);
sb.append(INDENT1 + "mbean.getMemoryPoolNames: " + CRLF);
String[] names = mbean.getMemoryPoolNames();
Arrays.sort(names);
- for (String name: names) {
+ for (String name : names) {
sb.append(INDENT2).append(name).append(CRLF);
}
sb.append(INDENT1 + "getCollectionCount:
").append(mbean.getCollectionCount()).append(CRLF);
@@ -586,12 +583,13 @@ public class Diagnostics {
sb.append(requestedSm.getString("diagnostics.vmInfoMemory"));
sb.append(":" + CRLF);
sb.append(INDENT1 + "isVerbose:
").append(memoryMXBean.isVerbose()).append(CRLF);
- sb.append(INDENT1 + "getObjectPendingFinalizationCount:
").append(memoryMXBean.getObjectPendingFinalizationCount()).append(CRLF);
+ sb.append(INDENT1 + "getObjectPendingFinalizationCount: ")
+
.append(memoryMXBean.getObjectPendingFinalizationCount()).append(CRLF);
sb.append(formatMemoryUsage("heap",
memoryMXBean.getHeapMemoryUsage()));
sb.append(formatMemoryUsage("non-heap",
memoryMXBean.getNonHeapMemoryUsage()));
sb.append(CRLF);
- for (MemoryPoolMXBean mbean: memoryPoolMXBeans) {
+ for (MemoryPoolMXBean mbean : memoryPoolMXBeans) {
sb.append(requestedSm.getString("diagnostics.vmInfoMemoryPools",
mbean.getName()));
sb.append(":" + CRLF);
sb.append(INDENT1 + "isValid:
").append(mbean.isValid()).append(CRLF);
@@ -599,7 +597,7 @@ public class Diagnostics {
sb.append(INDENT1 + "mbean.getMemoryManagerNames: " + CRLF);
String[] names = mbean.getMemoryManagerNames();
Arrays.sort(names);
- for (String name: names) {
+ for (String name : names) {
sb.append(INDENT2).append(name).append(CRLF);
}
sb.append(INDENT1 + "isUsageThresholdSupported:
").append(mbean.isUsageThresholdSupported()).append(CRLF);
@@ -608,9 +606,11 @@ public class Diagnostics {
} catch (UnsupportedOperationException ex) {
// IGNORE
}
- sb.append(INDENT1 + "isCollectionUsageThresholdSupported:
").append(mbean.isCollectionUsageThresholdSupported()).append(CRLF);
+ sb.append(INDENT1 + "isCollectionUsageThresholdSupported: ")
+
.append(mbean.isCollectionUsageThresholdSupported()).append(CRLF);
try {
- sb.append(INDENT1 + "isCollectionUsageThresholdExceeded:
").append(mbean.isCollectionUsageThresholdExceeded()).append(CRLF);
+ sb.append(INDENT1 + "isCollectionUsageThresholdExceeded: ")
+
.append(mbean.isCollectionUsageThresholdExceeded()).append(CRLF);
} catch (UnsupportedOperationException ex) {
// IGNORE
}
@@ -625,12 +625,14 @@ public class Diagnostics {
// IGNORE
}
try {
- sb.append(INDENT1 + "getCollectionUsageThreshold:
").append(mbean.getCollectionUsageThreshold()).append(CRLF);
+ sb.append(INDENT1 + "getCollectionUsageThreshold:
").append(mbean.getCollectionUsageThreshold())
+ .append(CRLF);
} catch (UnsupportedOperationException ex) {
// IGNORE
}
try {
- sb.append(INDENT1 + "getCollectionUsageThresholdCount:
").append(mbean.getCollectionUsageThresholdCount()).append(CRLF);
+ sb.append(INDENT1 + "getCollectionUsageThresholdCount: ")
+
.append(mbean.getCollectionUsageThresholdCount()).append(CRLF);
} catch (UnsupportedOperationException ex) {
// IGNORE
}
@@ -646,7 +648,7 @@ public class Diagnostics {
Map<String,String> props = runtimeMXBean.getSystemProperties();
ArrayList<String> keys = new ArrayList<>(props.keySet());
Collections.sort(keys);
- for (String prop: keys) {
+ for (String prop : keys) {
sb.append(INDENT1).append(prop).append(":
").append(props.get(prop)).append(CRLF);
}
sb.append(CRLF);
@@ -655,7 +657,7 @@ public class Diagnostics {
sb.append(":" + CRLF);
List<String> loggers = loggingMXBean.getLoggerNames();
Collections.sort(loggers);
- for (String logger: loggers) {
+ for (String logger : loggers) {
sb.append(INDENT1).append(logger).append(":
level=").append(loggingMXBean.getLoggerLevel(logger));
sb.append(",
parent=").append(loggingMXBean.getParentLoggerName(logger)).append(CRLF);
}
diff --git a/java/org/apache/tomcat/util/ExceptionUtils.java
b/java/org/apache/tomcat/util/ExceptionUtils.java
index bfa691ee31..e94a745e1f 100644
--- a/java/org/apache/tomcat/util/ExceptionUtils.java
+++ b/java/org/apache/tomcat/util/ExceptionUtils.java
@@ -25,8 +25,8 @@ import java.lang.reflect.InvocationTargetException;
public class ExceptionUtils {
/**
- * Checks whether the supplied Throwable is one that needs to be
- * rethrown and swallows all others.
+ * Checks whether the supplied Throwable is one that needs to be rethrown
and swallows all others.
+ *
* @param t the Throwable to check
*/
public static void handleThrowable(Throwable t) {
@@ -44,11 +44,11 @@ public class ExceptionUtils {
}
/**
- * Checks whether the supplied Throwable is an instance of
- * <code>InvocationTargetException</code> and returns the throwable that is
- * wrapped by it, if there is any.
+ * Checks whether the supplied Throwable is an instance of
<code>InvocationTargetException</code> and returns the
+ * throwable that is wrapped by it, if there is any.
*
* @param t the Throwable to check
+ *
* @return <code>t</code> or <code>t.getCause()</code>
*/
public static Throwable unwrapInvocationTargetException(Throwable t) {
@@ -60,10 +60,9 @@ public class ExceptionUtils {
/**
- * NO-OP method provided to enable simple preloading of this class. Since
- * the class is used extensively in error handling, it is prudent to
- * preload it to avoid any failure to load this class masking the true
- * problem during error handling.
+ * NO-OP method provided to enable simple preloading of this class. Since
the class is used extensively in error
+ * handling, it is prudent to preload it to avoid any failure to load this
class masking the true problem during
+ * error handling.
*/
public static void preload() {
// NO-OP
diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index f5b3dfc822..e4ae6f59b2 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -38,29 +38,28 @@ public final class IntrospectionUtils {
private static final StringManager sm =
StringManager.getManager(IntrospectionUtils.class);
/**
- * Find a method with the right name If found, call the method ( if param
is
- * int or boolean we'll convert value to the right type before) - that
means
- * you can have setDebug(1).
- * @param o The object to set a property on
- * @param name The property name
+ * Find a method with the right name If found, call the method ( if param
is int or boolean we'll convert value to
+ * the right type before) - that means you can have setDebug(1).
+ *
+ * @param o The object to set a property on
+ * @param name The property name
* @param value The property value
+ *
* @return <code>true</code> if operation was successful
*/
public static boolean setProperty(Object o, String name, String value) {
return setProperty(o, name, value, true, null);
}
- public static boolean setProperty(Object o, String name, String value,
- boolean invokeSetProperty) {
+ public static boolean setProperty(Object o, String name, String value,
boolean invokeSetProperty) {
return setProperty(o, name, value, invokeSetProperty, null);
}
@SuppressWarnings("null") // setPropertyMethodVoid is not null when used
- public static boolean setProperty(Object o, String name, String value,
- boolean invokeSetProperty, StringBuilder actualMethod) {
+ public static boolean setProperty(Object o, String name, String value,
boolean invokeSetProperty,
+ StringBuilder actualMethod) {
if (log.isTraceEnabled()) {
- log.trace("IntrospectionUtils: setProperty(" +
- o.getClass() + " " + name + "=" + value + ")");
+ log.trace("IntrospectionUtils: setProperty(" + o.getClass() + " "
+ name + "=" + value + ")");
}
if (actualMethod == null && XReflectionIntrospectionUtils.isEnabled())
{
@@ -77,8 +76,8 @@ public final class IntrospectionUtils {
// First, the ideal case - a setFoo( String ) method
for (Method item : methods) {
Class<?>[] paramT = item.getParameterTypes();
- if (setter.equals(item.getName()) && paramT.length == 1
- && "java.lang.String".equals(paramT[0].getName())) {
+ if (setter.equals(item.getName()) && paramT.length == 1 &&
+ "java.lang.String".equals(paramT[0].getName())) {
item.invoke(o, value);
if (actualMethod != null) {
actualMethod.append(item.getName()).append("(\"").append(escape(value)).append("\")");
@@ -90,16 +89,14 @@ public final class IntrospectionUtils {
// Try a setFoo ( int ) or ( boolean )
for (Method method : methods) {
boolean ok = true;
- if (setter.equals(method.getName())
- && method.getParameterTypes().length == 1) {
+ if (setter.equals(method.getName()) &&
method.getParameterTypes().length == 1) {
// match - find the type and invoke it
Class<?> paramType = method.getParameterTypes()[0];
Object[] params = new Object[1];
// Try a setFoo ( int )
- if ("java.lang.Integer".equals(paramType.getName())
- || "int".equals(paramType.getName())) {
+ if ("java.lang.Integer".equals(paramType.getName()) ||
"int".equals(paramType.getName())) {
try {
params[0] = Integer.valueOf(value);
} catch (NumberFormatException ex) {
@@ -107,14 +104,15 @@ public final class IntrospectionUtils {
}
if (actualMethod != null) {
if
("java.lang.Integer".equals(paramType.getName())) {
-
actualMethod.append(method.getName()).append("(Integer.valueOf(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Integer.valueOf(\"").append(value)
+ .append("\"))");
} else {
-
actualMethod.append(method.getName()).append("(Integer.parseInt(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Integer.parseInt(\"").append(value)
+ .append("\"))");
}
}
// Try a setFoo ( long )
- } else if ("java.lang.Long".equals(paramType.getName())
- || "long".equals(paramType.getName())) {
+ } else if ("java.lang.Long".equals(paramType.getName()) ||
"long".equals(paramType.getName())) {
try {
params[0] = Long.valueOf(value);
} catch (NumberFormatException ex) {
@@ -122,25 +120,28 @@ public final class IntrospectionUtils {
}
if (actualMethod != null) {
if ("java.lang.Long".equals(paramType.getName())) {
-
actualMethod.append(method.getName()).append("(Long.valueOf(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Long.valueOf(\"").append(value)
+ .append("\"))");
} else {
-
actualMethod.append(method.getName()).append("(Long.parseLong(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Long.parseLong(\"").append(value)
+ .append("\"))");
}
}
// Try a setFoo ( boolean )
- } else if ("java.lang.Boolean".equals(paramType.getName())
- || "boolean".equals(paramType.getName())) {
+ } else if ("java.lang.Boolean".equals(paramType.getName())
||
+ "boolean".equals(paramType.getName())) {
params[0] = Boolean.valueOf(value);
if (actualMethod != null) {
if
("java.lang.Boolean".equals(paramType.getName())) {
-
actualMethod.append(method.getName()).append("(Boolean.valueOf(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Boolean.valueOf(\"").append(value)
+ .append("\"))");
} else {
-
actualMethod.append(method.getName()).append("(Boolean.parseBoolean(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(Boolean.parseBoolean(\"").append(value)
+ .append("\"))");
}
}
// Try a setFoo ( InetAddress )
- } else if ("java.net.InetAddress".equals(paramType
- .getName())) {
+ } else if
("java.net.InetAddress".equals(paramType.getName())) {
try {
params[0] = InetAddress.getByName(value);
} catch (UnknownHostException exc) {
@@ -150,13 +151,13 @@ public final class IntrospectionUtils {
ok = false;
}
if (actualMethod != null) {
-
actualMethod.append(method.getName()).append("(InetAddress.getByName(\"").append(value).append("\"))");
+
actualMethod.append(method.getName()).append("(InetAddress.getByName(\"").append(value)
+ .append("\"))");
}
// Unknown type
} else {
if (log.isTraceEnabled()) {
- log.trace("IntrospectionUtils: Unknown type " +
- paramType.getName());
+ log.trace("IntrospectionUtils: Unknown type " +
paramType.getName());
}
}
@@ -178,25 +179,24 @@ public final class IntrospectionUtils {
}
// Ok, no setXXX found, try a setProperty("name", "value")
- if (invokeSetProperty && (setPropertyMethodBool != null ||
- setPropertyMethodVoid != null)) {
+ if (invokeSetProperty && (setPropertyMethodBool != null ||
setPropertyMethodVoid != null)) {
if (actualMethod != null) {
-
actualMethod.append("setProperty(\"").append(name).append("\",
\"").append(escape(value)).append("\")");
+
actualMethod.append("setProperty(\"").append(name).append("\",
\"").append(escape(value))
+ .append("\")");
}
Object[] params = new Object[2];
params[0] = name;
params[1] = value;
if (setPropertyMethodBool != null) {
try {
- return ((Boolean) setPropertyMethodBool.invoke(o,
- params)).booleanValue();
- }catch (IllegalArgumentException biae) {
- //the boolean method had the wrong
- //parameter types. let's try the other
- if (setPropertyMethodVoid!=null) {
+ return ((Boolean) setPropertyMethodBool.invoke(o,
params)).booleanValue();
+ } catch (IllegalArgumentException biae) {
+ // the boolean method had the wrong
+ // parameter types. let's try the other
+ if (setPropertyMethodVoid != null) {
setPropertyMethodVoid.invoke(o, params);
return true;
- }else {
+ } else {
throw biae;
}
}
@@ -216,8 +216,8 @@ public final class IntrospectionUtils {
}
/**
- * @param s
- * the input string
+ * @param s the input string
+ *
* @return escaped string, per Java rule
*/
public static String escape(String s) {
@@ -291,40 +291,37 @@ public final class IntrospectionUtils {
}
/**
- * Replaces ${NAME} in the value with the value of the property 'NAME'.
- * Replaces ${NAME:DEFAULT} with the value of the property 'NAME:DEFAULT',
- * if the property 'NAME:DEFAULT' is not set,
- * the expression is replaced with the value of the property 'NAME',
- * if the property 'NAME' is not set,
- * the expression is replaced with 'DEFAULT'.
- * If the property is not set and there is no default the value will be
- * returned unmodified.
+ * Replaces ${NAME} in the value with the value of the property 'NAME'.
Replaces ${NAME:DEFAULT} with the value of
+ * the property 'NAME:DEFAULT', if the property 'NAME:DEFAULT' is not set,
the expression is replaced with the value
+ * of the property 'NAME', if the property 'NAME' is not set, the
expression is replaced with 'DEFAULT'. If the
+ * property is not set and there is no default the value will be returned
unmodified.
*
- * @param value The value
- * @param staticProp Replacement properties
+ * @param value The value
+ * @param staticProp Replacement properties
* @param dynamicProp Replacement properties
+ *
* @return the replacement value
+ *
* @deprecated Use {@link #replaceProperties(String, Hashtable,
PropertySource[], ClassLoader)}
*/
@Deprecated
- public static String replaceProperties(String value,
- Hashtable<Object,Object> staticProp, PropertySource dynamicProp[])
{
+ public static String replaceProperties(String value,
Hashtable<Object,Object> staticProp,
+ PropertySource dynamicProp[]) {
return replaceProperties(value, staticProp, dynamicProp, null);
}
/**
* Replace ${NAME} with the property value.
- * @param value The value
- * @param staticProp Replacement properties
+ *
+ * @param value The value
+ * @param staticProp Replacement properties
* @param dynamicProp Replacement properties
- * @param classLoader Class loader associated with the code requesting the
- * property
+ * @param classLoader Class loader associated with the code requesting the
property
*
* @return the replacement value
*/
- public static String replaceProperties(String value,
- Hashtable<Object,Object> staticProp, PropertySource dynamicProp[],
- ClassLoader classLoader) {
+ public static String replaceProperties(String value,
Hashtable<Object,Object> staticProp,
+ PropertySource dynamicProp[], ClassLoader classLoader) {
if (value == null || value.indexOf('$') < 0) {
return value;
@@ -376,8 +373,8 @@ public final class IntrospectionUtils {
return sb.toString();
}
- private static String getProperty(String name, Hashtable<Object, Object>
staticProp,
- PropertySource[] dynamicProp, ClassLoader classLoader) {
+ private static String getProperty(String name, Hashtable<Object,Object>
staticProp, PropertySource[] dynamicProp,
+ ClassLoader classLoader) {
String v = null;
if (staticProp != null) {
v = (String) staticProp.get(name);
@@ -399,7 +396,9 @@ public final class IntrospectionUtils {
/**
* Reverse of Introspector.decapitalize.
+ *
* @param name The name
+ *
* @return the capitalized string
*/
public static String capitalize(String name) {
@@ -429,8 +428,7 @@ public final class IntrospectionUtils {
return methods;
}
- public static Method findMethod(Class<?> c, String name,
- Class<?>[] params) {
+ public static Method findMethod(Class<?> c, String name, Class<?>[]
params) {
Method[] methods = findMethods(c);
for (Method method : methods) {
if (method.getName().equals(name)) {
@@ -460,14 +458,13 @@ public final class IntrospectionUtils {
return null;
}
- public static Object callMethod1(Object target, String methodN,
- Object param1, String typeParam1, ClassLoader cl) throws Exception
{
+ public static Object callMethod1(Object target, String methodN, Object
param1, String typeParam1, ClassLoader cl)
+ throws Exception {
if (target == null || methodN == null || param1 == null) {
throw new
IllegalArgumentException(sm.getString("introspectionUtils.nullParameter"));
}
if (log.isTraceEnabled()) {
- log.trace("IntrospectionUtils: callMethod1 " +
- target.getClass().getName() + " " +
+ log.trace("IntrospectionUtils: callMethod1 " +
target.getClass().getName() + " " +
param1.getClass().getName() + " " + typeParam1);
}
@@ -479,7 +476,8 @@ public final class IntrospectionUtils {
}
Method m = findMethod(target.getClass(), methodN, params);
if (m == null) {
- throw new
NoSuchMethodException(sm.getString("introspectionUtils.noMethod", methodN,
target, target.getClass()));
+ throw new NoSuchMethodException(
+ sm.getString("introspectionUtils.noMethod", methodN,
target, target.getClass()));
}
try {
return m.invoke(target, param1);
@@ -489,8 +487,8 @@ public final class IntrospectionUtils {
}
}
- public static Object callMethodN(Object target, String methodN,
- Object[] params, Class<?>[] typeParams)
throws Exception {
+ public static Object callMethodN(Object target, String methodN, Object[]
params, Class<?>[] typeParams)
+ throws Exception {
Method m = findMethod(target.getClass(), methodN, typeParams);
if (m == null) {
if (log.isDebugEnabled()) {
@@ -524,20 +522,17 @@ public final class IntrospectionUtils {
Object result = null;
if ("java.lang.String".equals(paramType.getName())) {
result = object;
- } else if ("java.lang.Integer".equals(paramType.getName())
- || "int".equals(paramType.getName())) {
+ } else if ("java.lang.Integer".equals(paramType.getName()) ||
"int".equals(paramType.getName())) {
try {
result = Integer.valueOf(object);
} catch (NumberFormatException ex) {
}
// Try a setFoo ( boolean )
- } else if ("java.lang.Boolean".equals(paramType.getName())
- || "boolean".equals(paramType.getName())) {
+ } else if ("java.lang.Boolean".equals(paramType.getName()) ||
"boolean".equals(paramType.getName())) {
result = Boolean.valueOf(object);
// Try a setFoo ( InetAddress )
- } else if ("java.net.InetAddress".equals(paramType
- .getName())) {
+ } else if ("java.net.InetAddress".equals(paramType.getName())) {
try {
result = InetAddress.getByName(object);
} catch (UnknownHostException exc) {
@@ -549,32 +544,28 @@ public final class IntrospectionUtils {
// Unknown type
} else {
if (log.isTraceEnabled()) {
- log.trace("IntrospectionUtils: Unknown type " +
- paramType.getName());
+ log.trace("IntrospectionUtils: Unknown type " +
paramType.getName());
}
}
if (result == null) {
- throw new
IllegalArgumentException(sm.getString("introspectionUtils.conversionError",
object, paramType.getName()));
+ throw new IllegalArgumentException(
+ sm.getString("introspectionUtils.conversionError", object,
paramType.getName()));
}
return result;
}
/**
- * Checks to see if the specified class is an instance of or assignable
from
- * the specified type. The class <code>clazz</code>, all its superclasses,
- * interfaces and those superinterfaces are tested for a match against
- * the type name <code>type</code>.
- * This is similar to <code>instanceof</code> or {@link
Class#isAssignableFrom}
- * except that the target type will not be resolved into a Class
- * object, which provides some security and memory benefits.
+ * Checks to see if the specified class is an instance of or assignable
from the specified type. The class
+ * <code>clazz</code>, all its superclasses, interfaces and those
superinterfaces are tested for a match against the
+ * type name <code>type</code>. This is similar to <code>instanceof</code>
or {@link Class#isAssignableFrom} except
+ * that the target type will not be resolved into a Class object, which
provides some security and memory benefits.
*
* @param clazz The class to test for a match.
- * @param type The name of the type that <code>clazz</code> must be.
+ * @param type The name of the type that <code>clazz</code> must be.
*
- * @return <code>true</code> if the <code>clazz</code> tested is an
- * instance of the specified <code>type</code>,
- * <code>false</code> otherwise.
+ * @return <code>true</code> if the <code>clazz</code> tested is an
instance of the specified <code>type</code>,
+ * <code>false</code> otherwise.
*/
public static boolean isInstance(Class<?> clazz, String type) {
if (type.equals(clazz.getName())) {
@@ -608,19 +599,16 @@ public final class IntrospectionUtils {
public interface SecurePropertySource extends PropertySource {
/**
- * Obtain a property value, checking that code associated with the
- * provided class loader has permission to access the property. If the
- * {@code classLoader} is {@code null} or if {@code classLoader} does
- * not implement {@link PermissionCheck} then the property value will
be
- * looked up <b>without</b> a call to
+ * Obtain a property value, checking that code associated with the
provided class loader has permission to
+ * access the property. If the {@code classLoader} is {@code null} or
if {@code classLoader} does not implement
+ * {@link PermissionCheck} then the property value will be looked up
<b>without</b> a call to
* {@link PermissionCheck#check(java.security.Permission)}
*
- * @param key The key of the requested property
- * @param classLoader The class loader associated with the code that
- * trigger the property lookup
- * @return The property value or {@code null} if it could not be found
- * or if {@link
PermissionCheck#check(java.security.Permission)}
- * fails
+ * @param key The key of the requested property
+ * @param classLoader The class loader associated with the code that
trigger the property lookup
+ *
+ * @return The property value or {@code null} if it could not be found
or if
+ * {@link PermissionCheck#check(java.security.Permission)}
fails
*/
String getProperty(String key, ClassLoader classLoader);
}
diff --git a/java/org/apache/tomcat/util/MultiThrowable.java
b/java/org/apache/tomcat/util/MultiThrowable.java
index 1faf72e5cb..fb157a6a7b 100644
--- a/java/org/apache/tomcat/util/MultiThrowable.java
+++ b/java/org/apache/tomcat/util/MultiThrowable.java
@@ -21,9 +21,8 @@ import java.util.Collections;
import java.util.List;
/**
- * Wraps a list of throwables as a single throwable. This is intended to be
used
- * when multiple actions are taken where each may throw an exception but all
- * actions are taken before any errors are reported.
+ * Wraps a list of throwables as a single throwable. This is intended to be
used when multiple actions are taken where
+ * each may throw an exception but all actions are taken before any errors are
reported.
* <p>
* This class is <b>NOT</b> threadsafe.
*/
@@ -52,9 +51,8 @@ public class MultiThrowable extends Throwable {
/**
- * @return {@code null} if there are no wrapped throwables, the Throwable
if
- * there is a single wrapped throwable or the current instance of
- * there are multiple wrapped throwables
+ * @return {@code null} if there are no wrapped throwables, the Throwable
if there is a single wrapped throwable or
+ * the current instance of there are multiple wrapped
throwables
*/
public Throwable getThrowable() {
if (size() == 0) {
@@ -76,10 +74,9 @@ public class MultiThrowable extends Throwable {
/**
- * Overrides the default implementation to provide a concatenation of the
- * messages associated with each of the wrapped throwables. Note that the
- * format of the returned String is not guaranteed to be fixed and may
- * change in a future release.
+ * Overrides the default implementation to provide a concatenation of the
messages associated with each of the
+ * wrapped throwables. Note that the format of the returned String is not
guaranteed to be fixed and may change in a
+ * future release.
*/
@Override
public String toString() {
diff --git a/java/org/apache/tomcat/util/XReflectionIntrospectionUtils.java
b/java/org/apache/tomcat/util/XReflectionIntrospectionUtils.java
index 021c90e6c6..a59388dbd6 100644
--- a/java/org/apache/tomcat/util/XReflectionIntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/XReflectionIntrospectionUtils.java
@@ -25,8 +25,8 @@ final class XReflectionIntrospectionUtils {
/**
* Always throws {@link UnsupportedOperationException}
*
- * @param o Unused
- * @param name Unused
+ * @param o Unused
+ * @param name Unused
*
* @return Never returns normally
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]