2626import javax .naming .InitialContext ;
2727import javax .naming .NamingException ;
2828import javax .sql .DataSource ;
29- import java .io .File ;
30- import java .io .FileInputStream ;
31- import java .io .IOException ;
29+ import java .io .*;
3230import java .lang .reflect .Modifier ;
3331import java .security .AccessControlException ;
3432import java .sql .Connection ;
@@ -1199,8 +1197,7 @@ else if (value == null) {
11991197
12001198 private void loadProperties (String propertyFileName )
12011199 {
1202- final var propFile = new File (propertyFileName );
1203- try (final var is = propFile .isFile () ? new FileInputStream (propFile ) : this .getClass ().getResourceAsStream (propertyFileName )) {
1200+ try (final var is = openPropertiesInputStream (propertyFileName )) {
12041201 if (is != null ) {
12051202 var props = new Properties ();
12061203 props .load (is );
@@ -1215,6 +1212,18 @@ private void loadProperties(String propertyFileName)
12151212 }
12161213 }
12171214
1215+ private InputStream openPropertiesInputStream (String propertyFileName ) throws FileNotFoundException {
1216+ final var propFile = new File (propertyFileName );
1217+ if (propFile .isFile ()) {
1218+ return new FileInputStream (propFile );
1219+ }
1220+ var propertiesInputStream = this .getClass ().getResourceAsStream (propertyFileName );
1221+ if (propertiesInputStream == null ) {
1222+ propertiesInputStream = this .getClass ().getClassLoader ().getResourceAsStream (propertyFileName );
1223+ }
1224+ return propertiesInputStream ;
1225+ }
1226+
12181227 private String generatePoolName ()
12191228 {
12201229 final var prefix = "HikariPool-" ;
0 commit comments