@@ -57,7 +57,7 @@ public class Catalog implements EntityResolver2 {
5757 private Map <String , Catalog > delegateCatalogs ;
5858 private String workDir ;
5959 private String base = "" ;
60- private String documentParent = "" ;
60+ private final ThreadLocal < String > documentParent = ThreadLocal . withInitial (() -> "" ) ;
6161 private String prefer = "public" ;
6262
6363 protected Catalog (String catalogFile )
@@ -554,7 +554,7 @@ public String matchSystem(String baseURI, String systemId) {
554554 }
555555 // this resource is not in catalog.
556556
557- if (!documentParent .isEmpty ()) {
557+ if (!documentParent .get (). isEmpty ()) {
558558 // try to find the file in parent folder
559559 File f = new File (systemId );
560560 String name = f .getAbsolutePath ();
@@ -566,14 +566,14 @@ public String matchSystem(String baseURI, String systemId) {
566566 name = f .getName ();
567567 }
568568 }
569- File parent = new File (documentParent );
569+ File parent = new File (documentParent . get () );
570570 File file = new File (parent , name );
571571 if (file .exists ()) {
572572 return file .getAbsolutePath ();
573573 }
574574 }
575575 try {
576- URI u = new URI (baseURI != null ? baseURI : documentParent ).resolve (systemId ).normalize ();
576+ URI u = new URI (baseURI != null ? baseURI : documentParent . get () ).resolve (systemId ).normalize ();
577577 File file = new File (u .toURL ().toString ());
578578 if (file .exists ()) {
579579 return file .getAbsolutePath ();
@@ -636,7 +636,7 @@ public String matchURI(String uri) {
636636 }
637637
638638 public void currentDocumentBase (String parentFile ) {
639- documentParent = parentFile ;
639+ documentParent . set ( parentFile ) ;
640640 }
641641
642642 public String getDTD (String name ) {
0 commit comments