Skip to content

Commit 9a43949

Browse files
authored
Merge pull request #268 from beccagaspard/npe-fix
Fix for NPE when Thread.currentThread().getContextClassLoader() is null.
2 parents b2f69c7 + 1c8efea commit 9a43949

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

contributors.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ YYYY/MM/DD, github id, Full name, email
6767
2020/07/23, dyuan0226, David Yuan, dyuan1@andrew.cmu.edu
6868
2020/09/06, peteruhnak, Peter Uhnak, i.uhnak@gmail.com
6969
2020/09/16, Dvoreth, Jarmila Emanuela Panwitz, jaremapan@gmail.com
70+
2020/10/01, beccagaspard, Becca Gaspard, beccagaspard at gmail dot com

src/org/stringtemplate/v4/STGroup.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,12 @@ public ST createStringTemplateInternally(ST proto) {
837837
public URL getRootDirURL() { return null; }
838838

839839
public URL getURL(String fileName) {
840-
URL url;
840+
URL url = null;
841841
ClassLoader cl = Thread.currentThread().getContextClassLoader();
842-
url = cl.getResource(fileName);
842+
if ( cl!=null ) url = cl.getResource(fileName);
843843
if ( url==null ) {
844844
cl = this.getClass().getClassLoader();
845-
url = cl.getResource(fileName);
845+
if ( cl!=null ) url = cl.getResource(fileName);
846846
}
847847
return url;
848848
}

0 commit comments

Comments
 (0)