Add a double-wrap of tempContexts around the example call to MetaDataAction for the example, to avoid warning about creating a system-user session w/o an instance in context.

This commit is contained in:
2025-03-12 20:18:06 -05:00
parent 955cb67a2c
commit 8cf53e045e

View File

@ -242,23 +242,29 @@ public class MetaDataSpecV1 extends AbstractEndpointSpec<MetaDataInput, MetaData
.withChild(exampleTable);
exampleInstance.addApp(exampleApp);
QContext.withTemporaryContext(new CapturedContext(exampleInstance, new QSystemUserSession()), () ->
//////////////////////////////////////////////////////////////////////////////////////////////////////
// double-wrap the context here, so the instance will exist when the system-user-session is created //
// to avoid warnings out of system-user-session about there not being an instance in context. //
//////////////////////////////////////////////////////////////////////////////////////////////////////
QContext.withTemporaryContext(new CapturedContext(exampleInstance, null), () ->
{
try
QContext.withTemporaryContext(new CapturedContext(exampleInstance, new QSystemUserSession()), () ->
{
MetaDataAction metaDataAction = new MetaDataAction();
MetaDataOutput output = metaDataAction.execute(new com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataInput());
examples.put("Example", new Example()
.withValue(new MetaDataResponseV1()
.withMetaDataOutput(output)
)
);
}
catch(Exception e)
{
examples.put("Example", new Example().withValue("Error building example: " + e.getMessage())
);
}
try
{
MetaDataAction metaDataAction = new MetaDataAction();
MetaDataOutput output = metaDataAction.execute(new com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataInput());
examples.put("Example", new Example()
.withValue(new MetaDataResponseV1()
.withMetaDataOutput(output)
)
);
}
catch(Exception e)
{
examples.put("Example", new Example().withValue("Error building example: " + e.getMessage()));
}
});
});
return new BasicResponse("""