Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5377 custom exception for CharBuffer #5505

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create a custom exception to remove OutOfMemoryError in CharBuffer
Signed-off-by: aserkes <andrii.serkes@oracle.com>
  • Loading branch information
aserkes committed Nov 22, 2022
commit 372586e4df61a34499a99cc8cd036783026768ee
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void grow(int minCapacity) {

private static int hugeCapacity(int minCapacity) {
if (minCapacity < 0) {
throw new OutOfMemoryError("Capacity overflow. minCapacity=" + minCapacity);
throw new OutOfCapacityException("Capacity overflow. minCapacity=" + minCapacity);
}
return (minCapacity > MAX_ARRAY_SIZE)
? Integer.MAX_VALUE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.helidon.reactive.media.common;

/**
* Exception that is related to the capacity of an object.
*/
public class OutOfCapacityException extends RuntimeException {

/**
* New exception without a cause and message.
*/
public OutOfCapacityException() {
aserkes marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* New exception with a message and without a cause.
* @param message message to use
*/
public OutOfCapacityException(String message) {
super(message);
}

/**
* New exception with a cause and message.
*
* @param message message to use
* @param cause throwable that caused this exception
*/
public OutOfCapacityException(String message, Throwable cause) {
super(message, cause);
}

/**
* New exception with a cause and without a message.
*
* @param cause throwable that caused this exception
*/
public OutOfCapacityException(Throwable cause) {
super(cause);
}
}