本文整理了Java中java.lang.OutOfMemoryError.<init>()
方法的一些代码示例,展示了OutOfMemoryError.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutOfMemoryError.<init>()
方法的具体详情如下:
包路径:java.lang.OutOfMemoryError
类名称:OutOfMemoryError
方法名:<init>
[英]Constructs a new OutOfMemoryError that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新OutOfMemoryError。
代码示例来源:origin: netty/netty
private void expandArray() {
// double capacity
int newCapacity = array.length << 1;
if (newCapacity < 0) {
throw new OutOfMemoryError();
}
Object[] newArray = new Object[newCapacity];
System.arraycopy(array, 0, newArray, 0, array.length);
array = newArray;
}
}
代码示例来源:origin: redisson/redisson
private void expandArray() {
// double capacity
int newCapacity = array.length << 1;
if (newCapacity < 0) {
throw new OutOfMemoryError();
}
Object[] newArray = new Object[newCapacity];
System.arraycopy(array, 0, newArray, 0, array.length);
array = newArray;
}
}
代码示例来源:origin: apache/flink
private void increaseCapacity(int requiredCapacity) {
int oldCapacity = buffer.length;
int newCapacity = oldCapacity << 1;
if (newCapacity - requiredCapacity < 0) {
newCapacity = requiredCapacity;
}
if (newCapacity < 0) {
if (requiredCapacity < 0) {
throw new OutOfMemoryError();
}
newCapacity = Integer.MAX_VALUE;
}
buffer = Arrays.copyOf(buffer, newCapacity);
}
代码示例来源:origin: apache/kafka
@Override
protected ByteBuffer allocateByteBuffer(int size) {
throw new OutOfMemoryError();
}
};
代码示例来源:origin: google/guava
checkArgument(expectedSize >= 0, "expectedSize (%s) must be non-negative", expectedSize);
if (expectedSize > MAX_ARRAY_LEN) {
throw new OutOfMemoryError(expectedSize + " bytes is too large to fit in a byte array");
代码示例来源:origin: gocd/gocd
public File zip(File source, File destFile, int level) {
throw new OutOfMemoryError("#2824");
}
}
代码示例来源:origin: apache/hbase
@Override
public Future submit(Runnable runnable) {
throw new OutOfMemoryError("OutOfMemory error thrown by means");
}
}
代码示例来源:origin: apache/ignite
@Override public Object process(MutableEntry<Integer, Integer> entry,
Object... arguments) throws EntryProcessorException {
throw new OutOfMemoryError();
}
});
代码示例来源:origin: prestodb/presto
/**
* Reads a file of the given expected size from the given input stream, if it will fit into a byte
* array. This method handles the case where the file size changes between when the size is read
* and when the contents are read from the stream.
*/
static byte[] readFile(InputStream in, long expectedSize) throws IOException {
if (expectedSize > Integer.MAX_VALUE) {
throw new OutOfMemoryError(
"file is too large to fit in a byte array: " + expectedSize + " bytes");
}
// some special files may return size 0 but have content, so read
// the file normally in that case guessing at the buffer size to use. Note, there is no point
// in calling the 'toByteArray' overload that doesn't take a size because that calls
// InputStream.available(), but our caller has already done that. So instead just guess that
// the file is 4K bytes long and rely on the fallback in toByteArray to expand the buffer if
// needed.
// This also works around an app-engine bug where FileInputStream.available() consistently
// throws an IOException for certain files, even though FileInputStream.getChannel().size() does
// not!
return ByteStreams.toByteArray(in, expectedSize == 0 ? 4096 : (int) expectedSize);
}
代码示例来源:origin: google/guava
throw new OutOfMemoryError("input is too large to fit in a byte array");
代码示例来源:origin: square/picasso
@Override public void load(@NonNull Picasso picasso, @NonNull Request request, @NonNull Callback callback) {
callback.onError(new OutOfMemoryError());
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldComposeFailureDescriptionForFailedCandidates()
{
// given
monitor.allocationSuccessful( 123, factory, asList(
new NumberArrayFactory.AllocationFailure( new OutOfMemoryError( "OOM1" ), HEAP ),
new NumberArrayFactory.AllocationFailure( new OutOfMemoryError( "OOM2" ), OFF_HEAP ) ) );
// when
String failure = monitor.pageCacheAllocationOrNull();
// then
assertThat( failure, containsString( "OOM1" ) );
assertThat( failure, containsString( "OOM2" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldClearFailureStateAfterAccessorCall()
{
// given
monitor.allocationSuccessful( 123, factory, asList(
new NumberArrayFactory.AllocationFailure( new OutOfMemoryError( "OOM1" ), HEAP ),
new NumberArrayFactory.AllocationFailure( new OutOfMemoryError( "OOM2" ), OFF_HEAP ) ) );
// when
String failure = monitor.pageCacheAllocationOrNull();
String secondCall = monitor.pageCacheAllocationOrNull();
// then
assertNotNull( failure );
assertNull( secondCall );
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void throwsSetErrorWrappedInExecutionExceptionFromCompletable() throws Exception {
Throwable exception = new OutOfMemoryError();
assertTrue(settableListenableFuture.setException(exception));
Future<String> completable = settableListenableFuture.completable();
try {
completable.get();
fail("Expected ExecutionException");
}
catch (ExecutionException ex) {
assertThat(ex.getCause(), equalTo(exception));
}
assertFalse(completable.isCancelled());
assertTrue(completable.isDone());
}
代码示例来源:origin: spring-projects/spring-framework
i % 2 == 0 ? new OutOfMemoryError() : new IllegalStateException());
threads[i].start();
代码示例来源:origin: spring-projects/spring-framework
@Test
public void throwsSetErrorWrappedInExecutionException() throws Exception {
Throwable exception = new OutOfMemoryError();
assertTrue(settableListenableFuture.setException(exception));
try {
settableListenableFuture.get();
fail("Expected ExecutionException");
}
catch (ExecutionException ex) {
assertThat(ex.getCause(), equalTo(exception));
}
assertFalse(settableListenableFuture.isCancelled());
assertTrue(settableListenableFuture.isDone());
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testWrapAndUnwrapError() {
try {
ExceptionUtils.wrapAndThrow(new OutOfMemoryError());
fail("Error not thrown");
} catch (final Throwable t) {
assertTrue(ExceptionUtils.hasCause(t, Error.class));
}
}
代码示例来源:origin: apache/kafka
@Test
public void outOfMemoryOnAllocation() {
BufferPool bufferPool = new BufferPool(1024, 1024, metrics, time, metricGroup) {
@Override
protected ByteBuffer allocateByteBuffer(int size) {
throw new OutOfMemoryError();
}
};
try {
bufferPool.allocateByteBuffer(1024);
// should not reach here
fail("Should have thrown OutOfMemoryError");
} catch (OutOfMemoryError ignored) {
}
assertEquals(bufferPool.availableMemory(), 1024);
}
代码示例来源:origin: neo4j/neo4j
@Test
public void databaseWithCriticalErrorsCanNotBeHealed()
{
AssertableLogProvider logProvider = new AssertableLogProvider();
DatabaseHealth databaseHealth = new DatabaseHealth( mock( DatabasePanicEventGenerator.class ),
logProvider.getLog( DatabaseHealth.class ) );
assertTrue( databaseHealth.isHealthy() );
IOException criticalException = new IOException( "Space exception.", new OutOfMemoryError( "Out of memory." ) );
databaseHealth.panic( criticalException );
assertFalse( databaseHealth.isHealthy() );
assertFalse( databaseHealth.healed() );
logProvider.assertNoMessagesContaining( "Database health set to OK" );
logProvider.assertContainsLogCallContaining(
"Database encountered a critical error and can't be healed. Restart required." );
}
}
代码示例来源:origin: apache/kafka
@Test
public void testCleanupMemoryAvailabilityOnMetricsException() throws Exception {
BufferPool bufferPool = spy(new BufferPool(2, 1, new Metrics(), time, metricGroup));
doThrow(new OutOfMemoryError()).when(bufferPool).recordWaitTime(anyLong());
bufferPool.allocate(1, 0);
try {
bufferPool.allocate(2, 1000);
fail("Expected oom.");
} catch (OutOfMemoryError expected) {
}
assertEquals(1, bufferPool.availableMemory());
assertEquals(0, bufferPool.queued());
assertEquals(1, bufferPool.unallocatedMemory());
//This shouldn't timeout
bufferPool.allocate(1, 0);
verify(bufferPool).recordWaitTime(anyLong());
}
内容来源于网络,如有侵权,请联系作者删除!