Я пытаюсь напечатать ответ API JSON, используя политику на этапе @OnResponseContent. Я реализовал приведенный ниже код, но получил буфер как null / empty
@OnResponseContent
public ReadWriteStream onResponseContent(Response response, ExecutionContext executionContext,
PolicyChain policyChain) {
System.out.println("I AM IN!!!");
return new BufferedReadWriteStream() {
private final Buffer buffer = Buffer.buffer();
@Override
public SimpleReadWriteStream<Buffer> write(Buffer content) {
buffer.appendBuffer(content);
System.out.println("I AM CONETENT"+content);
return this;
}
{
System.out.println("I am being called upper!====>>>>"+buffer);
}
@Override
public void end() {
// Do callout
// You have response from API within the `buffer
System.out.println("I AM IN END"+buffer);
// Then write back the response to consumer
end(buffer);
}
{
System.out.println("I am being called!====>>>>"+buffer);
}
};
}
Переопределенные методы не вызываются (я предполагаю, что они должны быть вызваны событием). Вызваны операторы println вне методов.