Throws a LifetimeExceededException if the given pooled object's lifetime has exceeded a maximum duration. @param p The pooled object to test. @param maxDuration The maximum lifetime. @throws LifetimeExceededException Thrown if the given pooled object's lifetime has exceeded a maximum dura
(final PooledObject<?> p, final Duration maxDuration)
| 270 | * @throws LifetimeExceededException Thrown if the given pooled object's lifetime has exceeded a maximum duration. |
| 271 | */ |
| 272 | public static void validateLifetime(final PooledObject<?> p, final Duration maxDuration) throws LifetimeExceededException { |
| 273 | if (maxDuration.compareTo(Duration.ZERO) > 0) { |
| 274 | final Duration lifetimeDuration = Duration.between(p.getCreateInstant(), Instant.now()); |
| 275 | if (lifetimeDuration.compareTo(maxDuration) > 0) { |
| 276 | throw new LifetimeExceededException(getMessage("connectionFactory.lifetimeExceeded", lifetimeDuration, maxDuration)); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | private Utils() { |
| 282 | // not instantiable |
no test coverage detected