For small amount of data, everything is fine. For more than 8192 bytes it reads only first 8192 bytes. DSo 'BYTES READED' is never more than 8192. Desn't matter what is bufferSize value:
public String exec(String channelId, String requestJson) throws RpcException {
try {
Require.notNull(channelId, "channelId");
Require.notNull(requestJson, "requestJson");
String respStr = null;
UnixDomainSocketClient socket = channels.get(channelId);
if (socket == null) {
socket = new UnixDomainSocketClient(socketFilePath, JUDS.SOCK_STREAM);
channels.put(channelId, socket);
}
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();
try {
PrintWriter w = new PrintWriter(out);
w.print(requestJson);
w.flush();
} catch (Throwable ex) {
throw new Exception("Cannot send request \"" + requestJson + "\" to c-lightning RPC socket", ex);
}
try {
InputStreamReader r = new InputStreamReader(in);
CharBuffer respChBuf = CharBuffer.allocate(bufferSize);
StringBuilder resp = new StringBuilder();
int bytesRead;
do {
bytesRead = r.read(respChBuf);
LOGGER.debug("Readed bytes: " + bytesRead);
if(bytesRead > 0) {
respChBuf.flip();
resp.append(respChBuf.toString());
}
} while(bytesRead == bufferSize);
respStr = resp.toString();
LOGGER.info("BYTES READED: " + resp.length());
} catch (Throwable ex) {
throw new Exception("Cannot get response from c-lightning RPC socket", ex);
}
return Require.notNull(respStr, "respStr");
} catch (Throwable ex) {
throw new RpcException("Cannot execute request '" + requestJson + "'", ex);
}
}`
For small amount of data, everything is fine. For more than 8192 bytes it reads only first 8192 bytes. DSo 'BYTES READED' is never more than 8192. Desn't matter what is bufferSize value:
`