Class PoolUtilities

java.lang.Object
org.apache.tomcat.jdbc.pool.PoolUtilities

public class PoolUtilities extends Object
Utility methods for managing JDBC pool properties: the copy the connect path hands to the JDBC driver, and the password-masked copies the JMX and bean property getters expose, are all built here.
  • Field Details

  • Constructor Details

    • PoolUtilities

      public PoolUtilities()
      Default constructor.
  • Method Details

    • clone

      public static Properties clone(Properties p)
      Creates a shallow copy of the given properties. Entries that the source resolves to a String through a defaults table are materialized into the copy as plain values, so the copy resolves every String the source resolves and needs no defaults table of its own; the defaults table itself is not carried over. A String directly present in the source under the same key shadows the defaults there and takes precedence in the copy. A non-String directly present value shadows nothing, because Properties.getProperty(String) falls through to the defaults whenever the direct value is not a String, so where the source resolves a String under such a key the resolved String takes its place in the copy; entries the source resolves to no String are copied as they are, and a non-String held only in a defaults table - which neither the source nor the copy resolves - does not appear in the copy at all.

      The copy is per-key best effort against a source modified concurrently: an entry the modification removes may still be copied, and an entry it adds is copied only if it was already there when the copy sampled the source. A caller that needs the copy to show one state the source was actually in must serialize it against the modifications itself.

      Parameters:
      p - the properties to clone, not null
      Returns:
      a new Properties instance, without a defaults table, resolving every String the source resolves and carrying over its other direct entries
      Throws:
      NullPointerException - if the source is null
    • cloneWithoutPassword

      public static Properties cloneWithoutPassword(Properties p)
      Creates a copy of the given properties as clone(Properties) does, with every credential entry removed. A credential entry is one whose key is recognised by isCredentialKey(String): password, pass and pwd, ignoring case and surrounding whitespace. The copy carries no defaults table, so the removal also reaches a credential the source only resolved through its defaults - a reference copy would let the remove walk past the defaults table and leave the credential resolvable.
      Parameters:
      p - the properties to clone, not null
      Returns:
      a new Properties instance with all entries except the credentials
      Throws:
      NullPointerException - if the source is null