input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public void leaveRtpSession() {
if (this.joined.get()) {
this.joined.set(false);
/*
* When the participant decides to leave the system, tp is reset to tc, the current time, members and pmembers are
* initialized... | #fixed code
public void leaveRtpSession() {
if (this.joined.get()) {
this.joined.set(false);
/*
* When the participant decides to leave the system, tp is reset to tc, the current time, members and pmembers are
* initialized to 1,... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void startMixer() {
if (!started) {
started = true;
output.buffer.clear();
scheduler.submit(mixer,scheduler.MIXER_MIX_QUEUE);
mixCount = 0;
Iterator<Input> activeInputs=inputs.iterator();
... | #fixed code
public void startMixer() {
if (!started) {
started = true;
output.resetBuffer();
mixCount = 0;
Iterator<Input> activeInputs=inputs.iterator();
Input currInput;
while(activeInputs.hasNe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCodec() throws Exception {
boolean testPassed = false;
try {
final int packetSize = 480;
File outputFile = File.createTempFile("opustest", ".tmp");
FileInputStream inputStream = new FileInputStream("sr... | #fixed code
@Test
public void testCodec() throws Exception {
boolean testPassed = false;
try {
OpusJni opus = new OpusJni();
opus.initNative();
final int packetSize = 480;
File outputFile = File.createTempFile("opustest", ".tmp");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void harvest(IceMediaStream mediaStream, PortManager portManager, Selector selector) throws HarvestException, NoCandidatesGatheredException {
// Safe copy of currently registered harvesters
Map<CandidateType, CandidateHarvester> copy;
synchronized (this.harves... | #fixed code
public void harvest(IceMediaStream mediaStream, PortManager portManager, Selector selector) throws HarvestException, NoCandidatesGatheredException {
// Ask each harvester to gather candidates for the media stream
// HOST candidates take precedence and are mandatory
Candida... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Frame read(long timestamp) {
try {
if (queue.size() == 0) {
this.ready = false;
return null;
}
//extract packet
Frame frame = queue.remove(0);
//buffer empty now? - change ready flag.
if (queue.size() == 0) {
this.ready = false;... | #fixed code
public Frame read(long timestamp) {
try {
LOCK.lock();
if (queue.size() == 0) {
this.ready = false;
return null;
}
//extract packet
Frame frame = queue.remove(0);
//buffer empty now? - change ready flag.
if (queue.size() == 0) {
this.read... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private byte[] processRequest(StunRequest request, InetSocketAddress localPeer, InetSocketAddress remotePeer)
throws IOException {
// Produce Binding Response
TransportAddress transportAddress = new TransportAddress(remotePeer.getAddress(), ... | #fixed code
private byte[] processRequest(StunRequest request, InetSocketAddress localPeer, InetSocketAddress remotePeer)
throws IOException {
// Produce Binding Response
TransportAddress transportAddress = new TransportAddress(remotePeer.getAddress(), remote... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String open(String sdp) throws MgcpConnectionException {
synchronized (this.stateLock) {
switch (this.state) {
case CLOSED:
case HALF_OPEN:
// Update state
t... | #fixed code
@Override
public String open(String sdp) throws MgcpConnectionException {
synchronized (this.stateLock) {
switch (this.state) {
case CLOSED:
case HALF_OPEN:
// Update state
this.st... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCodec() throws Exception {
boolean testPassed = false;
try {
final int packetSize = 480;
File outputFile = File.createTempFile("opustest", ".tmp");
FileInputStream inputStream = new FileInputStream("sr... | #fixed code
@Test
public void testCodec() throws Exception {
boolean testPassed = false;
try {
OpusJni opus = new OpusJni();
opus.initNative();
final int packetSize = 480;
File outputFile = File.createTempFile("opustest", ".tmp");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Frame read(long timestamp) {
try {
if (queue.size() == 0) {
this.ready = false;
return null;
}
//extract packet
Frame frame = queue.remove(0);
//buffer empty now? - change ready flag.
if (queue.size() == 0) {
this.ready = false;... | #fixed code
public Frame read(long timestamp) {
try {
LOCK.lock();
if (queue.size() == 0) {
this.ready = false;
return null;
}
//extract packet
Frame frame = queue.remove(0);
//buffer empty now? - change ready flag.
if (queue.size() == 0) {
this.read... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
while (buffer.size() > 0) {
buffer.poll().recycle();
}
super.stop();
}
#location 4
#vulnerability type NULL_DEREFERENCE | #fixed code
@Override
public void stop() {
while (buffer.size() > 0) {
Frame frame = buffer.poll();
if(frame != null) {
frame.recycle();
}
}
super.stop();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(RtpPacket packet, RTPFormat format) {
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
this.format = format;
lo... | #fixed code
public void write(RtpPacket packet, RTPFormat format) {
try {
LOCK.lock();
// checking format
if (format == null) {
logger.warn("No format specified. Packet dropped!");
return;
}
if (this.format == null || this.format.getID() != format.getID()) {
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public int count() {
return this.count;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public int count() {
return this.count;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private byte[] processRequest(StunRequest request, InetSocketAddress localPeer, InetSocketAddress remotePeer) throws IOException {
/*
* The agent MUST use a short-term credential to authenticate the
* request and perform a message integrity check.
*/
// Produ... | #fixed code
private byte[] processRequest(StunRequest request, InetSocketAddress localPeer, InetSocketAddress remotePeer) throws IOException {
/*
* The agent MUST use a short-term credential to authenticate the
* request and perform a message integrity check.
*/
// Produce Bin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void train(String dataFile, int maxite, float c) throws IOException {
fp = File.createTempFile("train-features", null, new File("./tmp/"));
buildInstanceList(dataFile);
LabelAlphabet postagAlphabet = factory.buildLabelAlphabet("postag");
IFeatureAlphabet... | #fixed code
public void train(String dataFile, int maxite, float c) throws IOException {
fp = File.createTempFile("train-features", null, new File("./tmp/"));
buildInstanceList(dataFile);
LabelAlphabet postagAlphabet = factory.buildLabelAlphabet("postag");
SFGenerator generator... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args)
{
try
{
String ls_1;
Process process =null;
File handle = new File("./tmpdata/ctb/data3");
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("./tmpdata/malt.train"), "UTF-8"));... | #fixed code
public static void main(String[] args)
{
try
{
String ls_1;
Process process =null;
// File handle = new File("../tmp/ctb_v1/data");
File handle = new File("../tmp/ctb_v6/data/bracketed");
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private InstanceSet buildInstanceList(String file) throws IOException {
System.out.print("生成训练数据 ...");
FNLPReader reader = new FNLPReader(file);
InstanceSet instset = new InstanceSet();
LabelAlphabet la = factory.DefaultLabelAlphabet();
int count = 0;
whi... | #fixed code
private InstanceSet buildInstanceList(String file) throws IOException {
System.out.print("生成训练数据 ...");
FNLPReader reader = new FNLPReader(file);
FNLPReader preReader = new FNLPReader(file);
InstanceSet instset = new InstanceSet();
LabelAlphabet la = factory.Defau... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args)
{
try
{
String ls_1;
Process process =null;
File handle = new File("./tmpdata/ctb/data3");
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("./tmpdata/malt.train"), "UTF-8"));... | #fixed code
public static void main(String[] args)
{
try
{
String ls_1;
Process process =null;
// File handle = new File("../tmp/ctb_v1/data");
File handle = new File("../tmp/ctb_v6/data/bracketed");
BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void train(String dataFile, int maxite, float c) throws IOException {
InstanceSet instset = buildInstanceList(dataFile);
IFeatureAlphabet features = factory.DefaultFeatureAlphabet();
SFGenerator generator = new SFGenerator();
int fsize = features.size()... | #fixed code
public void train(String dataFile, int maxite, float c) throws IOException {
InstanceSet instset = buildInstanceList(dataFile);
SFGenerator generator = new SFGenerator();
LabelAlphabet la = factory.DefaultLabelAlphabet();
int ysize = la.size();
System.out.print... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStartNewSpanSampleNullNotPartOfExistingSpan() {
final ServerSpan mockServerSpan = mock(ServerSpan.class);
when(mockServerSpan.getSpan()).thenReturn(null);
when(mockState.sample()).thenReturn(null);
when(mockStat... | #fixed code
@Test
public void testStartNewSpanSampleNullNotPartOfExistingSpan() {
final ServerSpan mockServerSpan = mock(ServerSpan.class);
when(mockServerSpan.getSpan()).thenReturn(null);
when(mockState.sample()).thenReturn(null);
when(mockState.getC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void finishSpan() {
Span finished = new Span().setTimestamp(1000L); // set in start span
finished.startTick = 500000L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.nanoTime()).thenRe... | #fixed code
@Test
public void finishSpan() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // set in start span
finished.startTick = 500000L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.nanoTime(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public T call() throws Exception {
serverSpanThreadBinder().setCurrentSpan(currentServerSpan());
final long start = System.currentTimeMillis();
try {
return wrappedCallable().call();
} finally {
final... | #fixed code
@Override
public T call() throws Exception {
serverSpanThreadBinder().setCurrentSpan(currentServerSpan());
return wrappedCallable().call();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void recordClientSentAnnotations(Endpoint serverAddress) {
if (serverAddress == null) {
clientTracer.setClientSent();
} else {
clientTracer.setClientSent(serverAddress.ipv4, serverAddress.port, serverAddress.service_name);... | #fixed code
private void recordClientSentAnnotations(Endpoint serverAddress) {
if (serverAddress == null) {
clientTracer.setClientSent();
} else {
clientTracer.setClientSent(serverAddress);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void finishSpan_userSuppliedTimestamp() {
Span finished = new Span().setTimestamp(1000L); // Set by user
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.currentTimeMillis()).thenReturn(2L);
localTracer.fin... | #fixed code
@Test
public void finishSpan_userSuppliedTimestamp() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // Set by user
state.setCurrentLocalSpan(finished);
PowerMockito.when(System.currentTimeMillis()).thenReturn(2L);
localT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void finishSpan_userSuppliedTimestampAndDuration() {
Span finished = new Span().setTimestamp(1000L); // Set by user
state.setCurrentLocalSpan(finished);
localTracer.finishSpan(500L);
verify(mockCollector).collect(finish... | #fixed code
@Test
public void finishSpan_userSuppliedTimestampAndDuration() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // Set by user
state.setCurrentLocalSpan(finished);
localTracer.finishSpan(500L);
verify(mockReporter).report... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void finishSpan_lessThanMicrosRoundUp() {
Span finished = new Span().setTimestamp(1000L); // set in start span
finished.startTick = 500L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.when(System... | #fixed code
@Test
public void finishSpan_lessThanMicrosRoundUp() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // set in start span
finished.startTick = 500L; // set in start span
state.setCurrentLocalSpan(finished);
PowerMockito.wh... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void finishSpan_userSuppliedDuration() {
Span finished = new Span().setTimestamp(1000L); // set in start span
finished.startTick = 500L; // set in start span
state.setCurrentLocalSpan(finished);
localTracer.finishSpan(50... | #fixed code
@Test
public void finishSpan_userSuppliedDuration() {
Span finished = new Span().setName("foo").setTimestamp(1000L); // set in start span
finished.startTick = 500L; // set in start span
state.setCurrentLocalSpan(finished);
localTracer.fini... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void run() {
serverSpanThreadBinder().setCurrentSpan(currentServerSpan());
final long start = System.currentTimeMillis();
try {
wrappedRunnable().run();
} finally {
final long duration = System... | #fixed code
@Override
public void run() {
serverSpanThreadBinder().setCurrentSpan(currentServerSpan());
wrappedRunnable().run();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected boolean checkQuiesceLock() {
final String methodName = "checkQuiesceLock";
// if (quiescing && actualInFlight == 0 && pendingFlows.size() == 0 &&
// inFlightPubRels == 0 && callback.isQuiesced()) {
int tokC = tokenStore.count();
if (quiescing && tokC ==... | #fixed code
protected boolean checkQuiesceLock() {
final String methodName = "checkQuiesceLock";
// if (quiescing && actualInFlight == 0 && pendingFlows.size() == 0 &&
// inFlightPubRels == 0 && callback.isQuiesced()) {
int tokC = tokenStore.count();
if (quiescing && tokC == 0 && ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetStructure() {
try {
SimpleFormatter sf = new SimpleFormatter();
String delimiter = "/";
String bucket = "maven.kuali.org";
AmazonS3Client client = getClient();
KualiMavenBucketBaseCase baseCase1 = new KualiMavenBucketBaseCase();
... | #fixed code
@Test
public void testGetStructure() {
try {
long now = System.currentTimeMillis();
long bytes = Long.MAX_VALUE;
SimpleFormatter sf = new SimpleFormatter();
log.info(sf.getSize(bytes));
log.info(sf.getRate(now, bytes));
log.info(sf.getTime(now));
String d... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void transitionInto(RunState state) {
switch (state.state()) {
case SUBMITTING:
try {
final String executionId = dockerRunnerStart(state);
// this is racy
final Event submitted = Event.submitted(state.work... | #fixed code
@Override
public void transitionInto(RunState state) {
switch (state.state()) {
case SUBMITTING:
try {
final String executionId = dockerRunnerStart(state);
// this is racy
final Event submitted = Event.submitted(state.workflowIn... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Map<WorkflowInstance, RunState> activeStates() {
final ImmutableMap.Builder<WorkflowInstance, RunState> builder = ImmutableMap.builder();
states.entrySet().forEach(entry -> builder.put(entry.getKey(), entry.getValue().runState));
return buil... | #fixed code
@Override
public Map<WorkflowInstance, RunState> activeStates() {
return states.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, (entry) -> entry.getValue().runState));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Map<WorkflowInstance, Long> readActiveWorkflowInstances() throws IOException {
final Table activeStatesTable = connection.getTable(ACTIVE_STATES_TABLE_NAME);
final ImmutableMap.Builder<WorkflowInstance, Long> map = ImmutableMap.builder();
for (Result result :... | #fixed code
BigtableStorage(Connection connection, Duration retryBaseDelay) {
this.connection = Objects.requireNonNull(connection);
this.retryBaseDelay = Objects.requireNonNull(retryBaseDelay);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static KubernetesClient getKubernetesClient(Config config, String id) {
try {
final HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
final JsonFactory jsonFactory = Utils.getDefaultJsonFactory();
final GoogleCredent... | #fixed code
private static KubernetesClient getKubernetesClient(Config config, String id) {
try {
final HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
final JsonFactory jsonFactory = Utils.getDefaultJsonFactory();
final GoogleCredential cr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
List<Backfill> getBackfills() {
final EntityQuery query = Query.entityQueryBuilder().kind(KIND_BACKFILL).build();
final QueryResults<Entity> results = datastore.run(query);
final ImmutableList.Builder<Backfill> resources = ImmutableList.builder();
while (r... | #fixed code
DatastoreStorage(Datastore datastore, Duration retryBaseDelay) {
this.datastore = Objects.requireNonNull(datastore);
this.retryBaseDelay = Objects.requireNonNull(retryBaseDelay);
this.componentKeyFactory = datastore.newKeyFactory().kind(KIND_COMPONENT);
this.gl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void transitionInto(RunState state) {
switch (state.state()) {
case SUBMITTING:
try {
final String executionId = dockerRunnerStart(state);
// this is racy
final Event submitted = Event.submitted(state.work... | #fixed code
@Override
public void transitionInto(RunState state) {
switch (state.state()) {
case SUBMITTING:
// Perform rate limited submission on a separate thread pool to avoid blocking the caller.
executor.submit(() -> {
rateLimiter.acquire();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Map<WorkflowInstance, Long> allActiveStates() throws IOException {
final EntityQuery activeStatesQuery = Query.entityQueryBuilder()
.kind(KIND_ACTIVE_STATE)
.build();
final ImmutableMap.Builder<WorkflowInstance, Long> mapBuilder = ImmutableMap.bui... | #fixed code
DatastoreStorage(Datastore datastore, Duration retryBaseDelay) {
this.datastore = Objects.requireNonNull(datastore);
this.retryBaseDelay = Objects.requireNonNull(retryBaseDelay);
this.componentKeyFactory = datastore.newKeyFactory().kind(KIND_COMPONENT);
this.gl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void doRequest(ServletTransaction transaction)
throws ServletException {
try {
HttpServletRequest request = transaction.getServletRequest();
Client client = ClientCatalog
.getClient(request.getParameter("use"));
String report = reque... | #fixed code
@Override
protected void doRequest(ServletTransaction transaction)
throws ServletException {
try {
HttpServletRequest request = transaction.getServletRequest();
Client client = ClientCatalog
.getClient(request.getParameter("use"));
String report = request.get... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void deleteUrl(String sUrl) throws SearchLibException {
try {
client.deleteDocument(sUrl);
} catch (CorruptIndexException e) {
throw new SearchLibException(e);
} catch (LockObtainFailedException e) {
throw new SearchLibException(e);
} catch (IOExcep... | #fixed code
public void deleteUrl(String sUrl) throws SearchLibException {
try {
targetClient.deleteDocument(sUrl);
urlDbClient.deleteDocument(sUrl);
} catch (CorruptIndexException e) {
throw new SearchLibException(e);
} catch (LockObtainFailedException e) {
throw new Sear... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
fieldLeft = null;
selectedFacet = null;
super.reloadPage();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
fieldLeft = null;
selectedFacet = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
highlightFieldLeft = null;
selectedHighlight = null;
super.reloadPage();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
highlightFieldLeft = null;
selectedHighlight = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
super.readExternal(in);
fragmenter = External.readObject(in);
tag = External.readUTF(in);
maxDocChar = in.readInt();
separator = External.readUTF(in);
maxSnippetSize = in.r... | #fixed code
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
super.readExternal(in);
fragmenter = External.readObject(in);
tag = External.readUTF(in);
maxDocChar = in.readInt();
separator = External.readUTF(in);
maxSnippetSize = in.readInt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void onUpload() throws InterruptedException,
XPathExpressionException, NoSuchAlgorithmException,
ParserConfigurationException, SAXException, IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoun... | #fixed code
public void onUpload() throws InterruptedException,
XPathExpressionException, NoSuchAlgorithmException,
ParserConfigurationException, SAXException, IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoundExcep... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
fieldLeft = null;
selectedFacet = null;
super.reloadPage();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
fieldLeft = null;
selectedFacet = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void doRequest(ServletTransaction transaction)
throws ServletException {
try {
Client client = Client.getWebAppInstance();
HttpServletRequest request = transaction.getServletRequest();
String indexName = request.getParameter("index");
... | #fixed code
@Override
protected void doRequest(ServletTransaction transaction)
throws ServletException {
try {
Client client = Client.getWebAppInstance();
HttpServletRequest request = transaction.getServletRequest();
String indexName = request.getParameter("index");
String... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void reload(boolean optimize) throws IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoundException {
if (optimize) {
client.reload(null);
client.getIndex().optimize(null);
}
client.reloa... | #fixed code
public void reload(boolean optimize) throws IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoundException {
if (optimize) {
urlDbClient.reload(null);
urlDbClient.getIndex().optimize(null);
targetClien... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void deleteUrls(Collection<String> workDeleteUrlList)
throws SearchLibException {
try {
client.deleteDocuments(workDeleteUrlList);
} catch (CorruptIndexException e) {
throw new SearchLibException(e);
} catch (LockObtainFailedException e) {
throw ne... | #fixed code
public void deleteUrls(Collection<String> workDeleteUrlList)
throws SearchLibException {
try {
targetClient.deleteDocuments(workDeleteUrlList);
urlDbClient.deleteDocuments(workDeleteUrlList);
} catch (CorruptIndexException e) {
throw new SearchLibException(e);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void writeXmlConfig(XmlWriter xmlWriter) throws SAXException,
SearchLibException {
xmlWriter.startElement("system");
xmlWriter.startElement("availableProcessors", "value", Integer
.toString(getAvailableProcessors()));
xmlWriter.endElement();
xmlWrit... | #fixed code
public void writeXmlConfig(XmlWriter xmlWriter) throws SAXException,
SearchLibException, SecurityException, IOException {
xmlWriter.startElement("system");
xmlWriter.startElement("availableProcessors", "value", Integer
.toString(getAvailableProcessors()));
xmlWrite... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void onAdd() throws SearchLibException,
UnsupportedEncodingException, ParseException, InterruptedException {
synchronized (this) {
if (getSelectedFile() != null) {
// Already In
if (getClient().getFilePathManager().getStrictPaths(
getSelectedFi... | #fixed code
public void onAdd() throws SearchLibException,
UnsupportedEncodingException, ParseException, InterruptedException {
synchronized (this) {
if (getSelectedFile() != null) {
// Already In
if (getClient().getFilePathManager().getFilePaths(
getSelectedFile().get... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getNewUrlToFetch(NamedItem host, long limit,
List<UrlItem> urlList) throws SearchLibException, ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException,
InstantiationException, IllegalAccessException... | #fixed code
public void getNewUrlToFetch(NamedItem host, long limit,
List<UrlItem> urlList) throws SearchLibException, ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException,
InstantiationException, IllegalAccessException {
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateUrlItems(List<UrlItem> urlItems)
throws SearchLibException {
try {
List<IndexDocument> documents = new ArrayList<IndexDocument>(
urlItems.size());
for (UrlItem urlItem : urlItems) {
IndexDocument indexDocument = new IndexDocument();
... | #fixed code
public void updateUrlItems(List<UrlItem> urlItems)
throws SearchLibException {
try {
List<IndexDocument> documents = new ArrayList<IndexDocument>(
urlItems.size());
for (UrlItem urlItem : urlItems) {
IndexDocument indexDocument = new IndexDocument();
urlI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getStartingWith(String queryString, Field field, String start,
int limit, List<NamedItem> list) throws ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException, SearchLibException,
InstantiationExcep... | #fixed code
public void getStartingWith(String queryString, Field field, String start,
int limit, List<NamedItem> list) throws ParseException,
IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException, SearchLibException,
InstantiationException, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public long getUrls(SearchRequest searchRequest, Field orderBy,
boolean orderAsc, long start, long rows, List<UrlItem> list)
throws SearchLibException {
searchRequest.setStart((int) start);
searchRequest.setRows((int) rows);
try {
if (orderBy != null)
se... | #fixed code
public long getUrls(SearchRequest searchRequest, Field orderBy,
boolean orderAsc, long start, long rows, List<UrlItem> list)
throws SearchLibException {
searchRequest.setStart((int) start);
searchRequest.setRows((int) rows);
try {
if (orderBy != null)
searchRe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void renderDocument(int pos) throws CorruptIndexException,
IOException, ParseException, SyntaxError {
writer.print("\t<doc score=\"");
writer.print(result.getDocs()[pos].score);
writer.print("\" pos=\"");
writer.print(pos);
writer.println("\">");
Res... | #fixed code
private void renderDocument(int pos) throws CorruptIndexException,
IOException, ParseException, SyntaxError {
writer.print("\t<doc score=\"");
writer.print(result.getScore(pos));
writer.print("\" pos=\"");
writer.print(pos);
writer.println("\">");
ResultDocument d... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
highlightFieldLeft = null;
selectedHighlight = null;
super.reloadPage();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
highlightFieldLeft = null;
selectedHighlight = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateCrawls(List<Crawl> crawls) throws SearchLibException {
try {
List<IndexDocument> documents = new ArrayList<IndexDocument>(crawls
.size());
for (Crawl crawl : crawls) {
IndexDocument indexDocument = new IndexDocument();
crawl.getUrlIte... | #fixed code
public void updateCrawls(List<Crawl> crawls) throws SearchLibException {
try {
// Update target index
List<IndexDocument> documents = new ArrayList<IndexDocument>(crawls
.size());
for (Crawl crawl : crawls) {
IndexDocument indexDocument = crawl.getTargetIndex... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getOldUrlToFetch(NamedItem host, Date fetchIntervalDate,
long limit, List<UrlItem> urlList) throws SearchLibException,
ParseException, IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException,
InstantiationException... | #fixed code
public void getOldUrlToFetch(NamedItem host, Date fetchIntervalDate,
long limit, List<UrlItem> urlList) throws SearchLibException,
ParseException, IOException, SyntaxError, URISyntaxException,
ClassNotFoundException, InterruptedException,
InstantiationException, Ille... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reloadPage() {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
protected void reloadPage() {
synchronized (this) {
selectedSort = null;
sortFieldLeft = null;
super.reloadPage();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void reload(boolean optimize) throws IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoundException {
if (optimize) {
client.reload(null);
client.getIndex().optimize(null);
}
client.reloa... | #fixed code
public void reload(boolean optimize) throws IOException,
URISyntaxException, SearchLibException, InstantiationException,
IllegalAccessException, ClassNotFoundException {
if (optimize) {
urlDbClient.reload(null);
urlDbClient.getIndex().optimize(null);
targetClien... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run(ResultScoreDoc[] fetchedDocs, int fetchLength)
throws IOException {
collapsedDoc = null;
if (fetchedDocs == null)
return;
if (fetchLength > fetchedDocs.length)
fetchLength = fetchedDocs.length;
OpenBitSet collapsedSet = new OpenBitSet(f... | #fixed code
public void run(ResultScoreDoc[] fetchedDocs, int fetchLength)
throws IOException {
collapsedDoc = null;
if (fetchedDocs == null)
return;
if (fetchLength > fetchedDocs.length)
fetchLength = fetchedDocs.length;
collapse(fetchedDocs, fetchLength);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
final protected void getFragments(String originalText,
FragmentList fragments, int vectorOffset) {
originalTextLength = originalText.length();
if (splitPos == null)
splitPos = new TreeSet<Integer>();
splitPos.clear();
check(originalText);
Iterator<Integer> ... | #fixed code
final protected void getFragments(String originalText,
FragmentList fragments, int vectorOffset) {
originalTextLength = originalText.length();
if (splitPos == null)
splitPos = new TreeSet<Integer>();
splitPos.clear();
check(originalText);
Iterator<Integer> splitI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static HTMLDocument fetch(final URL url) throws IOException {
final URLConnection conn = url.openConnection();
final String charset = conn.getContentEncoding();
Charset cs = Charset.forName("Cp1252");
if (charset != null) {
try {
cs = Charset.forName... | #fixed code
public static HTMLDocument fetch(final URL url) throws IOException {
final URLConnection conn = url.openConnection();
final String ct = conn.getContentType();
Charset cs = Charset.forName("Cp1252");
if (ct != null) {
Matcher m = PAT_CHARSET.matcher(ct);
if(m.find(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getText(final URL url) throws BoilerpipeProcessingException {
try {
final URLConnection conn = url.openConnection();
final String encoding = conn.getContentEncoding();
Charset cs = Charset.forName("Cp1252");
... | #fixed code
public String getText(final URL url) throws BoilerpipeProcessingException {
try {
return getText(HTMLFetcher.fetch(url).toInputSource());
} catch (IOException e) {
throw new BoilerpipeProcessingException(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static HTMLDocument fetch(final URL url) throws IOException {
final URLConnection conn = url.openConnection();
final String charset = conn.getContentEncoding();
Charset cs = Charset.forName("Cp1252");
if (charset != null) {
try {
cs = Charset.forName... | #fixed code
public static HTMLDocument fetch(final URL url) throws IOException {
final URLConnection conn = url.openConnection();
final String ct = conn.getContentType();
Charset cs = Charset.forName("Cp1252");
if (ct != null) {
Matcher m = PAT_CHARSET.matcher(ct);
if(m.find(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void insertLoginLog(String username) {
UmsAdmin admin = getAdminByUsername(username);
UmsAdminLoginLog loginLog = new UmsAdminLoginLog();
loginLog.setAdminId(admin.getId());
loginLog.setCreateTime(new Date());
ServletReque... | #fixed code
private void insertLoginLog(String username) {
UmsAdmin admin = getAdminByUsername(username);
if(admin==null) return;
UmsAdminLoginLog loginLog = new UmsAdminLoginLog();
loginLog.setAdminId(admin.getId());
loginLog.setCreateTime(new Dat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getUserNameFromToken(String token) {
String username;
try {
Claims claims = getClaimsFromToken(token);
username = claims.getSubject();
} catch (Exception e) {
e.printStackTrace();
user... | #fixed code
public String getUserNameFromToken(String token) {
String username;
try {
Claims claims = getClaimsFromToken(token);
username = claims.getSubject();
} catch (Exception e) {
username = null;
}
return ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Date getExpiredDateFromToken(String token) {
Date expiredDate = null;
try {
Claims claims = getClaimsFromToken(token);
expiredDate = claims.getExpiration();
} catch (Exception e) {
e.printStackTrace();
... | #fixed code
private Date getExpiredDateFromToken(String token) {
Claims claims = getClaimsFromToken(token);
return claims.getExpiration();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onHttpFinish(QQHttpResponse response) {
try {
LOG.debug(response.getContentType());
String type = response.getContentType();
if((type.startsWith("application/x-javascript")
|| type.startsWith("application/json")
|| type.indexOf("... | #fixed code
@Override
public void onHttpFinish(QQHttpResponse response) {
try {
LOG.debug(response.getContentType());
String type = response.getContentType();
if(type!=null && (type.startsWith("application/x-javascript")
|| type.startsWith("application/json")
|| type.i... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void progressCallbackSend() throws Exception {
final AtomicReference<String> body = new AtomicReference<String>();
handler = new RequestHandler() {
@Override
public void handle(Request request, HttpServletResponse response) {
bo... | #fixed code
@Test
public void progressCallbackSend() throws Exception {
final AtomicReference<String> body = new AtomicReference<String>();
handler = new RequestHandler() {
@Override
public void handle(Request request, HttpServletResponse response) {
body.set... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void progressCallbackSendInputStream() throws Exception {
final AtomicReference<String> body = new AtomicReference<String>();
handler = new RequestHandler() {
@Override
public void handle(Request request, HttpServletResponse response) {... | #fixed code
@Test
public void progressCallbackSendInputStream() throws Exception {
final AtomicReference<String> body = new AtomicReference<String>();
handler = new RequestHandler() {
@Override
public void handle(Request request, HttpServletResponse response) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181");
node.join();
new BufferedReader(ne... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode();
node.join();
new BufferedReader(new InputStreamReader(System.in)).readLine();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode("localhost:2181,localhost:3181,localhost:4181", "http://localhost:8080/job");
node.join();
new BufferedReader(new InputStreamReader(Syst... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode("localhost:2181,localhost:3181,localhost:4181", "http://localhost:8080/job", StringHelper.emptyArray());
node.join();
new BufferedReader(new I... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new MasterSlaveNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181");
node.join();
new BufferedReade... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new MasterSlaveNode();
node.join();
new BufferedReader(new InputStreamReader(System.in)).readLine();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181");
node.join();
new BufferedReader(ne... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode();
node.join();
new BufferedReader(new InputStreamReader(System.in)).readLine();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<MasterSlaveNodeData> getAllNodes() {
List<ChildData> childDataList = getChildren(PathHelper.getParentPath(getMasterSlavePathApi().getNodePath()));
List<MasterSlaveNodeData> masterSlaveNodeDataList = childDataList.stream().map(Ma... | #fixed code
@Override
public List<MasterSlaveNodeData> getAllNodes() {
List<ChildData> childDataList = getChildren(PathHelper.getParentPath(getMasterSlavePathApi().getNodePath()));
if (ListHelper.isEmpty(childDataList)) {
return null;
}
Lis... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode("localhost:2181,localhost:3181,localhost:4181", "http://localhost:8080/job");
node.join();
new BufferedReader(new InputStreamReader(Syst... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new StandbyNode("localhost:2181,localhost:3181,localhost:4181", "http://localhost:8080/job", StringHelper.emptyArray());
node.join();
new BufferedReader(new I... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<StandbyNodeData> getAllNodes() {
List<ChildData> childDataList = getChildren(PathHelper.getParentPath(getStandbyPathApi().getNodePath()));
List<StandbyNodeData> standbyNodeDataList = childDataList.stream().map(StandbyNodeData::n... | #fixed code
@Override
public List<StandbyNodeData> getAllNodes() {
List<ChildData> childDataList = getChildren(PathHelper.getParentPath(getStandbyPathApi().getNodePath()));
if (ListHelper.isEmpty(childDataList)) {
return null;
}
List<Standb... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new MasterSlaveNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181");
node.join();
new BufferedReade... | #fixed code
@org.junit.Test
public void test() throws InterruptedException, IOException {
Node node = new MasterSlaveNode();
node.join();
new BufferedReader(new InputStreamReader(System.in)).readLine();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<Pair<String, String>> getColumns(String schema, String table) throws VerdictDBDbmsException {
List<Pair<String, String>> columns = new ArrayList<>();
DbmsQueryResult queryResult = execute(syntax.getColumnsCommand(schema, table));
JdbcRe... | #fixed code
@Override
public List<Pair<String, String>> getColumns(String schema, String table) throws VerdictDBDbmsException {
List<Pair<String, String>> columns = new ArrayList<>();
DbmsQueryResult queryResult = execute(syntax.getColumnsCommand(schema, table));
while (query... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> getSchemas() throws SQLException {
if (!schemaCache.isEmpty()){
return schemaCache;
}
DbmsQueryResult queryResult = connection.executeQuery(syntax.getSchemaCommand());
JdbcResultSet jdbcQueryResult = new JdbcResultSet(queryResult)... | #fixed code
public List<String> getSchemas() throws SQLException {
if (!schemaCache.isEmpty()){
return schemaCache;
}
schemaCache.addAll(connection.getSchemas());
return schemaCache;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ApproxRelation approx() throws VerdictException {
List<Expr> exprs = exprsInSelectElems(elems);
// for each expression, we obtain pairs of sample candidates and the costs of using them.
List<Pair<Map<Set<SampleParam>, List<Double>>, SelectElem>> candidates... | #fixed code
public ApproxRelation approx() throws VerdictException {
// for each expression, we obtain pairs of sample candidates and the costs of using them.
List<List<SampleGroup>> candidates_list = new ArrayList<List<SampleGroup>>();
for (int i = 0; i < elems.size(); i++) {
Lis... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public ExactRelation rewriteWithSubsampledErrorBounds() {
ExactRelation newSource = source.rewriteWithSubsampledErrorBounds();
List<SelectElem> sourceElems = null; // newSource.getSelectList();
Set<String> colAliases = new HashSet<String>();
for (SelectE... | #fixed code
@Override
public ExactRelation rewriteWithSubsampledErrorBounds() {
ExactRelation r = rewriteWithPartition(true);
// construct a new list of select elements. the last element is __vpart, which should be omitted.
// newElems and newAggs hold almost the same info; just r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String visitQuery_specification(VerdictSQLParser.Query_specificationContext ctx) {
List<Pair<String, String>> subqueryColName2Aliases = null;
BootstrapSelectStatementRewriter singleRewriter = null;
StringBuilder unionedFrom = new StringBuilder(20... | #fixed code
@Override
public String visitQuery_specification(VerdictSQLParser.Query_specificationContext ctx) {
StringBuilder sql = new StringBuilder(2000);
// this statement computes the mean value
AnalyticSelectStatementRewriter meanRewriter = new AnalyticSelectStatementRewriter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> getPartitionColumns(String schema, String table) throws SQLException {
if (!syntax.doesSupportTablePartitioning()) {
throw new SQLException("Database does not support table partitioning");
}
if (!partitionCache.isEmpty()){
retur... | #fixed code
public List<String> getPartitionColumns(String schema, String table) throws SQLException {
if (!syntax.doesSupportTablePartitioning()) {
throw new SQLException("Database does not support table partitioning");
}
if (!partitionCache.isEmpty()){
return part... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public ExactRelation rewriteWithSubsampledErrorBounds() {
ExactRelation r = rewriteWithPartition();
// List<SelectElem> selectElems = r.selectElemsWithAggregateSource();
List<SelectElem> selectElems = ((AggregatedRelation) r).getAggList();
// another w... | #fixed code
@Override
public ExactRelation rewriteWithSubsampledErrorBounds() {
ExactRelation r = rewriteWithPartition();
// List<SelectElem> selectElems = r.selectElemsWithAggregateSource();
List<SelectElem> selectElems = ((AggregatedRelation) r).getAggList();
// another wrapper... | 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.