github-advanced-security[bot] commented on code in PR #22494:
URL: https://github.com/apache/pulsar/pull/22494#discussion_r1563884550
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java:
##########
@@ -220,10 +176,34 @@
//if exception happens, release buffer
if (exceptionHappens) {
buf.release();
+ } else {
+ // for the next time, the initial buffer size will be
suggested by the last buffer size
+ initialBufferSize = Math.max(DEFAULT_INITIAL_BUFFER_SIZE,
buf.readableBytes());
}
}
}
+ private ByteBuf allocateMultipartCompositeDirectBuffer() {
+ // use composite buffer with pre-allocated buffers to ensure that the
pooled allocator can be used
+ // for allocating the buffers
+ ByteBufAllocator byteBufAllocator = PulsarByteBufAllocator.DEFAULT;
+ long chunkSize;
+ if (byteBufAllocator instanceof PooledByteBufAllocator) {
+ PooledByteBufAllocator pooledByteBufAllocator =
(PooledByteBufAllocator) byteBufAllocator;
+ chunkSize = Math.max(pooledByteBufAllocator.metric().chunkSize(),
DEFAULT_INITIAL_BUFFER_SIZE);
+ } else {
+ chunkSize = DEFAULT_INITIAL_BUFFER_SIZE;
+ }
+ CompositeByteBuf buf = byteBufAllocator.compositeDirectBuffer(
+ Math.max(MINIMUM_FOR_MAX_COMPONENTS, (int) (initialBufferSize
/ chunkSize) + 1));
+ int totalLen = 0;
+ while (totalLen < initialBufferSize) {
+ totalLen += chunkSize;
Review Comment:
## Implicit narrowing conversion in compound assignment
Implicit cast of source type long to narrower destination type int.
[Show more
details](https://github.com/apache/pulsar/security/code-scanning/116)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]