@@ -54,12 +54,43 @@ public class OntologyFilter implements ContainerRequestFilter
5454
5555 private static final Logger log = LoggerFactory .getLogger (OntologyFilter .class );
5656
57+ /**
58+ * Paths that should not trigger ontology loading to avoid circular dependencies.
59+ *
60+ * When an ontology contains owl:imports pointing to URIs within these paths,
61+ * loading the ontology would trigger HTTP requests to those URIs. If those requests
62+ * are intercepted by this filter, it creates a circular dependency:
63+ *
64+ * 1. Request arrives for /uploads/xyz
65+ * 2. OntologyFilter intercepts it and loads ontology
66+ * 3. Ontology has owl:imports for /uploads/xyz
67+ * 4. Jena FileManager makes HTTP request to /uploads/xyz
68+ * 5. OntologyFilter intercepts it again → infinite loop/deadlock
69+ *
70+ * Additionally, uploaded files are binary/RDF content that don't require
71+ * ontology context for their serving logic.
72+ */
73+ private static final java .util .Set <String > IGNORED_PATH_PREFIXES = java .util .Set .of (
74+ "uploads/"
75+ );
76+
5777 @ Inject com .atomgraph .linkeddatahub .Application system ;
5878
5979
6080 @ Override
6181 public void filter (ContainerRequestContext crc ) throws IOException
6282 {
83+ String path = crc .getUriInfo ().getPath ();
84+
85+ // Skip ontology loading for paths that may be referenced in owl:imports
86+ // to prevent circular dependency deadlocks during ontology resolution
87+ if (IGNORED_PATH_PREFIXES .stream ().anyMatch (path ::startsWith ))
88+ {
89+ if (log .isTraceEnabled ()) log .trace ("Skipping ontology loading for path: {}" , path );
90+ crc .setProperty (OWL .Ontology .getURI (), Optional .empty ());
91+ return ;
92+ }
93+
6394 crc .setProperty (OWL .Ontology .getURI (), getOntology (crc ));
6495 }
6596
0 commit comments