Skip to content

Commit da9cc74

Browse files
committed
Closing client responss
HTTP test fixes
1 parent 0a7398f commit da9cc74

5 files changed

Lines changed: 44 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,26 @@ export PATH="$(find bin -type d -exec realpath {} \; | tr '\n' ':')$PATH"
112112
- XSLT stylesheets are processed during build to inline XML entities
113113
- Saxon-JS SEF files are generated during Maven package phase for client-side XSLT
114114
- WebID certificates are required for authenticated API access
115-
- The system expects Jena CLI tools to be available (`JENA_HOME` environment variable)
115+
- The system expects Jena CLI tools to be available (`JENA_HOME` environment variable)
116+
117+
## Debugging Test Failures
118+
119+
When HTTP tests fail:
120+
1. NEVER speculate about failures - always add debug output first
121+
2. Add echo statements showing:
122+
- The actual values being tested
123+
- The expected values
124+
- HTTP response codes and bodies where relevant
125+
3. Run the test to see actual output
126+
4. Only then diagnose and fix
127+
128+
Example debug pattern:
129+
```bash
130+
result=$(curl ...)
131+
expected="..."
132+
echo "DEBUG: Expected: $expected"
133+
echo "DEBUG: Got: $result"
134+
if [ "$result" != "$expected" ]; then
135+
echo "DEBUG: Mismatch!"
136+
exit 1
137+
fi

http-tests/admin/GET-agent-mbox-html.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ html=$(curl -k -f -s -N \
1414

1515
# check that the description does *not* include foaf:mbox property
1616

17-
echo "$html" | grep -v "http://xmlns.com/foaf/0.1/mbox" > /dev/null
17+
if echo "$html" | grep -q "http://xmlns.com/foaf/0.1/mbox"; then
18+
exit 1
19+
fi
1820

1921
# check that the description includes foaf:mbox_sha1sum property
2022

http-tests/document-hierarchy/PUT-twice.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ EOF
5252

5353
# check that the old document metadata is gone
5454

55-
curl -k -f -s -G \
55+
response=$(curl -k -f -s -G \
5656
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
5757
-H "Accept: application/n-triples" \
5858
"$END_USER_BASE_URL" \
59-
| tr -d '\n' \
60-
| grep -v '"old object"' > /dev/null
59+
| tr -d '\n')
60+
61+
if echo "$response" | grep -q '"old object"'; then
62+
exit 1
63+
fi

src/main/java/com/atomgraph/linkeddatahub/resource/Generate.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ public Response post(Model model, @QueryParam("default") @DefaultValue("false")
159159
}
160160

161161
// ban the parent container URI from proxy cache to make sure the next query using it will be fresh (e.g. SELECT that loads children)
162-
ban(getApplication().getService().getBackendProxy(), parent.getURI());
163-
162+
try (Response response = ban(getApplication().getService().getBackendProxy(), parent.getURI()))
163+
{
164+
// Response automatically closed by try-with-resources
165+
}
166+
164167
return Response.ok().build();
165168
}
166169
finally

src/main/java/com/atomgraph/linkeddatahub/resource/admin/SignUp.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,13 @@ public Response post(Model agentModel, @QueryParam("default") @DefaultValue("fal
288288
}
289289

290290
// purge agent lookup from proxy cache
291-
if (getAgentService().getBackendProxy() != null) ban(getAgentService().getBackendProxy(), mbox.getURI());
291+
if (getAgentService().getBackendProxy() != null)
292+
{
293+
try (Response response = ban(getAgentService().getBackendProxy(), mbox.getURI()))
294+
{
295+
// Response automatically closed by try-with-resources
296+
}
297+
}
292298

293299
// remove secretary WebID from cache
294300
getSystem().getEventBus().post(new com.atomgraph.linkeddatahub.server.event.SignUp(getSystem().getSecretaryWebIDURI()));

0 commit comments

Comments
 (0)