input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Deprecated
public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) {
return HotkeyManager.getInstance().addHotkey(key, modifiers, listener);
}
#location 3
#vulnerability type NULL... | #fixed code
@Deprecated
public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) {
return Key.addHotkey(key, modifiers, listener);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
System.out.println("********** Running Sikulix.main");
int dl = RunTime.checkArgs(args, RunTime.Type.API);
if (dl > -1) {
testNumber = dl;
Debug.on(3);
}
rt = RunTime.get();
testNumber = r... | #fixed code
public static void main(String[] args) {
System.out.println("********** Running Sikulix.main");
int dl = RunTime.checkArgs(args, RunTime.Type.API);
if (dl > -1) {
testNumber = dl;
Debug.on(3);
}
rt = RunTime.get();
testNumber = rt.getO... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean reparse() {
File temp = FileManager.createTempFile("py");
Element e = this.getDocument().getDefaultRootElement();
if (e.getEndOffset() - e.getStartOffset() == 1) {
return true;
}
try {
writeFile(temp.getAbsolutePath());
this.read(new Buffe... | #fixed code
public boolean reparse() {
File temp = null;
Element e = this.getDocument().getDefaultRootElement();
if (e.getEndOffset() - e.getStartOffset() == 1) {
return true;
}
if ((temp = reparseBefore()) != null) {
if (reparseAfter(temp)) {
updateDocumentListeners();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void clearCache(int maxSize) {
Image first;
while (images.size() > 0 && currentMemory > maxSize) {
first = images.remove(0);
first.bimg = null;
currentMemory -= first.bsize;
}
if (maxSize == 0) {
currentMemory = 0;
... | #fixed code
public static void clearCache(int maxSize) {
currentMemoryChange(0, maxSize);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void runscript(String[] args) {
if (isRunningScript) {
log(-1, "can run only one script at a time!");
return;
}
IScriptRunner currentRunner = null;
if (args != null && args.length > 1 && args[0].startsWith("-testSetup")) {
... | #fixed code
public static void runscript(String[] args) {
if (isRunningScript) {
log(-1, "can run only one script at a time!");
return;
}
IScriptRunner currentRunner = null;
if (args != null && args.length > 1 && args[0].startsWith("-testSetup")) {
curr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Stream<IdObject<U, List<I>>> get() {
BufferedReader candidatesReader;
try {
candidatesReader = new BufferedReader(new FileReader(candidatesPath));
} catch (FileNotFoundException ex) {
throw new Uncheck... | #fixed code
@Override
public Stream<IdObject<U, List<I>>> get() {
try (BufferedReader candidatesReader = new BufferedReader(new FileReader(candidatesPath))) {
return candidatesReader.lines().parallel().map(line -> {
CharSequence[] tokens = split(li... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> List<T> queryObjectListSQL(String poolName, String sql, Class<T> type, Object[] params) {
List<T> returnList = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
... | #fixed code
public static <T> List<T> queryObjectListSQL(String poolName, String sql, Class<T> type, Object[] params) {
List<T> returnList = null;
try {
BeanListHandler<T> resultSetHandler = new BeanListHandler<T>(type);
returnList = new QueryRunner(DB_CONNECTION_MA... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) {
List<Object[]> returnList = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
... | #fixed code
public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) {
List<Object[]> returnList = null;
try {
ArrayListHandler resultSetHandler = new ArrayListHandler();
// returnList = new QueryRunner().query(con, sq... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> T querySingleScalarSQL(String poolName, String sql, Class<T> type, Object[] params) {
T returnObject = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
throw ne... | #fixed code
public static <T> T querySingleScalarSQL(String poolName, String sql, Class<T> type, Object[] params) {
T returnObject = null;
try {
ScalarHandler<T> resultSetHandler = new ScalarHandler<T>();
returnObject = new QueryRunner(DB_CONNECTION_MANAGER.getDataS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> List<T> queryColumnListSQL(String poolName, String sql, String columnName, Class<T> type, Object[] params) {
List<T> returnList = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con ... | #fixed code
public static <T> List<T> queryColumnListSQL(String poolName, String sql, String columnName, Class<T> type, Object[] params) {
List<T> returnList = null;
try {
ColumnListHandler<T> resultSetHandler = new ColumnListHandler<T>(columnName);
returnList = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static int[] executeBatchSQL(String poolName, String sql, Object[][] params) {
int[] returnIntArray = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
throw new Connection... | #fixed code
public static int[] executeBatchSQL(String poolName, String sql, Object[][] params) {
int[] returnIntArray = null;
try {
returnIntArray = new QueryRunner(DB_CONNECTION_MANAGER.getDataSource(poolName)).batch(sql, params);
} catch (Exception e) {
logge... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> T querySingleObjectSQL(String poolName, String sql, Class<T> type, Object[] params) {
T returnObject = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
throw ne... | #fixed code
public static <T> T querySingleObjectSQL(String poolName, String sql, Class<T> type, Object[] params) {
T returnObject = null;
try {
BeanHandler<T> resultSetHandler = new BeanHandler<T>(type);
returnObject = new QueryRunner(DB_CONNECTION_MANAGER.getDataS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean connect(final Endpoint endpoint) {
if (this.rpcClient == null) {
throw new IllegalStateException("Client service is not inited.");
}
if (isConnected(endpoint)) {
return true;
}
... | #fixed code
@Override
public boolean connect(final Endpoint endpoint) {
final RpcClient rc = this.rpcClient;
if (rc == null) {
throw new IllegalStateException("Client service is uninitialized.");
}
if (isConnected(rc, endpoint)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void onRpcReturned(Status status, GetFileResponse response) {
lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous o... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void cancel() {
lock.lock();
try {
if (this.finished) {
return;
}
if (this.timer != null) {
this.timer.cancel(true);
}
if (this.rpcCall != nu... | #fixed code
@Override
public void cancel() {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (this.timer != null) {
this.timer.cancel(true);
}
if (this.rpcCall != nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testChangePeers() throws Exception {
final List<PeerId> newPeers = TestUtils.generatePeers(10);
newPeers.removeAll(conf.getPeerSet());
for (final PeerId peer : newPeers) {
assertTrue(cluster.start(peer.getEndpoin... | #fixed code
@Test
public void testChangePeers() throws Exception {
final List<PeerId> newPeers = TestUtils.generatePeers(10);
newPeers.removeAll(conf.getPeerSet());
for (final PeerId peer : newPeers) {
assertTrue(cluster.start(peer.getEndpoint()));... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void shutdown(final Closure done) {
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state.compareTo(State.STATE_SHUTTING) < 0)... | #fixed code
@Override
public void shutdown(final Closure done) {
List<RepeatedTimer> timers = null;
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean isConnected(final Endpoint endpoint) {
return this.rpcClient.checkConnection(endpoint.toString());
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean isConnected(final Endpoint endpoint) {
final RpcClient rc = this.rpcClient;
return rc != null && isConnected(rc, endpoint);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void onRpcReturned(Status status, GetFileResponse response) {
lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous o... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean disconnect(final Endpoint endpoint) {
LOG.info("Disconnect from {}", endpoint);
this.rpcClient.closeConnection(endpoint.toString());
return true;
}
#location 4
... | #fixed code
@Override
public boolean disconnect(final Endpoint endpoint) {
final RpcClient rc = this.rpcClient;
if (rc == null) {
return true;
}
LOG.info("Disconnect from {}.", endpoint);
rc.closeConnection(endpoint.toString());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void addLeaderStateListener(final long regionId, final LeaderStateListener listener) {
checkState();
if (this.storeEngine == null) {
throw new IllegalStateException("current node do not have store engine");
}
... | #fixed code
@Override
public void addLeaderStateListener(final long regionId, final LeaderStateListener listener) {
addStateListener(regionId, listener);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void addStateListener(final long regionId, final StateListener listener) {
checkState();
if (this.storeEngine == null) {
throw new IllegalStateException("current node do not have store engine");
}
final Re... | #fixed code
@Override
public void addStateListener(final long regionId, final StateListener listener) {
this.stateListenerContainer.addStateListener(regionId, listener);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void block(final long startTimeMs, @SuppressWarnings("unused") final int errorCode) {
// TODO: Currently we don't care about error_code which indicates why the
// very RPC fails. To make it better there should be different timeout for
// each ind... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request,
final AppendEntriesResponse response, final long rpcSendTime) {
if (id == null) {
// replicator already wa... | #fixed code
static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request,
final AppendEntriesResponse response, final long rpcSendTime) {
if (id == null) {
// replicator already was dest... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raftOptions) {
if (opts.getLogManager() == null || opts.getBallotBox() == null || opts.getNode() == null) {
throw new IllegalArgumentException("Invalid ReplicatorOptions.");... | #fixed code
public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raftOptions) {
if (opts.getLogManager() == null || opts.getBallotBox() == null || opts.getNode() == null) {
throw new IllegalArgumentException("Invalid ReplicatorOptions.");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public <T extends Message> Future<Message> invokeWithDone(final Endpoint endpoint, final Message request,
final InvokeContext ctx,
final RpcRespon... | #fixed code
public <T extends Message> Future<Message> invokeWithDone(final Endpoint endpoint, final Message request,
final InvokeContext ctx,
final RpcResponseClos... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void shutdown(final Closure done) {
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state.compareTo(State.STATE_SHUTTING) < 0)... | #fixed code
@Override
public void shutdown(final Closure done) {
List<RepeatedTimer> timers = null;
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
releaseReader();
// Unregister replicator metric set
if (this.options.getNode().getNodeMetrics().isEna... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void shutdown(final Closure done) {
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state.compareTo(State.STATE_SHUTTING) < 0)... | #fixed code
@Override
public void shutdown(final Closure done) {
List<RepeatedTimer> timers = null;
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
releaseReader();
// Unregister replicator metric set
if (this.options.getNode().getNodeMetrics().isEna... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
if (this.reader != null) {
Utils.closeQuietly(this.reader);
this.reader = null;
}
... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void shutdown(final Closure done) {
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state.compareTo(State.STATE_SHUTTING) < 0)... | #fixed code
@Override
public void shutdown(final Closure done) {
List<RepeatedTimer> timers = null;
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testOnRpcReturnedRpcError() {
final Replicator r = getReplicator();
assertNull(r.getBlockTimer());
final RpcRequests.AppendEntriesRequest request = createEmptyEntriesRequest();
final RpcRequests.AppendEntriesResponse... | #fixed code
@Test
public void testOnRpcReturnedRpcError() {
testRpcReturnedError();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unused")
static void onTimeoutNowReturned(final ThreadId id, final Status status, final TimeoutNowRequest request,
final TimeoutNowResponse response, final boolean stopAfterFinish) {
final Replicator r ... | #fixed code
@SuppressWarnings("unused")
static void onTimeoutNowReturned(final ThreadId id, final Status status, final TimeoutNowRequest request,
final TimeoutNowResponse response, final boolean stopAfterFinish) {
final Replicator r = (Rep... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean commitAt(long firstLogIndex, long lastLogIndex, PeerId peer) {
//TODO use lock-free algorithm here?
final long stamp = stampedLock.writeLock();
long lastCommittedIndex = 0;
try {
if (pendingIndex == 0) {
... | #fixed code
public boolean commitAt(long firstLogIndex, long lastLogIndex, PeerId peer) {
//TODO use lock-free algorithm here?
final long stamp = stampedLock.writeLock();
long lastCommittedIndex = 0;
try {
if (pendingIndex == 0) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
releaseReader();
// Unregister replicator metric set
if (this.options.getNode().getNodeMetrics().isEna... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
releaseReader();
// Unregister replicator metric set
if (this.options.getNode().getNodeMetrics().isEna... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void sendEntries() {
boolean doUnlock = true;
try {
long prevSendIndex = -1;
while (true) {
final long nextSendingIndex = getNextSendIndex();
if (nextSendingIndex > prevSendIndex) {
... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void destroy() {
final ThreadId savedId = this.id;
LOG.info("Replicator {} is going to quit", savedId);
this.id = null;
releaseReader();
// Unregister replicator metric set
if (this.options.getNode().getNodeMetrics().isEna... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Session startCopyToFile(String source, String destPath, CopyOptions opts) throws IOException {
final File file = new File(destPath);
// delete exists file.
if (file.exists()) {
if (!file.delete()) {
LOG.error("... | #fixed code
public Session startCopyToFile(String source, String destPath, CopyOptions opts) throws IOException {
final File file = new File(destPath);
// delete exists file.
if (file.exists()) {
if (!file.delete()) {
LOG.error("Fail t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request,
final AppendEntriesResponse response, final long rpcSendTime) {
if (id == null) {
// replicator already wa... | #fixed code
static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request,
final AppendEntriesResponse response, final long rpcSendTime) {
if (id == null) {
// replicator already was dest... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void onRpcReturned(Status status, GetFileResponse response) {
lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous o... | #fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void shutdown(final Closure done) {
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state.compareTo(State.STATE_SHUTTING) < 0)... | #fixed code
@Override
public void shutdown(final Closure done) {
List<RepeatedTimer> timers = null;
this.writeLock.lock();
try {
LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state);
if (this.state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void installSnapshot() {
if (this.state == State.Snapshot) {
LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId());
this.id.unlock();
return;
}
boolean doUnlock = t... | #fixed code
long getNextSendIndex() {
// Fast path
if (this.inflights.isEmpty()) {
return this.nextIndex;
}
// Too many in-flight requests.
if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) {
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRead() throws IOException, ParseException, Event.EventFormatException {
BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8));
Event ev = Event.read(in);
... | #fixed code
@Test
public void testRead() throws IOException {
//noinspection UnstableApiUsage
BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8));
Event ev = Event.read(in);
ass... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRead() throws IOException, ParseException, Event.EventFormatException {
BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8));
Event ev = Event.read(in);
... | #fixed code
@Test
public void testRead() throws IOException {
//noinspection UnstableApiUsage
BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8));
Event ev = Event.read(in);
ass... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception {
OutputStream outputStream = new DeflaterOutputStream(new FileOutputStream(fileName, true));
com.esotericsoftware... | #fixed code
private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception {
OutputStream outputStream = new BufferedOutputStream(new DeflaterOutputStream(new FileOutputStream(fileName, true), false), Fi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getIpAddress() {
HttpServletRequest request = getRequest();
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-I... | #fixed code
public String getIpAddress() {
HttpServletRequest request = getRequest();
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) {
if (option == null) {
option = new DatabaseOpe... | #fixed code
public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) {
if (option == null) {
option = new DatabaseOperation... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private ClassLoader getDriverClassLoader() {
File localDriverPath = getCustomDriverPath();
if (driverClassLoader != null) {
return driverClassLoader;
} else if (localDriverPath.exists()) {
try {
List<URL> urlList = new ArrayList<URL>();
... | #fixed code
private ClassLoader getDriverClassLoader() {
File localDriverPath = getCustomDriverPath();
if (driverClassLoader != null) {
return driverClassLoader;
} else if (localDriverPath.exists()) {
try {
List<URL> urlList = new ArrayList<>();
File... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetConfiguredTemplate() {
String templateName = "";
try {
FileWriter fileWriter = new FileWriter(tempFile);
fileWriter.append("new_command.template=templates/col_new_template_migration.sql");
fileWriter.flush();
tem... | #fixed code
@Test
public void testGetConfiguredTemplate() {
String templateName = "";
try {
FileWriter fileWriter = new FileWriter(tempFile);
try {
fileWriter.append("new_command.template=templates/col_new_template_migration.sql");
fileWriter.flush();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) {
if (option == null) {
option = new DatabaseOpe... | #fixed code
public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) {
if (option == null) {
option = new DatabaseOperation... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetConfiguredTemplate() {
String templateName = "";
try {
FileWriter fileWriter = new FileWriter(tempFile);
fileWriter.append("new_command.template=templates/col_new_template_migration.sql");
fileWriter.flush();
tem... | #fixed code
@Test
public void testGetConfiguredTemplate() {
String templateName = "";
try {
FileWriter fileWriter = new FileWriter(tempFile);
try {
fileWriter.append("new_command.template=templates/col_new_template_migration.sql");
fileWriter.flush();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static void save(MethodNode methodNode) {
try {
MethodNodeService methodNodeService = ApplicationContextHelper.popBean(MethodNodeService.class);
methodNodeService.saveNotRedo(methodNode);
} catch (Exception e) {
... | #fixed code
private static void save(MethodNode methodNode) {
try {
MethodNodeService methodNodeService = ApplicationContextHelper.popBean(MethodNodeService.class);
assert methodNodeService != null;
methodNodeService.saveNotRedo(methodNode);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
byte[] readFile(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int n = 0;
byte[] buffer = new byte[BUFFER_LEN];
while ((n = fis.read(buffer)) != -1) {
// ... | #fixed code
InplaceFileConverter(RuleSet ruleSet) {
this.lineConverter = new LineConverter(ruleSet);
lineTerminator = System.getProperty("line.separator");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void convert(File file, byte[] input) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(input);
Reader reader = new InputStreamReader(bais);
BufferedReader breader = new BufferedReader(reader);
FileWriter fileWriter = new FileWriter... | #fixed code
InplaceFileConverter(RuleSet ruleSet) {
this.lineConverter = new LineConverter(ruleSet);
lineTerminator = System.getProperty("line.separator");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(String name) {
if(name == null) {
return false;
}
if(factory.exists(name)) {
Marker other = factory.getMarker(name);
return contains(other);
} else {
return false;
}
}
... | #fixed code
public boolean contains(String name) {
throw new UnsupportedOperationException("This method has been deprecated.");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Iterator<Marker> iterator() {
if (referenceList != null) {
return referenceList.iterator();
} else {
List<Marker> emptyList = Collections.emptyList();
return emptyList.iterator();
}
}
... | #fixed code
public Iterator<Marker> iterator() {
return referenceList.iterator();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void convert(File file, byte[] input) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(input);
Reader reader = new InputStreamReader(bais);
BufferedReader breader = new BufferedReader(reader);
FileWriter fileWriter = new FileWriter... | #fixed code
InplaceFileConverter(RuleSet ruleSet) {
this.lineConverter = new LineConverter(ruleSet);
lineTerminator = System.getProperty("line.separator");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static ILoggerFactory getILoggerFactory() {
if (INITIALIZATION_STATE == UNINITIALIZED) {
synchronized (LoggerFactory.class) {
if (INITIALIZATION_STATE == UNINITIALIZED) {
INITIALIZATION_STATE = ONGOING_INITI... | #fixed code
public static ILoggerFactory getILoggerFactory() {
if (INITIALIZATION_STATE == UNINITIALIZED) {
synchronized (LoggerFactory.class) {
if (INITIALIZATION_STATE == UNINITIALIZED) {
INITIALIZATION_STATE = ONGOING_INITIALIZAT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(String name) {
if (name == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.name.equals(name)) {
return true;
}
if (hasChildren()) {
for (int i = 0; i < children.size(); i++) {
... | #fixed code
public boolean contains(String name) {
if (name == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.name.equals(name)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < refereceList.size(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(String name) {
if (name == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.name.equals(name)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < refereceList.size(); i+... | #fixed code
public boolean contains(String name) {
if (name == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.name.equals(name)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < referenceList.size(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(Marker other) {
if (other == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.equals(other)) {
return true;
}
if (hasChildren()) {
for (int i = 0; i < children.size(); i++) {
... | #fixed code
public boolean contains(Marker other) {
if (other == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.equals(other)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < refereceList.size(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(Marker other) {
if (other == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.equals(other)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < refereceList.size(); i++)... | #fixed code
public boolean contains(Marker other) {
if (other == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.equals(other)) {
return true;
}
if (hasReferences()) {
for (int i = 0; i < referenceList.size(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean contains(String name) {
if(name == null) {
return false;
}
if(factory.exists(name)) {
Marker other = factory.getMarker(name);
return contains(other);
} else {
return false;
}
}
... | #fixed code
public boolean contains(String name) {
if(name == null) {
throw new IllegalArgumentException("Other cannot be null");
}
if (this.name.equals(name)) {
return true;
}
if (hasChildren()) {
for(int i = 0; i < children.size(); i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static boolean deleteFileOrDirectory(File path) throws MojoFailureException {
if (path.isDirectory()) {
File[] files = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
... | #fixed code
private static boolean deleteFileOrDirectory(File path) throws MojoFailureException {
if (path.isDirectory()) {
File[] files = path.listFiles();
if (null != files) {
for (File file : files) {
if (file.isDirectory()) {
if (!deleteFileOrDirectory(file)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void verifyNode(Node node) {
if (node == null)
return;
// Pre-order traversal.
verifyNodes(node.children());
if (node instanceof Call) {
Call call = (Call) node;
// Skip resolving property derefs.
if (call.isJavaStatic() ... | #fixed code
private void verifyNode(Node node) {
if (node == null)
return;
// Pre-order traversal.
verifyNodes(node.children());
if (node instanceof Call) {
Call call = (Call) node;
// Skip resolving property derefs.
if (call.isJavaStatic() || cal... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public final void evalLispFile() {
Loop.evalLisp("default", new InputStreamReader(LispEvaluatorTest.class.getResourceAsStream("funcs.lisp")));
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
@Test
public final void evalLispFile() {
// Loop.evalLisp("default", new InputStreamReader(LispEvaluatorTest.class.getResourceAsStream("funcs.lisp")));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String processVForValue(String vForValue)
{
VForDefinition vForDef = new VForDefinition(vForValue, context);
// Set return of the "in" expression
currentExpressionReturnType = vForDef.getInExpressionType();
String inExpressi... | #fixed code
private String processVForValue(String vForValue)
{
VForDefinition vForDef = new VForDefinition(vForValue, context);
// Set return of the "in" expression
currentExpressionReturnType = vForDef.getInExpressionType();
String inExpression = t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = 10)
public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long ex... | #fixed code
@Property(trials = 10)
public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long expected... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = TRIALS)
public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
lo... | #fixed code
@Property(trials = TRIALS)
public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long exp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = 10)
public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
... | #fixed code
@Property(trials = 10)
public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long e... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = TRIALS)
public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
... | #fixed code
@Property(trials = TRIALS)
public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = TRIALS)
public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
lon... | #fixed code
@Property(trials = TRIALS)
public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long expe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Property(trials = 10)
public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long e... | #fixed code
@Property(trials = 10)
public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) {
// given
executor = threadPoolExecutor(unitsOfWork);
long expecte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testToMap() throws SQLException {
int rowCount = 0;
Map m = null;
while (this.rs.next()) {
m = processor.toMap(this.rs);
assertNotNull(m);
assertEquals(COLS, m.keySet().size());
rowCoun... | #fixed code
public void testToMap() throws SQLException {
assertTrue(this.rs.next());
Map m = processor.toMap(this.rs);
assertEquals(COLS, m.keySet().size());
assertEquals("1", m.get("one"));
assertEquals("2", m.get("TWO"));
assertEquals("... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testNext() {
Iterator iter = new ResultSetIterator(this.rs);
int rowCount = 0;
Object[] row = null;
while (iter.hasNext()) {
rowCount++;
row = (Object[]) iter.next();
assertNotNull(row);
assertEquals(COLS, row.length);
}
assertEqua... | #fixed code
public void testNext() {
Iterator iter = new ResultSetIterator(this.rs);
Object[] row = null;
assertTrue(iter.hasNext());
row = (Object[]) iter.next();
assertEquals(COLS, row.length);
assertEquals("1", row[0]);
assertEquals("2", row[1]);
assertEquals("3", row... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testToArray() throws SQLException {
int rowCount = 0;
Object[] a = null;
while (this.rs.next()) {
a = processor.toArray(this.rs);
assertEquals(COLS, a.length);
rowCount++;
}
assert... | #fixed code
public void testToArray() throws SQLException {
Object[] a = null;
assertTrue(this.rs.next());
a = processor.toArray(this.rs);
assertEquals(COLS, a.length);
assertEquals("1", a[0]);
assertEquals("2", a[1]);
assertEquals... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testProcess() throws SQLException {
int rowCount = 0;
TestBean b = null;
while (this.rs.next()) {
b = (TestBean) beanProc.toBean(this.rs, TestBean.class);
assertNotNull(b);
rowCount++;
}
... | #fixed code
public void testProcess() throws SQLException {
TestBean b = null;
assertTrue(this.rs.next());
b = (TestBean) beanProc.toBean(this.rs, TestBean.class);
assertEquals(13.0, b.getColumnProcessorDoubleTest(), 0);
assertTrue(this.rs... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testHandle() throws SQLException {
ResultSetHandler h = new BeanListHandler(TestBean.class);
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
TestBean row = nu... | #fixed code
public void testHandle() throws SQLException {
ResultSetHandler h = new BeanListHandler(TestBean.class);
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
TestBean row = null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testColumnNameHandle() throws SQLException {
ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler("three");
Map<Object,Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEquals(ROW... | #fixed code
public void testColumnNameHandle() throws SQLException {
ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<Integer>("intTest");
Map<Integer,Map<String,Object>> results = h.handle(this.rs);
assertNotNull(results);
assertEqu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testHandle() throws SQLException {
ResultSetHandler h = new ArrayListHandler();
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
Object[] row = null;
while (... | #fixed code
public void testHandle() throws SQLException {
ResultSetHandler h = new ArrayListHandler();
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
Object[] row = null;
assertT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testHandle() throws SQLException {
ResultSetHandler h = new MapListHandler();
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
Map row = null;
while (i... | #fixed code
public void testHandle() throws SQLException {
ResultSetHandler h = new MapListHandler();
List results = (List) h.handle(this.rs);
assertNotNull(results);
assertEquals(ROWS, results.size());
Iterator iter = results.iterator();
Map row = null;
assertTr... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.