Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
197 stars 82 forks source link

Fix of resource loading for application container environments, like spring-boot #100

Closed zhemaituk closed 2 years ago

zhemaituk commented 2 years ago

closes #99

Petersoj commented 2 years ago

Looks good, however, according to the Javadoc here for class.getClassLoader:

Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader.

So in the event of such a bootstrap class loader, this would fail. Perhaps the following is better:

ClassLoader classLoader = PropertyUtil.class.getClassLoader();
if (classLoader == null) {
    classLoader = ClassLoader.getSystemClassLoader();
}

Thoughts?

zhemaituk commented 2 years ago

Good point. Updated.