output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
private void verifyArchivedHello(WorkflowRun run, String basePath) throws IOException {
assertTrue("Build should have artifacts", run.getHasArtifacts());
Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
assertEquals("hello.z... | #vulnerable code
private void verifyArchivedHello(WorkflowRun run, String basePath) throws IOException {
assertTrue("Build should have artifacts", run.getHasArtifacts());
Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
assertEquals("h... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void calcRemainingQuota(Long quota, Long refreshInterval,
Long requestTime, String key, Rate rate) {
if (Objects.nonNull(quota)) {
String quotaKey = key + QUOTA_SUFFIX;
long usage = ... | #vulnerable code
@Override
protected void calcRemainingQuota(Long quota, Long refreshInterval,
Long requestTime, String key, Rate rate) {
if (quota != null) {
String quotaKey = key + QUOTA_SUFFIX;
handleExpiration... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Long getRequestStartTime() {
final RequestContext ctx = RequestContext.getCurrentContext();
final HttpServletRequest request = ctx.getRequest();
return (Long) request.getAttribute(REQUEST_START_TIME);
} | #vulnerable code
private Long getRequestStartTime() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
return (Long) requestAttributes.getAttribute(REQUEST_START_TIME, SCOPE_REQUEST);
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Long calcRemaining(Long limit, Long refreshInterval, long usage,
String key, Rate rate) {
rate.setReset(SECONDS.toMillis(refreshInterval));
Long current = 0L;
try {
current = redisTemplate.opsForValue(... | #vulnerable code
private Long calcRemaining(Long limit, Long refreshInterval, long usage,
String key, Rate rate) {
rate.setReset(SECONDS.toMillis(refreshInterval));
Long current = 0L;
try {
current = redisTemplate.opsFor... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void calcRemainingLimit(Long limit, Long refreshInterval,
Long requestTime, String key, Rate rate) {
if (Objects.nonNull(limit)) {
long usage = requestTime == null ? 1L : 0L;
Long re... | #vulnerable code
@Override
protected void calcRemainingLimit(Long limit, Long refreshInterval,
Long requestTime, String key, Rate rate) {
if (limit != null) {
long usage = requestTime == null ? 1L : 0L;
Long curre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
LatticeNode getOOVNode(String text, OOV oov, int length) {
LatticeNode node = createNode();
node.setParameter(oov.leftId, oov.rightId, oov.cost);
WordInfo info = new WordInfo(text, (short) length, oov.posId, text, text, "");
node.setWordInfo(in... | #vulnerable code
void readCharacterProperty(String charDef) throws IOException {
try (InputStream input = (charDef == null) ? openFromJar("char.def") : new FileInputStream(charDef);
InputStreamReader isReader = new InputStreamReader(input, StandardCharsets.UTF_8)... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
DictionaryBuilder() {
buffer = ByteBuffer.allocate(BUFFER_SIZE);
buffer.order(ByteOrder.LITTLE_ENDIAN);
} | #vulnerable code
void buildLexicon(String filename, FileInputStream lexiconInput) throws IOException {
int lineno = -1;
try (InputStreamReader isr = new InputStreamReader(lexiconInput);
LineNumberReader reader = new LineNumberReader(isr)) {
fo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws IOException {
try (FileInputStream lexiconInput = new FileInputStream(args[0]);
FileInputStream matrixInput = new FileInputStream(args[1]);
FileOutputStream output = new FileOutputStream(args[2]))... | #vulnerable code
public static void main(String[] args) throws IOException {
FileInputStream lexiconInput = new FileInputStream(args[0]);
FileInputStream matrixInput = new FileInputStream(args[1]);
FileOutputStream output = new FileOutputStream(args[2]);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
LatticeNode getOOVNode(String text, OOV oov, int length) {
LatticeNode node = createNode();
node.setParameter(oov.leftId, oov.rightId, oov.cost);
WordInfo info = new WordInfo(text, (short) length, oov.posId, text, text, "");
node.setWordInfo(in... | #vulnerable code
void readOOV(String unkDef, Grammar grammar) throws IOException {
try (InputStream input = (unkDef == null) ? openFromJar("unk.def") : new FileInputStream(unkDef);
InputStreamReader isReader = new InputStreamReader(input, StandardCharsets.UTF_8);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws IOException {
try (FileInputStream lexiconInput = new FileInputStream(args[0]);
FileInputStream matrixInput = new FileInputStream(args[1]);
FileOutputStream output = new FileOutputStream(args[2]))... | #vulnerable code
public static void main(String[] args) throws IOException {
FileInputStream lexiconInput = new FileInputStream(args[0]);
FileInputStream matrixInput = new FileInputStream(args[1]);
FileOutputStream output = new FileOutputStream(args[2]);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void handleRead() throws IOException {
if( !socketBuffer.hasRemaining() ) {
socketBuffer.rewind();
socketBuffer.limit( socketBuffer.capacity() );
if( sockchannel.read( socketBuffer ) == -1 ) {
if( draft == null ) {
closeConnection( CloseFram... | #vulnerable code
long bufferedDataAmount() {
return bufferQueueTotalAmount;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void decode( ByteBuffer socketBuffer ) {
if( !socketBuffer.hasRemaining() || flushandclosestate )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to display" : new String( soc... | #vulnerable code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || flushandclosestate )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to d... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() throws IOException {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
thread.interrupt();
this.server.close();
} | #vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 7
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void close() {
if( thread != null ) {
conn.close( CloseFrame.NORMAL );
/*closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}*/
}
} | #vulnerable code
public void close() {
if( thread != null ) {
thread.interrupt();
closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}
}
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
selector.close();
} catch ( IOException e ) {
onError( e );
}
closelock.lock();
selector = null;
closelock.unlock();
try {
channel.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
thread = null;
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void close() {
if( thread != null ) {
conn.close( CloseFrame.NORMAL );
/*closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}*/
}
} | #vulnerable code
public void close() {
if( thread != null ) {
thread.interrupt();
closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}
}
}
#location 7
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void flush() throws IOException {
ByteBuffer buffer = this.bufferQueue.peek();
while ( buffer != null ) {
sockchannel.write( buffer );
if( buffer.remaining() > 0 ) {
continue;
} else {
// subtract this amount of data from the total queued (synchronize... | #vulnerable code
public void flush() throws IOException {
ByteBuffer buffer = this.bufferQueue.peek();
while ( buffer != null ) {
sockchannel.write( buffer );
if( buffer.remaining() > 0 ) {
continue;
} else {
synchronized ( bufferQueueTotalAmount ) {
// subtract t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
retu... | #vulnerable code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int getConnectionLostTimeout() {
synchronized (syncConnectionLost) {
return connectionLostTimeout;
}
} | #vulnerable code
public int getConnectionLostTimeout() {
return connectionLostTimeout;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() throws IOException , InterruptedException {
stop( 0 );
} | #vulnerable code
public void stop() throws IOException , InterruptedException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
selectorthread.interrupt();
selectorthread.join();
for( WebSocketWorker w : decoders ) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void start() {
if( selectorthread != null )
throw new IllegalStateException( "Already started" );
new Thread( this ).start();
} | #vulnerable code
public void start() {
if( thread != null )
throw new IllegalStateException( "Already started" );
new Thread( this ).start();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
retu... | #vulnerable code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || connectionClosed )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to display" ... | #vulnerable code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to display" : new String( ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
retu... | #vulnerable code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
selectorthread.interrupt();
this.server.close();
} | #vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 7
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.configureB... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || flushandclosestate )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to display... | #vulnerable code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || connectionClosed )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to dis... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || flushandclosestate )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to display... | #vulnerable code
public void decode( ByteBuffer socketBuffer ) throws IOException {
if( !socketBuffer.hasRemaining() || connectionClosed )
return;
if( DEBUG )
System.out.println( "process(" + socketBuffer.remaining() + "): {" + ( socketBuffer.remaining() > 1000 ? "too big to dis... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
synchronized ( this ) {
if( selectorthread != null )
throw new IllegalStateException( getClass().getName() + " can only be started once." );
selectorthread = Thread.currentThread();
if( isclosed.get() ) {
return;
}
}
selectorthread.s... | #vulnerable code
public void run() {
synchronized ( this ) {
if( selectorthread != null )
throw new IllegalStateException( getClass().getName() + " can only be started once." );
selectorthread = Thread.currentThread();
if( isclosed.get() ) {
return;
}
}
selectorth... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() throws IOException , InterruptedException {
stop( 0 );
} | #vulnerable code
public void stop() throws IOException , InterruptedException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
selectorthread.interrupt();
selectorthread.join();
for( WebSocketWorker w : decoders ) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( selectorthread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
selectorthread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
s... | #vulnerable code
public void run() {
if( thread != null )
throw new IllegalStateException( "This instance of " + getClass().getSimpleName() + " can only be started once the same time." );
thread = Thread.currentThread();
try {
server = ServerSocketChannel.open();
server.conf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public final void onWriteDemand( WebSocket conn ) {
try {
conn.flush();
} catch ( IOException e ) {
handleIOException( conn, e );
}
/*synchronized ( write_demands ) {
if( !write_demands.contains( conn ) ) {
write_demands.add( conn );
flusher.s... | #vulnerable code
@Override
public final void onWriteDemand( WebSocket conn ) {
selector.wakeup();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() throws IOException {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
thread.interrupt();
this.server.close();
} | #vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 8
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
retu... | #vulnerable code
protected final void interruptableRun() {
try {
tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
} catch ( ClosedByInterruptException e ) {
onWebsocketError( null, e );
return;
} catch ( IOException e ) {//
onWebsocketError( conn, e );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
assert ( !channel.isOpen() );
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catc... | #vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
try {
if( selector != null ) // if the initialization in <code>tryToConnect</code> fails, it could be null
selector.close();
} catch ( IOException e ) {
onEr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void roundTripWriteAndRead() throws TaskException, IOException {
List<String> strings = Arrays.asList("ગુજરાતી ਪੰਜਾਬੀ தமிழ்",
"ਹਰਜੋਤ ਸਿੰਘ ភាសាខ្មែរ latin ąćęłńóśźż ทดสอบ വീട मानक हिन्दी ് జ উ ☗⦄✸▃ ");
for(String str: strings) ... | #vulnerable code
@Test
public void roundTripWriteAndRead() throws TaskException, IOException {
String str = "ਹਰਜੋਤ ਸਿੰਘ ភាសាខ្មែរ latin ąćęłńóśźż ทดสอบ വീട मानक हिन्दी ് జ উ ☗⦄✸▃ ";
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
new Pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public TaskTestContext assertOutputSize(int size) {
requireMultipleOutputs();
String[] files = fileOutput.list();
assertEquals("An unexpected number of output files has been created: " + StringUtils.join(files, ","),
size, files.length)... | #vulnerable code
public TaskTestContext assertOutputSize(int size) {
requireMultipleOutputs();
assertEquals("An unexpected number of output files has been created", size, fileOutput.listFiles().length);
return this;
}
#location 3 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void mergeNull() {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCatalog().getAcroForm());
victim.mergeForm(null, a... | #vulnerable code
@Test
public void mergeNull() {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCatalog().getAcroForm());
victim.mergeForm(n... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBasics() throws TaskException, IOException {
withSource("pdf/unoptimized.pdf");
victim.execute(parameters);
assertThat(sizeOfResult(), is(lessThan(104L)));
} | #vulnerable code
@Test
public void testBasics() throws TaskException, IOException {
parameters.setOutput(new DirectoryTaskOutput(outputFolder));
victim.execute(parameters);
long sizeInKb = outputFolder.listFiles()[0].length() / 1000;
assertThat(sizeIn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void canDisplayGeorgian() {
assertNotNull(findFontFor("ქართული ენა"));
} | #vulnerable code
@Test
public void canDisplayGeorgian() {
PDFont font = FontUtils.findFontFor(new PDDocument(), "ქართული ენა");
assertNotNull("No font available for Georgian", font);
assertThat(font.getName(), is("NotoSansGeorgian"));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void extract(PDDocument document, File output) throws TaskException {
if (document == null) {
throw new TaskException("Unable to extract text from a null document.");
}
if (output == null || !output.isFile() || !output.canWrite()) {
... | #vulnerable code
public void extract(PDDocument document, File output) throws TaskException {
if (document == null) {
throw new TaskException("Unable to extract text from a null document.");
}
if (output == null || !output.isFile() || !output.canWrite... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void canDisplayGeorgian() {
assertNotNull(findFontFor("ქართული ენა"));
} | #vulnerable code
@Test
public void canDisplayGeorgian() {
PDFont font = FontUtils.findFontFor(new PDDocument(), "ქართული ენა");
assertNotNull("No font available for Georgian", font);
assertThat(font.getName(), is("NotoSansGeorgian"));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void resolveTextAndFontsWhenTextRepeats() throws TaskIOException {
write("123α456α789");
} | #vulnerable code
@Test
public void resolveTextAndFontsWhenTextRepeats() throws TaskIOException {
PageTextWriter writer = new PageTextWriter(new PDDocument());
List<PageTextWriter.TextWithFont> textAndFonts = writer.resolveFonts("123α456α789", helvetica);
ass... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void execute(JpegToPdfParameters parameters) throws TaskException {
final MutableInt currentStep = new MutableInt(0);
ImagesToPdfDocumentConverter converter = new ImagesToPdfDocumentConverter() {
@Override
public v... | #vulnerable code
@Override
public void execute(JpegToPdfParameters parameters) throws TaskException {
int currentStep = 0;
documentHandler = new PDDocumentHandler();
documentHandler.setCreatorOnPDDocument();
PageImageWriter imageWriter = new PageIma... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void resolvedSpaceSeparately() throws TaskIOException {
write("ab cd");
} | #vulnerable code
@Test
public void resolvedSpaceSeparately() throws TaskIOException {
PageTextWriter writer = new PageTextWriter(new PDDocument());
List<PageTextWriter.TextWithFont> textAndFonts = writer.resolveFonts("ab cd", helvetica);
assertThat(textAndFo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static void copyToStreamZipped(Map<String, File> files, OutputStream out) throws IOException {
try (ZipOutputStream zipOut = new ZipOutputStream(out)) {
for (Entry<String, File> entry : files.entrySet()) {
if (isBlank(entry.getKey())) {
... | #vulnerable code
static void copyToStreamZipped(Map<String, File> files, OutputStream out) throws IOException {
ZipOutputStream zipOut = new ZipOutputStream(out);
for (Entry<String, File> entry : files.entrySet()) {
FileInputStream input = null;
i... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCanDisplayThai() {
assertThat(findFontFor("นี่คือการทดสอบ"), is(notNullValue()));
} | #vulnerable code
@Test
public void testCanDisplayThai() {
PDFont noto = FontUtils.loadFont(new PDDocument(), UnicodeType0Font.NOTO_SANS_THAI_REGULAR);
assertThat(FontUtils.canDisplay("นี่คือการทดสอบ", noto), is(true));
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void mergeWithSignatureRemovesSignatureValue() throws IOException {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCatalog()... | #vulnerable code
@Test
public void mergeWithSignatureRemovesSignatureValue() throws IOException {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public TaskTestContext assertEmptyMultipleOutput() {
assertNotNull(fileOutput);
assertTrue("Expected an output directory", fileOutput.isDirectory());
assertEquals("Found output files while expecting none", 0,
fileOutput.listFiles((d, n)... | #vulnerable code
public TaskTestContext assertEmptyMultipleOutput() {
assertNotNull(fileOutput);
assertTrue("Expected an output directory", fileOutput.isDirectory());
assertEquals("Found output files while expecting none", 0, fileOutput.listFiles().length);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testFindFontFor() {
assertNotNull(findFontFor("ทดสอบ")); // thai
assertNotNull(findFontFor("αυτό είναι ένα τεστ")); // greek
assertNotNull(findFontFor("വീട്")); // malayalam
assertNotNull(findFontFor("मानक")); // hindi
... | #vulnerable code
@Test
public void testFindFontFor() {
assertEquals("NotoSansThai", findFontFor(new PDDocument(), "ทดสอบ").getName());
assertEquals("NotoSans", findFontFor(new PDDocument(), "αυτό είναι ένα τεστ").getName());
assertNull(findFontFor(new PDDocum... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String generate(NameGenerationRequest request) {
if (request == null) {
throw new IllegalArgumentException("Unable to generate a name for a null request.");
}
return toSafeFilename(prefixTypesChain.process(prefix, ofNullable(request)... | #vulnerable code
public String generate(NameGenerationRequest request) {
if (request == null) {
throw new IllegalArgumentException("Unable to generate a name for a null request.");
}
String result = toSafeFilename(
prefixTypesChain.pro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void before(AlternateMixParameters parameters, TaskExecutionContext executionContext) throws TaskException {
super.before(parameters, executionContext);
mixer = new PdfAlternateMixer();
outputWriter = OutputWriters.newSingleOutputW... | #vulnerable code
@Override
public void before(AlternateMixParameters parameters, TaskExecutionContext executionContext) throws TaskException {
super.before(parameters, executionContext);
mixer = new PdfAlternateMixer(parameters.getFirstInput(), parameters.getSecondIn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void writeToArchive(File[] sources, ArchiveOutputStream archive) throws IOException {
for (File source : sources) {
if (!source.exists()) {
throw new FileNotFoundException(source.getPath());
} else if (!source.canRead(... | #vulnerable code
protected void writeToArchive(File[] sources, ArchiveOutputStream archive) throws IOException {
for (File source : sources) {
if (!source.exists()) {
throw new FileNotFoundException(source.getPath());
} else if (!source.ca... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static ArchiveOutputStream createArchiveOutputStream(CommonsArchiver archiver, File archive) throws IOException,
ArchiveException {
return createArchiveOutputStream(archiver.getArchiveFormat(), archive);
} | #vulnerable code
static ArchiveOutputStream createArchiveOutputStream(CommonsArchiver archiver, File archive) throws IOException,
ArchiveException {
return createArchiveOutputStream(archiver.getFileType(), new FileOutputStream(archive));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static FileModeMapper create(ArchiveEntry entry) {
if (IS_POSIX) {
return new PosixPermissionMapper(entry);
}
// TODO: implement basic windows permission mapping (e.g. with File.setX or attrib)
return new FallbackFileModeMap... | #vulnerable code
public static FileModeMapper create(ArchiveEntry entry) {
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
// FIXME: this is really horrid, but with java 6 i need the system call to 'chmod'
// TODO: implement basic... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination)
throws IOException, CompressorException {
return createCompressorOutputStream(compressor.getCompressionType(), destination);
} | #vulnerable code
static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination)
throws IOException, CompressorException {
return createCompressorOutputStream(compressor.getFileType(), new FileOutputStream(destination));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void initialize() {
InputStream in = PinyinDic.class.getResourceAsStream(dicLocation);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
try {
String line = null;
long startPoint = System.currentTime... | #vulnerable code
private void initialize() {
InputStream in = PinyinDic.class.getResourceAsStream(dicLocation);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
try {
String line = null;
long startPoint = System.curre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<ProjectMailTicketConfig> findAll() {
return aggregateByConfig(queries.findAllConfigs(), queries.findAllTickets());
} | #vulnerable code
public List<ProjectMailTicketConfig> findAll() {
List<ProjectMailTicketConfig> configs = queries.findAllConfigs();
List<ProjectMailTicket> ticketConfigs = queries.findAllTickets();
Map<Integer, List<ProjectMailTicket>> ticketConfigsByConfigId = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testFindCardsId() {
Card c1 = cardService.createCard("card1", col1.getId(), new Date(), user);
Card c2 = cardService.createCard("card2", col1.getId(), new Date(), user);
Card c3 = cardService.createCard("card3", col1.getId(), new Date(), user);
Map<St... | #vulnerable code
@Test
public void testFindCardsId() {
Card c1 = cardService.createCard("card1", col1.getId(), new Date(), user);
Card c2 = cardService.createCard("card2", col1.getId(), new Date(), user);
Card c3 = cardService.createCard("card3", col1.getId(), new Date(), user);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void checkNew() {
List<ProjectMailTicketConfig> entries = mailTicketRepository.findAll();
for(ProjectMailTicketConfig entry: entries) {
MailReceiver receiver = entry.getConfig().getInboundProtocol().startsWith("pop3") ?
getP... | #vulnerable code
public void checkNew() {
List<ProjectMailTicketConfig> entries = mailTicketRepository.findAll();
for(ProjectMailTicketConfig entry: entries) {
MailReceiver receiver = entry.getConfig().getInboundProtocol().startsWith("pop3") ?
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void updateWinrate() {
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) {
history.getData().winrate = stats.maxWinrate;
// we won't set playouts here. but ... | #vulnerable code
public void updateWinrate() {
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) {
history.getData().winrate = stats.maxWinrate;
if (Lizzie.leelaz.isKataGo) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void clear() {
initialize();
} | #vulnerable code
public void clear() {
while (previousMove());
history.clear();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void drawWoodenBoard(Graphics2D g) {
if (uiConfig.getBoolean("fancy-board")) {
if (cachedBoardImage == null) {
try {
cachedBoardImage = ImageIO.read(getClass().getResourceAsStream("/assets/board.png"));
... | #vulnerable code
private void drawWoodenBoard(Graphics2D g) {
if (uiConfig.getBoolean("fancy-board")) {
// fancy version
int shadowRadius = (int) (boardLength * MARGIN / 6);
BufferedImage boardImage = theme.getBoard();
// Support s... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static boolean save(String filename) throws IOException {
FileOutputStream fp = new FileOutputStream(filename);
OutputStreamWriter writer = new OutputStreamWriter(fp);
try
{
// add SGF header
StringBuilder builde... | #vulnerable code
public static boolean save(String filename) throws IOException {
FileOutputStream fp = new FileOutputStream(filename);
OutputStreamWriter writer = new OutputStreamWriter(fp);
StringBuilder builder = new StringBuilder(String.format("(;KM[7.5]AP[Li... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void ponder() {
isPondering = true;
startPonderTime = System.currentTimeMillis();
if (Lizzie.board.isAvoding && Lizzie.board.isKeepingAvoid && !isKataGo)
analyzeAvoid(
"avoid b "
+ Lizzie.board.avoidCoords
+ " "
... | #vulnerable code
public void ponder() {
isPondering = true;
startPonderTime = System.currentTimeMillis();
if (Lizzie.board.isAvoding && Lizzie.board.isKeepingAvoid && !isKataGo)
analyzeAvoid(
"avoid",
Lizzie.board.getHistory().isBlacksTurn() ? "w" : "... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void sendCommand(String command) {
command = cmdNumber + " " + command;
cmdNumber++;
if (printCommunication) {
System.out.printf("> %s\n", command);
}
if (command.startsWith("fixed_handicap"))
isSettingHan... | #vulnerable code
public void sendCommand(String command) {
if (printCommunication) {
System.out.printf("> %s\n", command);
}
if (command.startsWith("fixed_handicap"))
isSettingHandicap = true;
if (command.startsWith("genmove"))
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static boolean parse(String value) {
// Drop anything outside "(;...)"
final Pattern SGF_PATTERN = Pattern.compile("(?s).*?(\\(\\s*;{0,1}.*\\))(?s).*?");
Matcher sgfMatcher = SGF_PATTERN.matcher(value);
if (sgfMatcher.matches()) {
value = sgfMatche... | #vulnerable code
private static boolean parse(String value) {
// Drop anything outside "(;...)"
final Pattern SGF_PATTERN = Pattern.compile("(?s).*?(\\(\\s*;.*\\)).*?");
Matcher sgfMatcher = SGF_PATTERN.matcher(value);
if (sgfMatcher.matches()) {
value = sgfMatcher.g... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void updateWinrate() {
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) {
history.getData().winrate = stats.maxWinrate;
// we won't set playouts here. but ... | #vulnerable code
public void updateWinrate() {
Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats();
if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().playouts) {
history.getData().winrate = stats.maxWinrate;
history.getData().playouts = stats... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void reopen(int size) {
size = (size >= 2) ? size : 19;
if (size != boardSize) {
boardSize = size;
Zobrist.init();
clear();
Lizzie.leelaz.sendCommand("boardsize " + boardSize);
forceRefresh = true;
}
} | #vulnerable code
public void reopen(int size) {
size = (size == 13 || size == 9) ? size : 19;
if (size != boardSize) {
boardSize = size;
initialize();
forceRefresh = true;
}
}
#location 5
#vulnerabil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int height) {
if (width < 0 || height < 0)
return; // we don't have enough space
double lastWR = 50; // winrate the previous move
boolean validLastWinrate = f... | #vulnerable code
private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int height) {
if (width < 0 || height < 0)
return; // we don't have enough space
double lastWR;
if (Lizzie.board.getData().moveNumber == 0)
last... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetPropertyType() throws Exception {
assertThat(TypeUtil.getPropertyType(A.class, "b.i", "1").equals(Integer.class), equalTo(true));
assertThat(TypeUtil.getPropertyType(A.class, "s", "2").equals(String.class), equalTo(true));
... | #vulnerable code
@Test
public void testGetPropertyType() throws Exception {
assertThat(TypeUtil.getPropertyType(A.class, "b.i").equals(Integer.class), equalTo(true));
assertThat(TypeUtil.getPropertyType(A.class, "s").equals(String.class), equalTo(true));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetPropertyType() throws Exception {
assertThat(TypeUtil.getPropertyType(A.class, "b.i", "1").equals(Integer.class), equalTo(true));
assertThat(TypeUtil.getPropertyType(A.class, "s", "2").equals(String.class), equalTo(true));
... | #vulnerable code
@Test
public void testGetPropertyType() throws Exception {
assertThat(TypeUtil.getPropertyType(A.class, "b.i").equals(Integer.class), equalTo(true));
assertThat(TypeUtil.getPropertyType(A.class, "s").equals(String.class), equalTo(true));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void executeDDL(Object test, String[] sqls) {
try {
executeSql(CONNECTION_TABLE.get(test), sqls);
} catch (SQLException e) {
throw new RuntimeException(e);
}
} | #vulnerable code
public static void executeDDL(Object test, String[] sqls) {
Connection connection = CONNECTION_TABLE.get(test);
try {
Statement statement = connection.createStatement();
for (int i = 0; i < sqls.length; i++) {
statement.execute(sqls[i]);
}
connection.co... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected Properties getProperties() {
if (propertyFile!=null) {
Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ?
FileInputStream is = null;
try {
is = new FileInputStream(propertyFile);
properties.load... | #vulnerable code
protected Properties getProperties() {
if (propertyFile!=null) {
Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ?
try {
properties.load(new FileInputStream(propertyFile) );
return properties;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void execute() {
getLog().info("Starting " + this.getClass().getSimpleName() + "...");
RevengStrategy strategy = setupReverseEngineeringStrategy();
if (propertyFile.exists()) {
executeExporter(createJdbcDescriptor(strategy, loadProperti... | #vulnerable code
public void execute() {
getLog().info("Starting " + this.getClass().getSimpleName() + "...");
RevengStrategy strategy = setupReverseEngineeringStrategy();
Properties properties = loadPropertiesFile();
MetadataDescriptor jdbcDescriptor = c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getAllExecutors(String jobName, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) {
String executorsNodePath = SaturnExecutorsNode.getExecutorsNodePath();
if (!curatorFrameworkOp.checkExists(executorsNodePath)) {
return null;
}
StringBu... | #vulnerable code
@Override
public String getAllExecutors(String jobName, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) {
String executorsNodePath = SaturnExecutorsNode.getExecutorsNodePath();
if (!curatorFrameworkOp.checkExists(executorsNodePath)) {
return null;
}
St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void refreshTreeData() {
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluster : zkClusters) {
InitRegistryCenterService.initTreeJson(zkCluster.getRegCenterConfList(), zkCluster.getZkAddr());
}
} | #vulnerable code
private void refreshTreeData() {
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluster : zkClusters) {
InitRegistryCenterService.initTreeJson(REGISTRY_CENTER_CONFIGURATION_MAP.get(zkCluster.getZkAddr(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public RegistryCenterConfiguration findConfigByNamespace(String namespace) {
if(Strings.isNullOrEmpty(namespace)){
return null;
}
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluster: zkClus... | #vulnerable code
@Override
public RegistryCenterConfiguration findConfigByNamespace(String namespace) {
if(Strings.isNullOrEmpty(namespace)){
return null;
}
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluster: ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void zip(List<File> runtimeLibFiles, File saturnContainerDir, File zipFile) throws IOException {
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
/* for(File file : saturnContainerDir.listFiles()) {
zip(file, "saturn", zos);
}*/
... | #vulnerable code
public static void zip(List<File> runtimeLibFiles, File saturnContainerDir, File zipFile) throws IOException {
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
for(File file : saturnContainerDir.listFiles()) {
zip(file, "saturn", zos);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void run() {
while (!halted.get()) {
try {
synchronized (sigLock) {
while (paused && !halted.get()) {
try {
sigLock.wait(1000L);
} catch (InterruptedException ignore) {
}
}
if (halted.get()) {
break;
}... | #vulnerable code
@Override
public void run() {
while (!halted.get()) {
try {
synchronized (sigLock) {
while (paused && !halted.get()) {
try {
sigLock.wait(1000L);
} catch (InterruptedException ignore) {
}
}
if (halted.get()) {
break;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public RegistryCenterConfiguration findConfig(String nameAndNamespace) {
if(Strings.isNullOrEmpty(nameAndNamespace)){
return null;
}
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluster: zkC... | #vulnerable code
@Override
public RegistryCenterConfiguration findConfig(String nameAndNamespace) {
if(Strings.isNullOrEmpty(nameAndNamespace)){
return null;
}
Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values();
for (ZkCluster zkCluste... | 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.