Skip to content

Commit

Permalink
If the pool could not be found, don't throw RuntimeException but retu…
Browse files Browse the repository at this point in the history
…rn null

- all callers were not prepared for RTE except one; that can handle null.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Mar 6, 2023
1 parent 158d2e6 commit 7325902
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -209,7 +209,7 @@ ClassLoader createConnectorClassLoader(String moduleDirectory, ClassLoader paren
* Provide the configuration of the pool
*
* @param poolInfo connection pool info
* @return ResourcePool connection pool configuration
* @return ResourcePool connection pool configuration or null if not found
*/
ResourcePool getConnectionPoolConfig(PoolInfo poolInfo);

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to Eclipse Foundation. All rights reserved.
* Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -1012,6 +1012,7 @@ public void unregisterConnectorNamingEventListener(ConnectorNamingEventListener

@Override
public ResourcePool getConnectionPoolConfig(PoolInfo poolInfo) {
_logger.log(Level.FINEST, "getConnectionPoolConfig(poolInfo={0})", poolInfo);
ResourcePool pool = ResourcesUtil.createInstance().getPoolConfig(poolInfo);
if (pool != null) {
return pool;
Expand All @@ -1024,7 +1025,7 @@ public ResourcePool getConnectionPoolConfig(PoolInfo poolInfo) {
return pool;
}
}
throw new RuntimeException("No pool found by " + poolInfo);
return null;
}

@Override
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -285,11 +285,13 @@ public void switchOnMatching(String rarName, PoolInfo poolInfo) {
public boolean checkAndLoadPool(PoolInfo poolInfo) {
try {
ResourcePool pool = _runtime.getConnectionPoolConfig(poolInfo);
if (pool == null) {
return false;
}
DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(null, pool, null, null);
return loadResourcesAndItsRar(defResConfig);
} catch (ConnectorRuntimeException cre) {
Object params[] = new Object[]{poolInfo, cre};
_logger.log(Level.WARNING, "unable.to.load.connection.pool", params);
} catch (ConnectorRuntimeException e) {
_logger.log(Level.WARNING, "unable.to.load.connection.pool", new Object[]{poolInfo, e});
return false;
}
}
Expand Down

0 comments on commit 7325902

Please sign in to comment.