output stringlengths 79 30.1k | instruction stringclasses 1
value | input stringlengths 216 28.9k |
|---|---|---|
#fixed code
public static void main(String[] args) throws IOException, ParseException {
long curTime = System.nanoTime();
SearchArgs searchArgs = new SearchArgs();
CmdLineParser parser = new CmdLineParser(searchArgs, ParserProperties.defaults().withUsageWidth(90));
try {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void main(String[] args) throws IOException, ParseException {
if (args.length != 3) {
System.err.println("Usage: SearcherCW09B <topicsFile> <submissionFile> <indexDir>");
System.err.println("topicsFile: input file containing queries. One of:... |
#fixed code
private static int spawnPacket(Location loc) throws Exception {
Object world = Reflections.getHandle(loc.getWorld());
Object crystal = enderCrystalConstructor.newInstance(world);
setLocation.invoke(crystal, loc.getX(), loc.getY(), loc.getZ(), 0, 0);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static int spawnPacket(Location loc) throws Exception {
Object world = Reflections.getHandle(loc.getWorld());
Object crystal = enderCrystalClass.getConstructor(Reflections.getCraftClass("World")).newInstance(world);
Reflections.getMethod(... |
#fixed code
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
User user = User.get(player);
if (user == null) {
user = User.create(player);
} else {
if (! user.getName().equals(player.getName(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
User user = User.get(player);
if (user == null) {
user = User.create(player);
}
user.updateReference(player);
PluginCon... |
#fixed code
private void sendMessageToGuild(Guild guild, Player player, String message) {
for (User user : guild.getOnlineMembers()) {
Player p = user.getPlayer();
if(!p.equals(player) || !user.isSpy()) {
p.sendMessage(message)... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void sendMessageToGuild(Guild guild, Player player, String message) {
for (User user : guild.getMembers()) {
Player loopedPlayer = this.plugin.getServer().getPlayer(user.getName());
if (loopedPlayer != null) {
if (... |
#fixed code
private static List<String> getWorldGuardRegionNames(User user) {
if (user == null || user.getPlayer() == null) {
return Collections.emptyList();
}
Location location = user.getPlayer().getLocation();
if (location != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static List<String> getWorldGuardRegionNames(User user) {
Location location = user.getPlayer().getLocation();
if (location != null) {
List<String> regionNames = WorldGuardHook.getRegionNames(location);
if (regionNames !=... |
#fixed code
@Override
public boolean isInNonPointsRegion(Location location) {
ApplicableRegionSet regionSet = getRegionSet(location);
if (regionSet == null) {
return false;
}
for (ProtectedRegion region : regionSet) {
if (regi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public boolean isInNonPointsRegion(Location location) {
if (! isInRegion(location)) {
return false;
}
for (ProtectedRegion region : getRegionSet(location)) {
if (region.getFlag(noPointsFlag) == StateFlag.Sta... |
#fixed code
@Test
public void testBasicPreemptiveAuthHeader() throws Exception
{
final HttpClientBuilder client = HttpClientBuilder.create();
client.addInterceptorFirst(new HttpRequestInterceptor()
{
public void process(final HttpRequest r, final HttpContext context) throws HttpE... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testBasicPreemptiveAuthHeader() throws Exception
{
final DefaultHttpClient client = new DefaultHttpClient();
client.addRequestInterceptor(new HttpRequestInterceptor()
{
public void process(final HttpRequest r, final HttpContext context) throws ... |
#fixed code
@Override
public void run() {
ServerSocket socket = null;
Socket clientSocket = null;
try {
socket = new ServerSocket(this.port);
clientSocket = socket.accept();
final BufferedInputStream bif = new BufferedInputStream(
clientSocket.get... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void run() {
ServerSocket socket = null;
try {
socket = new ServerSocket(this.port);
final Socket clientSocket = socket.accept();
final BufferedInputStream bif = new BufferedInputStream(
clientSocket.getInputStream()... |
#fixed code
private void run(final Class<?> clazz, final Class<?> test,
final MethodMutatorFactory... mutators) {
final ReportOptions data = new ReportOptions();
final Set<Predicate<String>> tests = Collections.singleton(Prelude
.isEqualTo(test.getName()));
data... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void run(final Class<?> clazz, final Class<?> test,
final MethodMutatorFactory... mutators) {
final ReportOptions data = new ReportOptions();
final Set<Predicate<String>> tests = Collections.singleton(Prelude
.isEqualTo(test.getName()));
... |
#fixed code
private String getGeneratedManifestAttribute(final String key)
throws IOException, FileNotFoundException {
final Option<String> actual = this.testee.getJarLocation();
final File f = new File(actual.value());
final JarInputStream jis = new JarInputStream(new Fi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private String getGeneratedManifestAttribute(final String key)
throws IOException, FileNotFoundException {
final Option<String> actual = this.testee.getJarLocation();
final File f = new File(actual.value());
final JarInputStream jis = new JarInputStream(... |
#fixed code
@Test
public void shouldPrintScoresFourToALine() {
final String[] ss = generateReportLines();
assertEquals("> KILLED 0 SURVIVED 0 TIMED_OUT 0 NON_VIABLE 0 ", ss[2]);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void shouldPrintScoresFourToALine() {
final ByteArrayOutputStream s = new ByteArrayOutputStream();
final PrintStream out = new PrintStream(s);
this.testee.report(out);
final String actual = new String(s.toByteArray());
final String[] ss ... |
#fixed code
public void execute() {
List<String> commandLine = getCommandLine();
LOG.info("Executing " + getExecutedTool() + " with command '{}'", prettyPrint(commandLine));
Iterator<String> commandLineIterator = commandLine.iterator();
Command command = Command.create(com... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void execute() {
try {
// Gets the tool command line
List<String> commandLine = getCommandLine();
ProcessBuilder builder = new ProcessBuilder(commandLine);
LOG.info("Executing " + getExecutedTool() + " with command '{}'", prettyPrint(com... |
#fixed code
private void addProfiledResourcesFromSubirectories(KubernetesListBuilder builder, File resourceDir, EnricherManager enricherManager) throws IOException, MojoExecutionException {
File[] profileDirs = resourceDir.listFiles(new FileFilter() {
@Override
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void addProfiledResourcesFromSubirectories(KubernetesListBuilder builder, File resourceDir, EnricherManager enricherManager) throws IOException, MojoExecutionException {
File[] profileDirs = resourceDir.listFiles(new FileFilter() {
@Override
... |
#fixed code
private String getPortForwardUrl(final Set<HasMetadata> resources) throws Exception {
LabelSelector selector = KubernetesResourceUtil.getPodLabelSelector(resources);
if (selector == null) {
log.warn("Unable to determine a selector for application p... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private String getPortForwardUrl(final Set<HasMetadata> resources) throws Exception {
LabelSelector selector = KubernetesResourceUtil.getPodLabelSelector(resources);
if (selector == null) {
log.warn("Unable to determine a selector for applica... |
#fixed code
@Override
public void execute(final JobDetail jobDetail, JobTriggerType triggerType, JobExecutionContext context) {
final String appName = jobDetail.getApp().getAppName();
final String jobClass = jobDetail.getJob().getClazz();
JobInstance instanc... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void execute(final JobDetail jobDetail, JobTriggerType triggerType, JobExecutionContext context) {
final String appName = jobDetail.getApp().getAppName();
final String jobClass = jobDetail.getJob().getClazz();
JobInstance i... |
#fixed code
@Test
public void testTrainAndValidate() {
TestUtils.log(this.getClass(), "testTrainAndValidate");
RandomValue.setRandomGenerator(new Random(TestConfiguration.RANDOM_SEED));
DatabaseConfiguration dbConf = TestUtils.getDBConfig();
D... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testTrainAndValidate() {
TestUtils.log(this.getClass(), "testTrainAndValidate");
RandomValue.setRandomGenerator(new Random(TestConfiguration.RANDOM_SEED));
DatabaseConfiguration dbConf = TestUtils.getDBConfig();
... |
#fixed code
@Override
public ResultSet executeQuery(String sql) throws SQLException {
String csql = clickhousifySql(sql);
CountingInputStream is = getInputStream(csql);
try {
return new CHResultSet(properties.isCompress()
? new ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public ResultSet executeQuery(String sql) throws SQLException {
String csql = clickhousifySql(sql, "TabSeparatedWithNamesAndTypes");
CountingInputStream is = getInputStream(csql);
try {
return new HttpResult(properties.i... |
#fixed code
public void delete() {
commandFactory.createDeleteContainerCommand(getAccount(), getClient(), getAccess(), this).call();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void delete() {
new DeleteContainerCommand(getAccount(), getClient(), getAccess(), this).call();
}
#location 2
#vulnerability type RESOURCE_LEAK |
#fixed code
public StoredObject setContentType(String contentType) {
checkForInfo();
info.setContentType(new ObjectContentType(contentType));
commandFactory.createObjectMetadataCommand(
getAccount(), getClient(), getAccess(), this,
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public StoredObject setContentType(String contentType) {
checkForInfo();
info.setContentType(new ObjectContentType(contentType));
new ObjectMetadataCommand(
getAccount(), getClient(), getAccess(), this,
info.getHea... |
#fixed code
protected void getInfo() {
this.info = new ObjectInformationCommand(getAccount(), getClient(), getAccess(), getContainer(), this).call();
this.setInfoRetrieved();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void getInfo() {
ObjectInformation info = new ObjectInformationCommand(getAccount(), getClient(), getAccess(), getContainer(), this).call();
this.lastModified = info.getLastModified();
this.etag = info.getEtag();
this.contentLen... |
#fixed code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 = new F... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 =... |
#fixed code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new FileInputS... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new File... |
#fixed code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new File... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(ne... |
#fixed code
public static byte[] toUnixLineEndings(InputStream input) throws IOException {
String encoding = "ISO-8859-1";
FixCrLfFilter filter = new FixCrLfFilter(new InputStreamReader(input, encoding));
filter.setEol(FixCrLfFilter.CrLf.newInstance("unix"));
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static byte[] toUnixLineEndings(InputStream input) throws IOException {
final Charset UTF8 = Charset.forName("UTF-8");
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final ByteArrayOutputStream dataStream ... |
#fixed code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput, "UTF-8"));
StringBuilder buffer = new StringBuilder();
String key = null;
int linen... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput));
StringBuilder buffer = new StringBuilder();
String key = null;
int linenr =... |
#fixed code
private void unpackDependencies() throws MojoExecutionException {
ExecutionEnvironment executionEnvironment = executionEnvironment(mavenProject, mavenSession, buildPluginManager);
// try {
executeMojo(
plugin(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void unpackDependencies() throws MojoExecutionException {
try {
// get plugin JAR
String pluginJarPath = getPluginJarPath();
JarFile pluginJar = new JarFile(new File(pluginJarPath));
// extract loader JAR ... |
#fixed code
@Override
public HttpSession getSession(final boolean create) {
return servletContext.getSession(exchange.getExchange(), create);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public HttpSession getSession(final boolean create) {
if (httpSession == null) {
Session session = exchange.getExchange().getAttachment(Session.ATTACHMENT_KEY);
if (session != null) {
httpSession = new HttpSe... |
#fixed code
public static void main(String[] args) throws Exception {
TokenManager tokenManager = new TokenManager(new ConcurrentHashMap<>(), null, null, "");
String email = "dmitriy@blynk.cc";
String pass = "b";
String appName = AppName.BLYNK;
Use... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void main(String[] args) throws Exception {
TokenManager tokenManager = new TokenManager(new ConcurrentHashMap<>(), null, null, "");
String email = "dmitriy@blynk.cc";
String pass = "b";
String appName = AppName.BLYNK;
... |
#fixed code
private void sendPushNotification(DashBoard dashBoard, Notification notification, int dashId, int deviceId) {
Device device = dashBoard.getDeviceById(deviceId);
final String dashName = dashBoard.name == null ? "" : dashBoard.name;
final String deviceNa... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void sendPushNotification(DashBoard dashBoard, Notification notification, int dashId, int deviceId) {
Device device = dashBoard.getDeviceById(deviceId);
final String dashName = dashBoard.name == null ? "" : dashBoard.name;
final String de... |
#fixed code
@Test
@Ignore
public void testGetTestString() {
RedisClient redisClient = new RedisClient("localhost", "123", 6378, false);
String result = redisClient.getServerByToken("test");
assertEquals("It's working!", result);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
@Ignore
public void testGetTestString() {
RealRedisClient redisClient = new RealRedisClient("localhost", "123", 6378);
String result = redisClient.getServerByToken("test");
assertEquals("It's working!", result);
}
... |
#fixed code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
ret... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
... |
#fixed code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-server")
.register("ping", new PingRequestHandler())
.setServerPort(this.port)
.build();
tchannel.listen().channel().closeFutur... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-server")
.register("ping", new PingRequestHandler())
.setPort(this.port)
.build();
tchannel.listen().channel().closeFutur... |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long missCount()
{
return missCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
table = Table.create(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long putReplaceCount()
{
return putReplaceCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
int hashTableSize()
{
return table.size();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
table = Table.create(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
}
#location 3
... |
#fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long putReplaceCount()
{
return putReplaceCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long rehashes()
{
return rehashes;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... |
#fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
boolean putEntry(long newHashEntryAdr, long hash, long keyLen, long bytes, boolean ifAbsent, long oldValueAddr, long oldValueOffset, long oldValueLen)
{
long removeHashEntryAdr = 0L;
LongArrayList derefList = null;
lock.lock();
try
... |
#fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... |
#fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long rehashes()
{
return rehashes;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
@Test
public void vanilla() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
TestConfiguration.class);
Service service = context.getBean(Service.class);
Foo foo = context.getBean(Foo.class);
assertFalse(AopUtils.isAopProxy(foo))... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void vanilla() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
TestConfiguration.class);
Service service = context.getBean(Service.class);
service.service();
assertEquals(3, service.getCount());
context.clo... |
#fixed code
private void downloadLoeschen(boolean dauerhaft) {
int rows[] = tabelle.getSelectedRows();
if (rows.length > 0) {
String[] urls = new String[rows.length];
for (int i = 0; i < rows.length; ++i) {
urls[i] = tabelle.getMode... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void downloadLoeschen(boolean dauerhaft) {
int rows[] = tabelle.getSelectedRows();
if (rows.length > 0) {
for (int i = rows.length - 1; i >= 0; --i) {
int delRow = tabelle.convertRowIndexToModel(rows[i]);
... |
#fixed code
public static String getMusterPfadVlc() {
final String PFAD_LINUX_VLC = "/usr/bin/vlc";
final String PFAD_MAC_VLC = "/Applications/VLC.app/Contents/MacOS/VLC";
final String PFAD_WIN_DEFAULT = "C:\\Programme\\VideoLAN\\VLC\\vlc.exe";
final Strin... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static String getMusterPfadVlc() {
final String PFAD_LINUX_VLC = "/usr/bin/vlc";
final String PFAD_MAC_VLC = "/Applications/VLC.app/Contents/MacOS/VLC";
String pfad = "";
if (System.getProperty("os.name").toLowerCase().contains("wi... |
#fixed code
private synchronized StringBuffer getUri(String sender, String addr, StringBuffer seite, String kodierung, int timeout, String meldung, int versuch, boolean lVersuch) {
int timeo = timeout;
boolean proxyB = false;
char[] zeichen = new char[1];
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private synchronized StringBuffer getUri(String sender, String addr, StringBuffer seite, String kodierung, int timeout, String meldung, int versuch, boolean lVersuch) {
int timeo = timeout;
boolean proxyB = false;
char[] zeichen = new char[1];
... |
#fixed code
public static boolean isLeopard() {
return SystemInfo.isMacOSX() && SystemInfo.getOSVersion().startsWith("10.5");
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static boolean isLeopard() {
return isMac() && getOsVersion().startsWith("10.5");
}
#location 2
#vulnerability type NULL_DEREFERENCE |
#fixed code
void addToListNormal() {
//<strong style="margin-left:10px;">Sesamstraße präsentiert: Eine Möhre für Zwei</strong><br />
//<a style="margin-left:20px;" href="?programm=168&id=14487&ag=5" title="Sendung vom 10.10.2012" class="overlay_link">42. Ordnung i... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void addToListHttp() {
//http://www.kikaplus.net/clients/kika/kikaplus/hbbtv/index.php?cmd=az&age=3&page=all
//http://www.kikaplus.net/clients/kika/kikaplus/hbbtv/index.php?cmd=az&age=6&page=all
//http://www.kikaplus.net/clients/kika/kikaplus/hbb... |
#fixed code
void addToListNormal() {
//<strong style="margin-left:10px;">Sesamstraße präsentiert: Eine Möhre für Zwei</strong><br />
//<a style="margin-left:20px;" href="?programm=168&id=14487&ag=5" title="Sendung vom 10.10.2012" class="overlay_link">42. Ordnung i... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void ladenHttp(String filmWebsite, String thema, String alter) {
// erst die Nummer suchen
// >25420<4<165<23. Die b
// <http://www.kikaplus.net/clients/kika/mediathek/previewpic/1355302530-f80b463888fd4602d925b2ef2c861928 9.jpg<
final St... |
#fixed code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
String swarmNodeIp = null;
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
ContainerStatus contain... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
String swarmNodeIp = null;
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.status()... |
#fixed code
@Test
public void pollerThreadTearsDownNodeAfterTestIsCompleted() throws IOException {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start poller thread... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void pollerThreadTearsDownNodeAfterTestIsCompleted() throws IOException {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start poller ... |
#fixed code
private ContainerCreationStatus getContainerCreationStatus (String serviceId, String nodePort) throws DockerException, InterruptedException {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.serviceId().equals(service... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private ContainerCreationStatus getContainerCreationStatus (String serviceId, String nodePort) throws DockerException, InterruptedException {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.serviceId().equals(s... |
#fixed code
public <T> Future<List<T>> fetchAsync(final JsonObject criteria, final String pojo) {
return JqFlow.create(this.analyzer, pojo).inputQrJAsync(criteria).compose(this.reader::fetchAsync);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public <T> Future<List<T>> fetchAsync(final JsonObject criteria, final String pojo) {
return this.reader.fetchAsync(criteria, JqFlow.create(this.analyzer, pojo));
}
#location 2
#vulnerability type NUL... |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
#locat... |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
... |
#fixed code
public static void delete(String key) throws IOException {
delete(propertyFile, key);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void delete(String key) throws IOException {
Properties props = getProperty();
OutputStream fos = new FileOutputStream(propertyFile);
props.remove(key);
props.store(fos, "Delete '" + key + "' value");
}
#location 6
... |
#fixed code
public static List<String> callCommand(String command, String[] environ) {
List<String> lines = new LinkedList<String>();
PythonPlugin.LOG.debug("Calling command: '{}'", command);
BufferedReader stdInput = null;
Process process = null;
try {
if(envir... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static List<String> callCommand(String command, String[] environ) {
List<String> lines = new LinkedList<String>();
PythonPlugin.LOG.debug("Calling command: '{}'", command);
BufferedReader stdInput = null;
try {
Process p = null;
if(env... |
#fixed code
@Test
public void definition_callee_symbol() {
FileInput tree = parse(
"def fn(): pass",
"fn('foo')"
);
assertNameAndQualifiedName(tree, "fn", null);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void definition_callee_symbol() {
FileInput tree = parse(
"def fn(): pass",
"fn('foo')"
);
// TODO: create a symbol for function declaration
CallExpression callExpression = getCallExpression(tree);
assertThat(callExpression.c... |
#fixed code
@RequestMapping("/file/downloadFile")
@ResponseBody
public void downloadFile(String path, String name, HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.setCon... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@RequestMapping("/file/downloadFile")
@ResponseBody
public void downloadFile(String path, String name, HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.... |
#fixed code
private static void writeSymJson(@NotNull Binding binding, JsonGenerator json) throws IOException {
if (binding.start < 0) {
return;
}
String name = binding.node.name;
boolean isExported = !(
Binding.Kind.VARIABLE =... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static void writeSymJson(@NotNull Binding binding, JsonGenerator json) throws IOException {
if (binding.start < 0) {
return;
}
String name = binding.node.name;
boolean isExported = !(
Binding.Kind.VARI... |
#fixed code
private void createStreams(final String host) throws Exception {
appServerPort = randomFreeLocalPort();
streams = KafkaMusicExample.createChartsStreams(CLUSTER.bootstrapServers(),
CLUSTER.schemaRegistryUrl(),
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void createStreams(final String host) throws Exception {
appServerPort = randomFreeLocalPort();
streams = KafkaMusicExample.createChartsStreams(CLUSTER.bootstrapServers(),
CLUSTER.schemaRegistryUrl(),
... |
#fixed code
@Test
public void testShutdown2() throws SQLException
{
Assert.assertSame("StubConnection count not as expected", 0, StubConnection.count.get());
StubConnection.slowCreate = true;
HikariConfig config = new HikariConfig();
config.setMi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testShutdown2() throws SQLException
{
Assert.assertSame("StubConnection count not as expected", 0, StubConnection.count.get());
StubConnection.slowCreate = true;
HikariConfig config = new HikariConfig();
config... |
#fixed code
private long runAndMeasure(Measurable[] runners, CountDownLatch latch, String timeUnit)
{
for (int i = 0; i < runners.length; i++)
{
Thread t = new Thread(runners[i]);
t.start();
}
try
{
latch.aw... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private long runAndMeasure(Measurable[] runners, CountDownLatch latch, String timeUnit)
{
for (int i = 0; i < runners.length; i++)
{
Thread t = new Thread(runners[i]);
t.start();
}
try
{
la... |
#fixed code
@Test
public void testShutdown3() throws SQLException
{
Assert.assertSame("StubConnection count not as expected", 0, StubConnection.count.get());
StubConnection.slowCreate = true;
HikariConfig config = new HikariConfig();
config.setMi... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testShutdown3() throws SQLException
{
Assert.assertSame("StubConnection count not as expected", 0, StubConnection.count.get());
StubConnection.slowCreate = true;
HikariConfig config = new HikariConfig();
config... |
#fixed code
@Test
public void testConnectionIdleFill() throws Exception
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(5);
config.setMaximumPoolSize(10);
config.setConnectionTimeout(1000);
config.setConnectionTestQuery("V... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testConnectionIdleFill() throws Exception
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(5);
config.setMaximumPoolSize(10);
config.setConnectionTimeout(1000);
config.setConnectionTestQu... |
#fixed code
@Override
public void startCrackedSession(ProtocolLibLoginSource source, StoredProfile profile, String username) {
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
plugin.putSession(player.getAddress(), loginSession);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void startCrackedSession(ProtocolLibLoginSource source, StoredProfile profile, String username) {
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
plugin.getLoginSessions().put(player.getAddress().toString... |
#fixed code
protected static String rootPath() {
String path = OS.getTarget();
String sep = System.getProperty("file.separator");
if (!path.endsWith(sep)) {
path += sep;
}
return path + "chronicle-jul" + Time.uniqueId();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected static String rootPath() {
String path = System.getProperty("java.io.tmpdir");
String sep = System.getProperty("file.separator");
if (!path.endsWith(sep)) {
path += sep;
}
return path + "chronicle-jul";
... |
#fixed code
static String rootPath() {
String path = OS.getTarget();
String sep = System.getProperty("file.separator");
if (!path.endsWith(sep)) {
path += sep;
}
return path + "chronicle-log4j1" + Time.uniqueId();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
static String rootPath() {
String path = System.getProperty("java.io.tmpdir");
String sep = System.getProperty("file.separator");
if (!path.endsWith(sep)) {
path += sep;
}
return path + "chronicle-log4j1";
}
... |
#fixed code
protected void checkProviderInfo(ProviderGroup providerGroup) {
List<ProviderInfo> providerInfos = providerGroup == null ? null : providerGroup.getProviderInfos();
if (CommonUtils.isEmpty(providerInfos)) {
return;
}
Iterator<Provide... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void checkProviderInfo(ProviderGroup providerGroup) {
List<ProviderInfo> providerInfos = providerGroup == null ? null : providerGroup.getProviderInfos();
if (CommonUtils.isEmpty(providerInfos)) {
return;
}
Iterator<P... |
#fixed code
@Override
public void updateProviders(ProviderGroup providerGroup) {
checkProviderInfo(providerGroup);
ProviderGroup oldProviderGroup = addressHolder.getProviderGroup(providerGroup.getName());
if (ProviderHelper.isEmpty(providerGroup)) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void updateProviders(ProviderGroup providerGroup) {
checkProviderInfo(providerGroup);
ProviderGroup oldProviderGroup = addressHolder.getProviderGroup(providerGroup.getName());
if (ProviderHelper.isEmpty(providerGroup)) {
... |
#fixed code
private void populateMarkovMatrix(String markovMatrixStorageLocation) {
File file = new File(markovMatrixStorageLocation);
FileInputStream fileInputStream = null;
BufferedInputStream bufferedInputStream = null;
BufferedReader bufferedReader = ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void populateMarkovMatrix(String markovMatrixStorageLocation) {
File file = new File(markovMatrixStorageLocation);
FileInputStream fileInputStream = null;
BufferedInputStream bufferedInputStream = null;
BufferedReader bufferedRea... |
#fixed code
@Override
public void process(ComplexEventChunk complexEventChunk) {
if (trigger) {
ComplexEventChunk<StateEvent> returnEventChunk = new ComplexEventChunk<StateEvent>(true);
StateEvent joinStateEvent = new StateEvent(2, 0);
Stre... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void process(ComplexEventChunk complexEventChunk) {
if (trigger) {
ComplexEventChunk<StateEvent> returnEventChunk = new ComplexEventChunk<StateEvent>(true);
StateEvent joinStateEvent = new StateEvent(2, 0);
... |
#fixed code
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) {
while (streamEventChunk.hasNext()) {
StreamEvent streamEvent = streamEventChunk.next();
Stream... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) {
while (streamEventChunk.hasNext()) {
StreamEvent streamEvent = streamEventChunk.next();
... |
#fixed code
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor,
StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
ComplexEventChunk<StreamEvent> complexEventChu... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor,
StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
ComplexEventChunk<StreamEvent> complexEv... |
#fixed code
@Override
public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
BearerTokenAuthenticator bearer = createBearerTokenAuthenticator();
AuthenticationMechanismOutcome outcome = bearer.authenticate(ex... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
BearerTokenAuthenticator bearer = createBearerTokenAuthenticator();
AuthenticationMechanismOutcome outcome = bearer.authentic... |
#fixed code
protected void start() {
if (started) {
throw new IllegalStateException("Filter already started. Make sure to specify just keycloakConfigResolver or keycloakConfigFile but not both");
}
if (keycloakConfigResolverClass != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void start() {
if (started) {
throw new IllegalStateException("Filter already started. Make sure to specify just keycloakConfigResolver or keycloakConfigFile but not both");
}
if (keycloakConfigResolverClass != null) {
... |
#fixed code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getSessionInternal().getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecurityCon... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getSessionInternal().getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecur... |
#fixed code
private byte[] unHashBlockStream(SafeInputStream decryptedStream) throws IOException {
HashedBlockInputStream hashedBlockInputStream = new HashedBlockInputStream(decryptedStream);
return StreamUtils.toByteArray(hashedBlockInputStream);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private byte[] unHashBlockStream(SafeInputStream decryptedStream) throws IOException {
HashedBlockInputStream hashedBlockInputStream = new HashedBlockInputStream(decryptedStream);
byte[] hashedBlockBytes = StreamUtils.toByteArray(hashedBlockInputStream);
return hashe... |
#fixed code
public void checkVersionSupport(byte[] keepassFile) throws IOException {
BufferedInputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(keepassFile));
byte[] signature = new byte[VERSION_SIGNATURE_LENGTH];
int readBytes = inputStream.read(signature);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void checkVersionSupport(byte[] keepassFile) throws IOException {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new ByteArrayInputStream(keepassFile));
byte[] signature = new byte[VERSION_SIGNATURE_LENGTH];
bufferedInputStream.read(signatu... |
#fixed code
@Test
public void testCountAllWithPredicate()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders WHERE orderstatus = 'F'", FIXED_INT_64);
TupleStream orderStatus = createTupleStream(ordersData, Column.ORDER_ORDERSTATUS, VARIABLE_BIN... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testCountAllWithPredicate()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders WHERE orderstatus = 'F'", FIXED_INT_64);
TupleStream orderStatus = createBlockStream(ordersData, Column.ORDER_ORDERSTATUS, VARIAB... |
#fixed code
public ZooKeeper getClient(){
if (zooKeeper==null) {
try {
if (INSTANCE_INIT_LOCK.tryLock(2, TimeUnit.SECONDS)) {
if (zooKeeper==null) { // 二次校验,防止并发创建client
// init new-client
ZooKeeper newZk = null;
try {
newZk = new ZooKeeper(zkaddress... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public ZooKeeper getClient(){
if (zooKeeper==null) {
try {
if (INSTANCE_INIT_LOCK.tryLock(2, TimeUnit.SECONDS)) {
if (zooKeeper==null) { // 二次校验,防止并发创建client
try {
zooKeeper = new ZooKeeper(zkaddress, 10000, watcher); // TODO,本地变量方式,成功才会赋值
... |
#fixed code
private static String getAddress() {
if (LOCAL_ADDRESS != null) {
return LOCAL_ADDRESS;
}
InetAddress localAddress = getFirstValidAddress();
LOCAL_ADDRESS = localAddress != null ? localAddress.getHostAddress() : null;
return... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static String getAddress() {
if (LOCAL_ADDRESS != null) {
return LOCAL_ADDRESS;
}
InetAddress localAddress = getFirstValidAddress();
LOCAL_ADDRESS = localAddress.getHostAddress();
return LOCAL_ADDRESS;
}
... |
#fixed code
@Override
public void start() {
createKafkaConsumer();
//按主题数创建ConsumerWorker线程
for (int i = 0; i < topicHandlers.size(); i++) {
ConsumerWorker consumer = new ConsumerWorker();
consumerWorks.add(consumer);
fetcheExecutor.submit(consumer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void start() {
for (int i = 0; i < topicHandlers.size(); i++) {
ConsumerWorker<String, DefaultMessage> consumer = new ConsumerWorker<>(configs, topicHandlers,processExecutor);
consumers.add(consumer);
fetcheExecutor.submit(consumer);
}
}
... |
#fixed code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(readOnly) ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(read... |
#fixed code
@Test
public void shouldParseDataInRowResponseCorrectly() {
try (Response<DefaultRestModel> rsp = new TestRestHttpResponse((rowResultsAndNoErrors()))) {
DefaultRestModel restModel = rsp.next();
assertNotNull(restModel);
Map<Str... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void shouldParseDataInRowResponseCorrectly() {
try (Response<DefaultRestModel> rsp = new TestRestHttpResponse((rowResultsAndNoErrors()))) {
DefaultRestModel restModel = rsp.next();
assertNotNull(restModel);
O... |
#fixed code
@Override
public RelationalReader getIterableReader(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(!iterableReaderCache.containsKey(classInfo)) {
iterableReaderCache.put(classInfo, new HashMap<D... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public RelationalReader getIterableReader(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(iterableReaderCache.get(classInfo) == null) {
iterableReaderCache.put(classInfo, new Hash... |
#fixed code
@Override
public <T> Collection<T> loadAll(Class<T> type, Collection<Long> ids, SortOrder sortOrder, Pagination pagination, int depth) {
Transaction tx = session.ensureTransaction();
String entityType = session.entityType(type.getName());
QuerySt... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public <T> Collection<T> loadAll(Class<T> type, Collection<Long> ids, SortOrder sortOrder, Pagination pagination, int depth) {
String url = session.ensureTransaction().url();
String entityType = session.entityType(type.getName());
... |
#fixed code
public FieldInfo propertyField(String propertyName) {
if (propertyFields == null) {
initPropertyFields();
}
return propertyFields.get(propertyName.toLowerCase());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public FieldInfo propertyField(String propertyName) {
if (propertyFields == null) {
if (propertyFields == null) {
Collection<FieldInfo> fieldInfos = propertyFields();
propertyFields = new HashMap<>(fieldInfos.size());... |
#fixed code
private Object createRelationshipEntity(Edge edge, Object startEntity, Object endEntity) {
// create and hydrate the new RE
Object relationshipEntity = entityFactory.newObject(getRelationshipEntity(edge));
setIdentity(relationshipEntity, edge.getId());
// REs also have... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private Object createRelationshipEntity(Edge edge, Object startEntity, Object endEntity) {
// create and hydrate the new RE
Object relationshipEntity = entityFactory.newObject(getRelationshipEntity(edge));
setIdentity(relationshipEntity, edge.getId());
// REs als... |
#fixed code
public void setPlatform(String platform) throws FileNotFoundException, IOException {
if(!platformPattern.matcher(platform).matches())
throw new IllegalArgumentException("Platform must match " + platformPattern.pattern());
this.platform = platform;... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void setPlatform(String platform) throws FileNotFoundException, IOException {
if(!platformPattern.matcher(platform).matches())
throw new IllegalArgumentException("Platform must match " + platformPattern.pattern());
File tempFile = new... |
#fixed code
@Override
@JsonIgnore
public Set<Aggregation> getAggregations() {
return getInnerQueryUnchecked().getAggregations();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
@JsonIgnore
public Set<Aggregation> getAggregations() {
return getInnerQuery().getAggregations();
}
#location 4
#vulnerability type NULL_DEREFERENCE |
#fixed code
@Override
public void refreshIndex(Map<String, Pair<DimensionRow, DimensionRow>> changedRows) {
// Make a single Document instance to hold field data being updated to Lucene
// Creating documents is costly and so Document will be reused for each record bei... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void refreshIndex(Map<String, Pair<DimensionRow, DimensionRow>> changedRows) {
// Make a single Document instance to hold field data being updated to Lucene
// Creating documents is costly and so Document will be reused for each reco... |
#fixed code
@Override
@JsonIgnore
public Granularity getGranularity() {
return getInnerQueryUnchecked().getGranularity();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
@JsonIgnore
public Granularity getGranularity() {
return getInnerQuery().getGranularity();
}
#location 4
#vulnerability type NULL_DEREFERENCE |
#fixed code
public void run() {
if (shutdown) {
return;
}
try {
initialize();
LOG.info("Initialization complete. Starting worker loop.");
} catch (RuntimeException e1) {
LOG.error("Unable to initialize after... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void run() {
if (shutdown) {
return;
}
try {
initialize();
LOG.info("Initialization complete. Starting worker loop.");
} catch (RuntimeException e1) {
LOG.error("Unable to initialize... |
#fixed code
@Override
public void start(ExtendedSequenceNumber extendedSequenceNumber, InitialPositionInStreamExtended initialPositionInStreamExtended) {
if (executorService.isShutdown()) {
throw new IllegalStateException("ExecutorService has been shutdown.");
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void start(ExtendedSequenceNumber extendedSequenceNumber, InitialPositionInStreamExtended initialPositionInStreamExtended) {
if (executorService.isShutdown()) {
throw new IllegalStateException("ExecutorService has been shutdown."... |
#fixed code
@Test
public void test() throws Exception {
for (int i = 0; i < 5; i++) {
SpecCaptcha specCaptcha = new SpecCaptcha();
//specCaptcha.setCharType(Captcha.TYPE_ONLY_NUMBER);
System.out.println(specCaptcha.text());
//sp... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void test() throws Exception {
for (int i = 0; i < 5; i++) {
SpecCaptcha specCaptcha = new SpecCaptcha();
//specCaptcha.setCharType(Captcha.TYPE_ONLY_NUMBER);
System.out.println(specCaptcha.text());
... |
#fixed code
Module(final ConcreteModuleSpec spec, final ModuleLoader moduleLoader, final Object myKey) {
this.moduleLoader = moduleLoader;
this.myKey = myKey;
// Initialize state from the spec.
identifier = spec.getModuleIdentifier();
mainClassNam... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
Map<String, List<LocalLoader>> getPathsUnchecked(final boolean export) {
try {
return getPaths(export);
} catch (ModuleLoadException e) {
throw e.toError();
}
}
#location 3
... |
#fixed code
public static IterableResourceLoader createIterableFileResourceLoader(final String name, final File root) {
return createFileResourceLoader(name, root);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static IterableResourceLoader createIterableFileResourceLoader(final String name, final File root) {
return new FileResourceLoader(name, root, AccessController.getContext());
}
#location 2
#vul... |
#fixed code
Module(final ConcreteModuleSpec spec, final ModuleLoader moduleLoader) {
this.moduleLoader = moduleLoader;
// Initialize state from the spec.
identifier = spec.getModuleIdentifier();
mainClassName = spec.getMainClass();
fallbackLoader ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
long addExportedPaths(Dependency[] dependencies, Map<String, List<LocalLoader>> map, FastCopyHashSet<PathFilter> filterStack, FastCopyHashSet<ClassFilter> classFilterStack, final FastCopyHashSet<PathFilter> resourceFilterStack, Set<Visited> visited) throws ModuleLoadExc... |
#fixed code
public static ResourceLoader createMavenArtifactLoader(final MavenResolver mavenResolver, final String name) throws IOException {
File fp = mavenResolver.resolveJarArtifact(ArtifactCoordinates.fromString(name));
if (fp == null) return null;
JarFile jar... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static ResourceLoader createMavenArtifactLoader(final MavenResolver mavenResolver, final String name) throws IOException {
File fp = mavenResolver.resolveJarArtifact(ArtifactCoordinates.fromString(name));
if (fp == null) return null;
JarFi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.