@@ -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 )
@@ -442,7 +442,7 @@ public InputSource resolveEntity(String name, String publicId, String baseURI, S
442442 return new InputSource (uri .toURL ().openStream ());
443443 }
444444 return new InputSource (new FileInputStream (uri .toURL ().toString ()));
445- } catch (URISyntaxException | IllegalArgumentException | NullPointerException e ) {
445+ } catch (URISyntaxException | IllegalArgumentException | NullPointerException _ ) {
446446 // ignore
447447 }
448448 if (dtdPublicEntities != null && publicId != null && dtdPublicEntities .containsKey (publicId )) {
@@ -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,19 +566,19 @@ 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 ();
580580 }
581- } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e ) {
581+ } catch (MalformedURLException | URISyntaxException | IllegalArgumentException _ ) {
582582 // ignore
583583 }
584584 }
@@ -628,15 +628,15 @@ public String matchURI(String uri) {
628628 if (u .isAbsolute () && u .toURL ().getProtocol ().startsWith ("file" )) {
629629 return u .toString ();
630630 }
631- } catch (URISyntaxException | MalformedURLException | IllegalArgumentException e ) {
631+ } catch (URISyntaxException | MalformedURLException | IllegalArgumentException _ ) {
632632 // ignore
633633 }
634634 }
635635 return null ;
636636 }
637637
638638 public void currentDocumentBase (String parentFile ) {
639- documentParent = parentFile ;
639+ documentParent . set ( parentFile ) ;
640640 }
641641
642642 public String getDTD (String name ) {
@@ -681,7 +681,7 @@ public void parseDTD(String publicId) {
681681 EntityDecl entity = it .next ();
682682 addDtdSystemEntity (entity .getValue (), entity .getSystemId ());
683683 }
684- } catch (IOException | SAXException e ) {
684+ } catch (IOException | SAXException _ ) {
685685 // do nothing
686686 MessageFormat mf = new MessageFormat (Messages .getString ("Catalog.0" ));
687687 logger .log (Level .WARNING , mf .format (new String [] { publicId }));
0 commit comments