input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Override
public Object readFrom(Class<Object> type, Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
... | #fixed code
@Override
public Object readFrom(Class<Object> type, Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
In... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowB... | #fixed code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowBounds ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowB... | #fixed code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowBounds ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Object intercept(Invocation invocation) throws Throwable {
SqlUtil sqlUtil;
if (autoRuntimeDialect) {
sqlUtil = getSqlUtil(invocation);
} else {
if (autoDialect) {
initSqlUtil(invocation);
... | #fixed code
public Object intercept(Invocation invocation) throws Throwable {
if (autoRuntimeDialect) {
SqlUtil sqlUtil = getSqlUtil(invocation);
return sqlUtil.processPage(invocation);
} else {
if (autoDialect) {
initSq... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowB... | #fixed code
@Override
public Object intercept(Invocation invocation) throws Throwable {
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowBounds ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (S... | #fixed code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (StringU... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (S... | #fixed code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (StringU... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (S... | #fixed code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (StringU... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (S... | #fixed code
@Override
public void setProperties(Properties properties) {
//缓存 count ms
msCountMap = CacheFactory.createCache(properties.getProperty("msCountCache"), "ms", properties);
String dialectClass = properties.getProperty("dialect");
if (StringU... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getUrl(DataSource dataSource){
Connection conn = null;
try {
conn = dataSource.getConnection();
return conn.getMetaData().getURL();
} catch (SQLException e) {
throw new RuntimeException(e);
... | #fixed code
public String getUrl(DataSource dataSource){
Connection conn = null;
try {
conn = dataSource.getConnection();
return conn.getMetaData().getURL();
} catch (SQLException e) {
throw new RuntimeException(e);
} fi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void verifyArchivedNotContainingItself(WorkflowRun run) throws IOException {
assertTrue("Build should have artifacts", run.getHasArtifacts());
Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
VirtualFile file =... | #fixed code
private void verifyArchivedNotContainingItself(WorkflowRun run) throws IOException {
assertTrue("Build should have artifacts", run.getHasArtifacts());
Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
VirtualFile file = run.g... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canArchiveFileWithSameName() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" dir ('src') {\n" +
... | #fixed code
@Test
public void canArchiveFileWithSameName() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" dir ('src') {\n" +
" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String slurp(String fileName) throws IOException {
URL fileUrl = this.getClass().getResource(fileName);
File file = new File(URLDecoder.decode(fileUrl.getFile(), "UTF-8"));
FileReader in = new FileReader(file);
StringBuffer sb = n... | #fixed code
private String slurp(String fileName) throws IOException {
URL fileUrl = this.getClass().getResource(fileName);
File file = new File(URLDecoder.decode(fileUrl.getFile(), "UTF-8"));
BufferedReader in = new BufferedReader(new FileReader(file));
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String slurp(String fileName) throws IOException {
URL fileUrl = this.getClass().getResource(fileName);
File file = new File(URLDecoder.decode(fileUrl.getFile(), "UTF-8"));
FileReader in = new FileReader(file);
StringBuffer sb = n... | #fixed code
private String slurp(String fileName) throws IOException {
URL fileUrl = this.getClass().getResource(fileName);
File file = new File(URLDecoder.decode(fileUrl.getFile(), "UTF-8"));
BufferedReader in = new BufferedReader(new FileReader(file));
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Long getRequestStartTime() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
return (Long) requestAttributes.getAttribute(REQUEST_START_TIME, SCOPE_REQUEST);
}
#location 3
... | #fixed code
private Long getRequestStartTime() {
final RequestContext ctx = RequestContext.getCurrentContext();
final HttpServletRequest request = ctx.getRequest();
return (Long) request.getAttribute(REQUEST_START_TIME);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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(... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
DictionaryBuilder() {
buffer = ByteBuffer.allocate(BUFFER_SIZE);
buffer.order(ByteOrder.LITTLE_ENDIAN);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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]);
... | #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]))... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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]);
... | #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]))... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long bufferedDataAmount() {
return bufferQueueTotalAmount;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 7
... | #fixed code
public void stop() throws IOException {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
thread.interrupt();
this.server.close();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void close() {
if( thread != null ) {
thread.interrupt();
closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}
}
}
#location 3
... | #fixed code
public void close() {
if( thread != null ) {
conn.close( CloseFrame.NORMAL );
/*closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}*/
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() {
if( thread == null )
thread = Thread.currentThread();
interruptableRun();
thread = null;
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public final void onWebsocketClose( WebSocket conn, int code, String reason, boolean remote ) {
oqueue.add( (WebSocketImpl) conn );// because the ostream will close the channel
selector.wakeup();
try {
synchronized ( connections ) {
if( this.connect... | #fixed code
@Override
public final void onWebsocketClose( WebSocket conn, int code, String reason, boolean remote ) {
oqueue.add( (WebSocketImpl) conn );// because the ostream will close the channel
selector.wakeup();
try {
if( removeConnection( conn ) ) {
onClose( conn, code,... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void stop( int timeout ) throws IOException , InterruptedException {
if( !isclosed.compareAndSet( false, true ) ) { // this also makes sure that no further connections will be added to this.connections
return;
}
List<WebSocket> socketsToClose = null;
//... | #fixed code
public void stop( int timeout ) throws InterruptedException {
if( !isclosed.compareAndSet( false, true ) ) { // this also makes sure that no further connections will be added to this.connections
return;
}
List<WebSocket> socketsToClose = null;
// copy the connection... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void close() {
if( thread != null ) {
thread.interrupt();
closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}
}
}
#location 7
... | #fixed code
public void close() {
if( thread != null ) {
conn.close( CloseFrame.NORMAL );
/*closelock.lock();
try {
if( selector != null )
selector.wakeup();
} finally {
closelock.unlock();
}*/
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 );
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public int getConnectionLostTimeout() {
return connectionLostTimeout;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public int getConnectionLostTimeout() {
synchronized (syncConnectionLost) {
return connectionLostTimeout;
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 );
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 ) {... | #fixed code
public void stop() throws IOException , InterruptedException {
stop( 0 );
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void start() {
if( thread != null )
throw new IllegalStateException( "Already started" );
new Thread( this ).start();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void start() {
if( selectorthread != null )
throw new IllegalStateException( "Already started" );
new Thread( this ).start();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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 );
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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( ... | #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" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 );
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 7
... | #fixed code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
selectorthread.interrupt();
this.server.close();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 ) {... | #fixed code
public void stop() throws IOException , InterruptedException {
stop( 0 );
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public final void onWriteDemand( WebSocket conn ) {
selector.wakeup();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void stop() throws IOException {
synchronized ( connections ) {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
}
thread.interrupt();
this.server.close();
}
#location 8
... | #fixed code
public void stop() throws IOException {
for( WebSocket ws : connections ) {
ws.close( CloseFrame.NORMAL );
}
thread.interrupt();
this.server.close();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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 );
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void roundTripWriteAndRead() throws TaskException, IOException {
String str = "ਹਰਜੋਤ ਸਿੰਘ ភាសាខ្មែរ latin ąćęłńóśźż ทดสอบ വീട मानक हिन्दी ് జ উ ☗⦄✸▃ ";
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
new Pa... | #fixed code
@Test
public void roundTripWriteAndRead() throws TaskException, IOException {
List<String> strings = Arrays.asList("ગુજરાતી ਪੰਜਾਬੀ தமிழ்",
"ਹਰਜੋਤ ਸਿੰਘ ភាសាខ្មែរ latin ąćęłńóśźż ทดสอบ വീട मानक हिन्दी ് జ উ ☗⦄✸▃ ");
for(String str: strings) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 ... | #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)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void mergeNull() {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCatalog().getAcroForm());
victim.mergeForm(n... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void testBasics() throws TaskException, IOException {
withSource("pdf/unoptimized.pdf");
victim.execute(parameters);
assertThat(sizeOfResult(), is(lessThan(104L)));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canDisplayGeorgian() {
PDFont font = FontUtils.findFontFor(new PDDocument(), "ქართული ენა");
assertNotNull("No font available for Georgian", font);
assertThat(font.getName(), is("NotoSansGeorgian"));
}
... | #fixed code
@Test
public void canDisplayGeorgian() {
assertNotNull(findFontFor("ქართული ენა"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canDisplayGeorgian() {
PDFont font = FontUtils.findFontFor(new PDDocument(), "ქართული ენა");
assertNotNull("No font available for Georgian", font);
assertThat(font.getName(), is("NotoSansGeorgian"));
}
... | #fixed code
@Test
public void canDisplayGeorgian() {
assertNotNull(findFontFor("ქართული ენა"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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())) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void resolveTextAndFontsWhenTextRepeats() throws TaskIOException {
write("123α456α789");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute(JpegToPdfParameters parameters) throws TaskException {
int currentStep = 0;
documentHandler = new PDDocumentHandler();
documentHandler.setCreatorOnPDDocument();
PageImageWriter imageWriter = new PageIma... | #fixed code
@Override
public void execute(JpegToPdfParameters parameters) throws TaskException {
final MutableInt currentStep = new MutableInt(0);
ImagesToPdfDocumentConverter converter = new ImagesToPdfDocumentConverter() {
@Override
public v... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFindFontFor() {
assertEquals("NotoSansThai", findFontFor(new PDDocument(), "ทดสอบ").getName());
assertEquals("NotoSans", findFontFor(new PDDocument(), "αυτό είναι ένα τεστ").getName());
assertNull(findFontFor(new PDDocum... | #fixed code
@Test
public void testFindFontFor() {
assertNotNull(findFontFor("ทดสอบ")); // thai
assertNotNull(findFontFor("αυτό είναι ένα τεστ")); // greek
assertNotNull(findFontFor("വീട്")); // malayalam
assertNotNull(findFontFor("मानक")); // hindi
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void resolvedSpaceSeparately() throws TaskIOException {
write("ab cd");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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())) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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
... | #fixed code
@Test
public void testCanDisplayThai() {
assertThat(findFontFor("นี่คือการทดสอบ"), is(notNullValue()));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void mergeWithSignatureRemovesSignatureValue() throws IOException {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCat... | #fixed code
@Test
public void mergeWithSignatureRemovesSignatureValue() throws IOException {
PDDocument destination = new PDDocument();
AcroFormsMerger victim = new AcroFormsMerger(AcroFormPolicy.MERGE, destination);
assertNotNull(document.getDocumentCatalog()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFindFontFor() {
assertEquals("NotoSansThai", findFontFor(new PDDocument(), "ทดสอบ").getName());
assertEquals("NotoSans", findFontFor(new PDDocument(), "αυτό είναι ένα τεστ").getName());
assertNull(findFontFor(new PDDocum... | #fixed code
@Test
public void testFindFontFor() {
assertNotNull(findFontFor("ทดสอบ")); // thai
assertNotNull(findFontFor("αυτό είναι ένα τεστ")); // greek
assertNotNull(findFontFor("വീട്")); // malayalam
assertNotNull(findFontFor("मानक")); // hindi
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void before(AlternateMixParameters parameters, TaskExecutionContext executionContext) throws TaskException {
super.before(parameters, executionContext);
mixer = new PdfAlternateMixer(parameters.getFirstInput(), parameters.getSecondIn... | #fixed code
@Override
public void before(AlternateMixParameters parameters, TaskExecutionContext executionContext) throws TaskException {
super.before(parameters, executionContext);
mixer = new PdfAlternateMixer();
outputWriter = OutputWriters.newSingleOutputW... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static ArchiveOutputStream createArchiveOutputStream(CommonsArchiver archiver, File archive) throws IOException,
ArchiveException {
return createArchiveOutputStream(archiver.getFileType(), new FileOutputStream(archive));
}
... | #fixed code
static ArchiveOutputStream createArchiveOutputStream(CommonsArchiver archiver, File archive) throws IOException,
ArchiveException {
return createArchiveOutputStream(archiver.getArchiveFormat(), archive);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination)
throws IOException, CompressorException {
return createCompressorOutputStream(compressor.getFileType(), new FileOutputStream(destination));
... | #fixed code
static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination)
throws IOException, CompressorException {
return createCompressorOutputStream(compressor.getCompressionType(), destination);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<ProjectMailTicketConfig> findAll() {
List<ProjectMailTicketConfig> configs = queries.findAllConfigs();
List<ProjectMailTicket> ticketConfigs = queries.findAllTickets();
Map<Integer, List<ProjectMailTicket>> ticketConfigsByConfigId = ... | #fixed code
public List<ProjectMailTicketConfig> findAll() {
return aggregateByConfig(queries.findAllConfigs(), queries.findAllTickets());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void checkNew() {
List<ProjectMailTicketConfig> entries = mailTicketRepository.findAll();
for(ProjectMailTicketConfig entry: entries) {
MailReceiver receiver = entry.getConfig().getInboundProtocol().startsWith("pop3") ?
... | #fixed code
public void checkNew() {
List<ProjectMailTicketConfig> entries = mailTicketRepository.findAll();
for(ProjectMailTicketConfig entry: entries) {
MailReceiver receiver = entry.getConfig().getInboundProtocol().startsWith("pop3") ?
getP... | Below is the vulnerable code, please generate the patch based on the following information. |
#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) {... | #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 ... | 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.