Skip to content

Commit

Permalink
去掉2.0的 throw
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuam committed Mar 11, 2016
1 parent c4a798d commit 0045359
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/io/mycat/buffer/BufferPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class BufferPool {
private final int chunkSize;
private final int conReadBuferChunk;
private final ConcurrentLinkedQueue<ByteBuffer> items = new ConcurrentLinkedQueue<ByteBuffer>();

/**
* 只用于Connection读取Socket事件,每个Connection一个ByteBuffer(Direct),
* 此ByteBufer通常应该能容纳2-N个 应用消息的报文长度,
Expand Down Expand Up @@ -130,9 +131,7 @@ private boolean checkValidBuffer(ByteBuffer buffer) {
} else if (buffer.capacity() != chunkSize) {
LOGGER.warn("cant' recycle a buffer not equals my pool chunksize "
+ chunkSize + " he is " + buffer.capacity());
throw new RuntimeException("bad size");

// return false;
return false;
}
buffer.clear();
return true;
Expand Down Expand Up @@ -178,7 +177,10 @@ public boolean testIfDuplicate(ByteBuffer buffer) {
}
}
return false;

}

private ByteBuffer createTempBuffer(int size) {
return ByteBuffer.allocate(size);
}

private ByteBuffer createDirectBuffer(int size) {
Expand All @@ -192,8 +194,7 @@ public ByteBuffer allocate(int size) {
} else {
LOGGER.warn("allocate buffer size large than default chunksize:"
+ this.chunkSize + " he want " + size);
throw new RuntimeException("execuddd");
// return createTempBuffer(size);
return createTempBuffer(size);
}
}

Expand Down

0 comments on commit 0045359

Please sign in to comment.