Skip to content

Update ByteBuffAllocator.java#5360

Closed
moonlightingLL wants to merge 1 commit intoapache:masterfrom
moonlightingLL:#162-ByteBuffAllocator.java
Closed

Update ByteBuffAllocator.java#5360
moonlightingLL wants to merge 1 commit intoapache:masterfrom
moonlightingLL:#162-ByteBuffAllocator.java

Conversation

@moonlightingLL
Copy link
Copy Markdown

In ByteBuffAllocator.java, there is no value checking for poolBufSize and this variable is directly used to calculate the bufsForTwoMB. When poolBufSize is mistakenly set to 0, the code would cause division by 0 and throw ArithmeticException to crash the system.

public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnabled) {
    int poolBufSize = conf.getInt(BUFFER_SIZE_KEY, DEFAULT_BUFFER_SIZE);
    if (reservoirEnabled) {
    . . .
    int bufsForTwoMB = (2 * 1024 * 1024) / poolBufSize;
    . . .

I add a piece of code to check whether poolBufSize is equal to 0 during runtime, and if it's 0, it will raise an IllegalArgumentException exception with the given message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant