input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Override public long countEntitiesOfType(Class<?> entity) { ClassInfo classInfo = session.metaData().classInfo(entity.getName()); if (classInfo == null) { return 0; } RowModelQuery countStatement = new AggregateStatement...
#fixed code @Override public long countEntitiesOfType(Class<?> entity) { ClassInfo classInfo = session.metaData().classInfo(entity.getName()); if (classInfo == null) { return 0; } RowModelQuery countStatement = new AggregateStatements().co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void close() { if (graphDatabaseService != null) { graphDatabaseService.shutdown(); } } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public void close() { if (graphDatabaseService != null) { logger.debug(" *** Now shutting down embedded database instance: " + this); graphDatabaseService.shutdown(); // graphDatabaseService = null; ...
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)); EntityUtils.setIdentity(relationshipEnt...
#fixed code private Object createRelationshipEntity(Edge edge, Object startEntity, Object endEntity) { ClassInfo relationClassInfo = getRelationshipEntity(edge); if (relationClassInfo == null) { throw new MappingException("Could not find a class to map for re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void mapOneToMany(Object instance, Class<?> valueType, Object values, String relationshipType, String relationshipDirection) { ClassInfo classInfo = metadata.classInfo(instance); RelationalWriter writer = entityAccessStrategy.getIterableWriter(classInfo, valu...
#fixed code private void mapOneToMany(Object instance, Class<?> valueType, Object values, String relationshipType, String relationshipDirection) { ClassInfo classInfo = metadata.classInfo(instance); RelationalWriter writer = EntityAccessManager.getIterableWriter(classInfo, valueType, ...
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 @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 @Before public void setUp() throws Exception { new File("target/test-classes/META-INF/services/").mkdirs(); FileWriter out = new FileWriter(PLUGIN_LIFECYCLE); out.write(TestOgmPluginLifecycle.class.getName()); out.close(); } ...
#fixed code @Before public void setUp() throws Exception { TestOgmPluginLifecycle.shouldInitialize = true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void hydrateCourses(Collection<Teacher> teachers) { session.setDriver(new TeacherRequest()); session.setDriver(new CoursesRequest()); session.loadAll(Course.class); } #location 4 ...
#fixed code private void hydrateCourses(Collection<Teacher> teachers) { session.loadAll(Course.class); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public <T> void deleteAll(Class<T> type) { ClassInfo classInfo = session.metaData().classInfo(type.getName()); if (classInfo != null) { String url = session.ensureTransaction().url(); ParameterisedStatement request =...
#fixed code @Override public <T> void deleteAll(Class<T> type) { ClassInfo classInfo = session.metaData().classInfo(type.getName()); if (classInfo != null) { Transaction tx = session.ensureTransaction(); ParameterisedStatement request = getDel...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public <T> Iterable<T> map(Class<T> type, Response<RestModel> response) { //TODO refactor to decouple from the REST response format RestStatisticsModel restStatisticsModel = new RestStatisticsModel(); RestModel model; Collection<Map<String, Object>> resu...
#fixed code @Override public <T> Iterable<T> map(Class<T> type, Response<RestModel> response) { RestStatisticsModel restStatisticsModel = new RestStatisticsModel(); RestModel model = response.next(); Collection<Map<String, Object>> result = new ArrayList<>(); Map<Long, String> rela...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String newTransactionUrl() { String url = transactionEndpoint(driverConfig.getURI()); LOGGER.debug( "Thread {}: POST {}", Thread.currentThread().getId(), url ); try (CloseableHttpResponse response = executeHttpRequest(new HttpPost(url))...
#fixed code private String newTransactionUrl() { String url = transactionEndpoint(driverConfig.getURI()); LOGGER.debug( "Thread: {}, POST {}", Thread.currentThread().getId(), url ); HttpPost request = new HttpPost(url); try (CloseableHttpResponse respon...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private RelationshipBuilder getRelationshipBuilder(Compiler cypherBuilder, Object entity, DirectedRelationship directedRelationship, boolean mapBothDirections) { RelationshipBuilder relationshipBuilder; if (isRelationshipEntity(entity)) { L...
#fixed code private RelationshipBuilder getRelationshipBuilder(Compiler cypherBuilder, Object entity, DirectedRelationship directedRelationship, boolean mapBothDirections) { RelationshipBuilder relationshipBuilder; if (isRelationshipEntity(entity)) { Long re...
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)); EntityUtils.setIdentity(relationshipEnt...
#fixed code private Object createRelationshipEntity(Edge edge, Object startEntity, Object endEntity) { ClassInfo relationClassInfo = getRelationshipEntity(edge); if (relationClassInfo == null) { throw new MappingException("Could not find a class to map for re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private <T> Iterable<T> executeAndMap(Class<T> type, String cypher, Map<String, ?> parameters, RowModelMapper<T> rowModelMapper) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); ...
#fixed code private <T> Iterable<T> executeAndMap(Class<T> type, String cypher, Map<String, ?> parameters, RowModelMapper<T> rowModelMapper) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public QueryStatistics execute(String statement) { if (StringUtils.isEmpty(statement)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } assertNothingReturned(statement); Row...
#fixed code @Override public QueryStatistics execute(String statement) { if (StringUtils.isEmpty(statement)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } assertNothingReturned(statement); RowModelQ...
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 @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 private void mapOneToMany(Collection<Edge> oneToManyRelationships) { EntityCollector entityCollector = new EntityCollector(); List<MappedRelationship> relationshipsToRegister = new ArrayList<>(); Set<Edge> registeredEdges = new HashSet<>(); ...
#fixed code private void mapOneToMany(Collection<Edge> oneToManyRelationships) { EntityCollector entityCollector = new EntityCollector(); List<MappedRelationship> relationshipsToRegister = new ArrayList<>(); // first, build the full set of related entities of ea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRelatedObjectChangeDoesNotAffectNodeMemoisation() { ClassInfo classInfo = metaData.classInfo(Teacher.class.getName()); Teacher teacher = new Teacher("Miss White"); objectMemo.remember(teacher, classInfo); teac...
#fixed code @Test public void testRelatedObjectChangeDoesNotAffectNodeMemoisation() { Teacher teacher = new Teacher("Miss White"); teacher.setId(115L); // the id field must not be part of the memoised property list mappingContext.remember(teacher); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public RelationalReader getRelationalReader(ClassInfo classInfo, String relationshipType, String relationshipDirection) { if(relationalReaderCache.get(classInfo) == null) { relationalReaderCache.put(classInfo, new HashMap<DirectedRelati...
#fixed code @Override public RelationalReader getRelationalReader(ClassInfo classInfo, String relationshipType, String relationshipDirection) { if(!relationalReaderCache.containsKey(classInfo)) { relationalReaderCache.put(classInfo, new HashMap<DirectedRelationshi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private <T> Iterable<T> executeAndMap(Class<T> type, String cypher, Map<String, ?> parameters, RowModelMapper<T> rowModelMapper) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); ...
#fixed code private <T> Iterable<T> executeAndMap(Class<T> type, String cypher, Map<String, ?> parameters, RowModelMapper<T> rowModelMapper) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public QueryStatistics execute(String statement) { if (StringUtils.isEmpty(statement)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } assertNothingReturned(statement); Row...
#fixed code @Override public QueryStatistics execute(String statement) { if (StringUtils.isEmpty(statement)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } assertNothingReturned(statement); RowModelQ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void purgeDatabase() { String url = session.ensureTransaction().url(); session.requestHandler().execute(new DeleteNodeStatements().purge(), url).close(); session.context().clear(); } #location...
#fixed code @Override public void purgeDatabase() { Transaction tx = session.ensureTransaction(); session.requestHandler().execute(new DeleteNodeStatements().purge(), tx).close(); session.context().clear(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public QueryStatistics execute(String cypher, Map<String, Object> parameters) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } if (parameters == ...
#fixed code @Override public QueryStatistics execute(String cypher, Map<String, Object> parameters) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } if (parameters == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void configure(String configurationFileName) { try (InputStream is = classPathResource(configurationFileName)) { configure(is); } catch (Exception e) { logger.warn("Could not configure OGM from {}", configurationFile...
#fixed code public static void configure(String configurationFileName) { try (InputStream is = toInputStream(configurationFileName)) { configure(is); } catch (Exception e) { logger.warn("Could not configure OGM from {}", configurationFileName); ...
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 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 @Test public void testIndexesAreSuccessfullyValidated() { createLoginConstraint(); Components.getConfiguration().setAutoIndex("validate"); AutoIndexManager indexManager = new AutoIndexManager(metaData, Components.driver()); assertEquals(AutoIndexMode.VALIDATE.ge...
#fixed code @Test public void testIndexesAreSuccessfullyValidated() { createLoginConstraint(); baseConfiguration.setAutoIndex("validate"); AutoIndexManager indexManager = new AutoIndexManager(metaData, Components.driver(), baseConfiguration); assertEquals(AutoIndexMode.VALIDATE.g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void removeEntity(Object entity) { Class<?> type = entity.getClass(); ClassInfo classInfo = metaData.classInfo(type.getName()); FieldInfo identityReader = classInfo.identityField(); Long id = (Long) identityReader.readProperty(entity); ...
#fixed code boolean removeRelationship(MappedRelationship mappedRelationship) { return relationshipRegister.remove(mappedRelationship); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIndexDumpMatchesDatabaseIndexes() throws IOException { createLoginConstraint(); Components.getConfiguration().setAutoIndex("dump"); Components.getConfiguration().setDumpDir("."); Components.getConfiguration().setDumpFilename("test.cql"); ...
#fixed code @Test public void testIndexDumpMatchesDatabaseIndexes() throws IOException { createLoginConstraint(); baseConfiguration.setAutoIndex("dump"); baseConfiguration.setDumpDir("."); baseConfiguration.setDumpFilename("test.cql"); File file = new File("./test.cql"); tr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public EntityAccess getPropertyWriter(final ClassInfo classInfo, String propertyName) { if(propertyWriterCache.get(classInfo) == null) { propertyWriterCache.put(classInfo,new HashMap<String, EntityAccess>()); } EntityAcc...
#fixed code @Override public EntityAccess getPropertyWriter(final ClassInfo classInfo, String propertyName) { if(!propertyWriterCache.containsKey(classInfo)) { propertyWriterCache.put(classInfo,new HashMap<String, EntityAccess>()); } if(propertyWri...
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 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 void removeNodeEntity(Object entity, boolean deregisterDependentRelationshipEntity) { Long id = nativeId(entity); nodeEntityRegister.remove(id); final ClassInfo primaryIndexClassInfo = metaData.classInfo(entity); final FieldInfo primary...
#fixed code boolean removeRelationship(MappedRelationship mappedRelationship) { return relationshipRegister.remove(mappedRelationship); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public QueryStatistics execute(String cypher, Map<String, Object> parameters) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } if (parameters == ...
#fixed code @Override public QueryStatistics execute(String cypher, Map<String, Object> parameters) { if (StringUtils.isEmpty(cypher)) { throw new RuntimeException("Supplied cypher statement must not be null or empty."); } if (parameters == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testUnchangedObjectDetected() { ClassInfo classInfo = metaData.classInfo(Teacher.class.getName()); Teacher mrsJones = new Teacher(); objectMemo.remember(mrsJones, classInfo); mrsJones.setId(115L); // the id field ...
#fixed code @Test public void testUnchangedObjectDetected() { Teacher mrsJones = new Teacher(); mrsJones.setId(115L); // the id field must not be part of the memoised property list mappingContext.remember(mrsJones); assertFalse(mappingContext.isDirty...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public <T> void delete(T object) { if (object.getClass().isArray() || Iterable.class.isAssignableFrom(object.getClass())) { deleteAll(object); } else { ClassInfo classInfo = session.metaData().classInfo(object); ...
#fixed code @Override public <T> void delete(T object) { if (object.getClass().isArray() || Iterable.class.isAssignableFrom(object.getClass())) { deleteAll(object); } else { ClassInfo classInfo = session.metaData().classInfo(object); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String createTemporaryEphemeralFileStore() { try { System.out.format("java tmpdir root: %s\n", System.getProperty("java.io.tmpdir")); Path path = Files.createTempDirectory("neo4j.db"); System.out.format("Check tempor...
#fixed code private String createTemporaryEphemeralFileStore() { try { Path path = Files.createTempDirectory("neo4j.db"); File f = path.toFile(); f.deleteOnExit(); URI uri = f.toURI(); String fileStoreUri = uri.toString...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public PropertyReader getPropertyReader(final ClassInfo classInfo, String propertyName) { if(propertyReaderCache.get(classInfo) == null) { propertyReaderCache.put(classInfo, new HashMap<String, PropertyReader>()); } Prop...
#fixed code @Override public PropertyReader getPropertyReader(final ClassInfo classInfo, String propertyName) { if(!propertyReaderCache.containsKey(classInfo)) { propertyReaderCache.put(classInfo, new HashMap<String, PropertyReader>()); } if(proper...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setup() { // Might have to manually load a checkpoint. // In that case, the input splits are not set, they will be faked by // the checkpoint files. Each checkpoint file will be an input split // and the input split s...
#fixed code public void setup() { // Might have to manually load a checkpoint. // In that case, the input splits are not set, they will be faked by // the checkpoint files. Each checkpoint file will be an input split // and the input split superst...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected boolean processEvent(WatchedEvent event) { boolean foundEvent = false; if (event.getPath().startsWith(MASTER_JOB_STATE_PATH) && (event.getType() == EventType.NodeChildrenChanged)) { if (LOG.isInfoEnable...
#fixed code @Override protected boolean processEvent(WatchedEvent event) { boolean foundEvent = false; if (event.getPath().startsWith(MASTER_JOB_STATE_PATH) && (event.getType() == EventType.NodeChildrenChanged)) { if (LOG.isInfoEnabled()) {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void onlineZooKeeperServers() { Integer taskId = zkServerPortMap.get(myHostname); if ((taskId != null) && (taskId.intValue() == taskPartition)) { File zkDirFile = new File(this.zkDir); try { if (LOG.isInfoEn...
#fixed code public void onlineZooKeeperServers() { Integer taskId = zkServerPortMap.get(myHostname); if ((taskId != null) && (taskId.intValue() == taskPartition)) { File zkDirFile = new File(this.zkDir); try { if (LOG.isInfoEnabled(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public SuperstepState coordinateSuperstep() throws KeeperException, InterruptedException { // 1. Get chosen workers and set up watches on them. // 2. Assign partitions to the workers // or possibly reload from a super...
#fixed code @Override public SuperstepState coordinateSuperstep() throws KeeperException, InterruptedException { // 1. Get chosen workers and set up watches on them. // 2. Assign partitions to the workers // or possibly reload from a superstep ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void onlineZooKeeperServers() { Integer taskId = zkServerPortMap.get(myHostname); if ((taskId != null) && (taskId.intValue() == taskPartition)) { File zkDirFile = new File(this.zkDir); try { if (LOG.isInfoEn...
#fixed code public void onlineZooKeeperServers() { Integer taskId = zkServerPortMap.get(myHostname); if ((taskId != null) && (taskId.intValue() == taskPartition)) { File zkDirFile = new File(this.zkDir); try { if (LOG.isInfoEnabled(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Map<String, Object> doUpdate(EntityManager entityManager, int ciTypeId, Map<String, Object> ci, boolean enableStateTransition) { DynamicEntityMeta entityMeta = getDynamicEntityMetaMap().get(ciTypeId); Map<String, Object> convertedCi = MultiValueF...
#fixed code private Map<String, Object> doUpdate(EntityManager entityManager, int ciTypeId, Map<String, Object> ci, boolean enableStateTransition) { DynamicEntityMeta entityMeta = getDynamicEntityMetaMap().get(ciTypeId); String guid = ci.get(GUID).toString(); Obj...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Result<Integer> save(RcRole role, List<Integer> permissionIds) { Result<Integer> result=new Result<>(); result.setStatus(false); result.setCode(MsgCode.FAILED); if (selectByRoleName(role.getName()) != null){ ...
#fixed code @Override public Result<Integer> save(RcRole role, List<Integer> permissionIds) { Result<Integer> result=new Result<>(); result.setStatus(false); result.setCode(MsgCode.FAILED); if (selectByRoleName(role.getName()) != null){ res...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void load(String name, List<String> col) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(name),"US-ASCII")); String line; while ((line=r.readLine())!=null) col.ad...
#fixed code private void load(String name, List<String> col) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(name),"US-ASCII")); try { String line; while ((line=r.readLine())!=null) ...
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 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 addSendJob(Frame f, int sec, int usec) { synchronized(output) { output.print("< add " + Integer.toString(sec) + " " + Integer.toString(usec) + " " + Integer.toHexString(f.getIden...
#fixed code public void addSendJob(Frame f, int sec, int usec) { StringBuilder sb = new StringBuilder(40); sb.append("< add "); sb.append(Integer.toString(sec)); sb.append(' '); sb.append(Integer.toString(usec)); sb.append(' '); sb....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Object readProperties(java.util.Properties p) { if (instance == null) { instance = this; } instance.readPropertiesImpl(p); return instance; } #location 6 #vulnerabi...
#fixed code void writeProperties(java.util.Properties p) { // better to version settings since initial version as advocated at // http://wiki.apidesign.org/wiki/PropertyFiles p.setProperty("version", "1.0"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Object readProperties(java.util.Properties p) { if (instance == null) { instance = this; } instance.readPropertiesImpl(p); return instance; } #location 3 #vulnerabi...
#fixed code void writeProperties(java.util.Properties p) { p.setProperty("version", "1.0"); p.setProperty("busName", bus.getName()); ProjectManager manager = ProjectManager.getGlobalProjectManager(); p.setProperty("projectName", manager.getOpenedProject()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void readDirectory() { logger.log(Level.INFO, "Opening folder {0}", logFolder.getPath()); logFileDir.clear(); platforms.clear(); if (logFolder.isFolder()) { Enumeration<? extends FileObject> children = logFolder.getChi...
#fixed code public void readDirectory() { logger.log(Level.INFO, "Opening folder {0}", logFolder.getPath()); logFileDir.clear(); platforms.clear(); if (logFolder.isFolder()) { Enumeration<? extends FileObject> children = logFolder.getChildren(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void unsubscribeFrom(int id) { synchronized(output) { output.print("< unsubscribe " + Integer.toHexString(id) + " >"); output.flush(); } } #location 2 #vulnerabi...
#fixed code public void unsubscribeFrom(int id) { StringBuilder sb = new StringBuilder(30); sb.append("< unsubscribe "); sb.append(Integer.toHexString(id)); sb.append(" >"); send(sb.toString()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Node[] createNodesForKey(BusDescription key) { Bus bus = null; for(Bus b : project.getBusses()) { if(b.getDescription() == key) bus = b; } AbstractNode node = new AbstractNode(Children....
#fixed code @Override protected Node[] createNodesForKey(BusDescription key) { Bus bus = null; for(Bus b : project.getBusses()) { if(b.getDescription() == key) bus = b; } return new Node[] { new BusNode(key, bus) };...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); F...
#fixed code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); this.de...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Boolean checkConnection() { Socket socket = new Socket(); InetSocketAddress address = new InetSocketAddress(host, port); try { socket.setSoTimeout(10); socket.connect(address, 50); InputStreamReader in...
#fixed code public Boolean checkConnection() { Socket socket = new Socket(); InetSocketAddress address = new InetSocketAddress(host, port); InputStreamReader input = null; try { socket.setSoTimeout(10); socket.connect(address, 50); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void subscribeTo(int id, int sec, int usec) { synchronized(output) { output.print("< subscribe " + Integer.toString(sec) + " " + Integer.toString(usec) + " " + Integer.toHexString(id)...
#fixed code public void subscribeTo(int id, int sec, int usec) { StringBuilder sb = new StringBuilder(30); sb.append("< subscribe "); sb.append(String.valueOf(sec)); sb.append(' '); sb.append(String.valueOf(usec)); sb.append(' '); s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) s...
#fixed code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) subscri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Boolean checkConnection() { Socket socket = new Socket(); InetSocketAddress address = new InetSocketAddress(host, port); InputStreamReader input = null; try { socket.setSoTimeout(10); socket.connect(address,...
#fixed code public Boolean checkConnection() { Socket socket = new Socket(); InetSocketAddress address = new InetSocketAddress(host, port); InputStreamReader input = null; OutputStreamWriter output = null; try { socket.setSoTimeout(10);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void updateSendJob(Frame f) { synchronized(output) { output.print("< add " + Integer.toHexString(f.getIdentifier()) + " " + Integer.toString(f.getLength()) + " " + Util.byteArrayToHex...
#fixed code public void updateSendJob(Frame f) { StringBuilder sb = new StringBuilder(40); sb.append("< add "); sb.append(Integer.toHexString(f.getIdentifier())); sb.append(' '); sb.append(Integer.toString(f.getLength())); sb.append(' '); ...
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 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 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 @Override public void unsubscribed(int id, Subscription s) { if(subscriptionsBCM.contains(s)) { safeUnsubscribe(id); } } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public void unsubscribed(int id, Subscription s) { if(subscriptionsBCM.contains(s)) { safeUnsubscribe(id); } else { logger.log(Level.WARNING, "Unregistered subscription tried to unsubscribe!"); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setConnection(BusURL url) { disconnect(); this.url = url; rawConnection = new RAWConnection(url); bcmConnection = new BCMConnection(url); rawConnection.setReceiver(rawReceiver); bcmConnection.setRece...
#fixed code public void setConnection(BusURL url) { disconnect(); this.url = url; rawConnection = new RAWConnection(url); bcmConnection = new BCMConnection(url); rawConnection.setReceiver(rawReceiver); bcmConnection.setReceiver(bcmReceiv...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); F...
#fixed code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); this.de...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void unsubscribeRange(int from, int to) { synchronized(this) { for (int i = from; i <= to; i++) { if(ids.contains(i)) { ids.remove(i); changeReceiver.unsubscribed(i, this); ...
#fixed code public void unsubscribeRange(int from, int to) { synchronized(ids) { for (int i = from; i <= to; i++) { if(ids.contains(i)) { ids.remove(i); changeReceiver.unsubscribed(i, this); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void sendFrame(Frame f) { StringBuilder sb = new StringBuilder(); sb.append("< send "); sb.append(Integer.toHexString(f.getIdentifier())); sb.append(' '); sb.append(Integer.toString(f.getLength())); sb.append(' '); ...
#fixed code public void sendFrame(Frame f) { StringBuilder sb = new StringBuilder(50); sb.append("< send "); sb.append(Integer.toHexString(f.getIdentifier())); sb.append(' '); sb.append(Integer.toString(f.getLength())); sb.append(' '); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); F...
#fixed code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); this.de...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) s...
#fixed code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) subscri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void sendFrame(Frame frame) { /* Try to open BCM connection if not present */ if(url != null) { openBCMConnection(); if (bcmConnection != null) { bcmConnection.sendFrame(frame); } ...
#fixed code public void sendFrame(Frame frame) { /* Try to open BCM connection if not present */ if(url != null) { openBCMConnection(); if (bcmConnection != null) { bcmConnection.sendFrame(frame); } /* If no BCM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); F...
#fixed code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); this.de...
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 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 Object readProperties(java.util.Properties p) { if (instance == null) { instance = this; } instance.readPropertiesImpl(p); return instance; } #location 6 #vulnerabi...
#fixed code void writeProperties(java.util.Properties p) { p.setProperty("version", "1.0"); p.setProperty("busName", bus.getName()); ProjectManager manager = ProjectManager.getGlobalProjectManager(); p.setProperty("projectName", manager.getOpenedProject()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void clear() { Integer[] identifiers = new Integer[0]; synchronized(this) { identifiers = ids.toArray(new Integer[ids.size()]); } for (int i=0;i<identifiers.length;i++) { unsubscribe(identifiers[i]); ...
#fixed code public void clear() { Integer[] identifiers = null; synchronized(ids) { identifiers = ids.toArray(new Integer[ids.size()]); ids.clear(); } for (int i=0;i<identifiers.length;i++) { changeReceiver.unsubscribed...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void subscribed(int id, Subscription s) { if (subscriptionsBCM.contains(s)) { /* Check if the ID was already subscribed in any subscription */ if(!subscribedIDs.contains(id)) { subscribedIDs.add(id); ...
#fixed code @Override public void subscribed(int id, Subscription s) { if (subscriptionsBCM.contains(s)) { /* Check if the ID was already subscribed in any subscription */ synchronized(subscribedIDs) { if(!subscribedIDs.contains(id)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void disconnect() { if (rawConnection != null && rawConnection.isConnected()) { rawConnection.close(); } if (bcmConnection != null && bcmConnection.isConnected()) { bcmConnection.close(); } url = n...
#fixed code public void disconnect() { if (rawConnection != null && rawConnection.isConnected()) { rawConnection.close(); } if (bcmConnection != null && bcmConnection.isConnected()) { bcmConnection.close(); } notifyListene...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void print(EventFrame ef) { synchronized(io) { createOutput(); OutputWriter out = io.getOut(); Date date = new Date(); out.write("["); out.write(dateFormat.format(date)); out....
#fixed code public static void print(EventFrame ef) { createOutput(); synchronized(io) { OutputWriter out = io.getOut(); Date date = new Date(); out.write("["); out.write(dateFormat.format(date)); out.write("] EV...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) s...
#fixed code @Override public void subscriptionAllChanged(boolean all, Subscription s) { /* BCM subscription switched to RAW subscription */ if (all == true) { subscriptionsBCM.remove(s); if(!subscriptionsRAW.contains(s)) subscri...
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 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 Object readProperties(java.util.Properties p) { if (instance == null) { instance = this; } instance.readPropertiesImpl(p); return instance; } #location 3 #vulnerabi...
#fixed code void writeProperties(java.util.Properties p) { // better to version settings since initial version as advocated at // http://wiki.apidesign.org/wiki/PropertyFiles p.setProperty("version", "1.0"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); F...
#fixed code public void setDescription(String description) throws FileNotFoundException, IOException { if(!descriptionPattern.matcher(description).matches()) throw new IllegalArgumentException("Description must match " + descriptionPattern.pattern()); this.de...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void printInfo(String info) { synchronized(io) { createOutput(); OutputWriter out = io.getOut(); Date date = new Date(); out.write("["); out.write(dateFormat.format(date)); ou...
#fixed code public static void printInfo(String info) { createOutput(); synchronized(io) { OutputWriter out = io.getOut(); Date date = new Date(); out.write("["); out.write(dateFormat.format(date)); out.write("] ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void waitForReady() { while (true) { System.out.println("Waiting for SonarQube to be available at " + getUrl()); try { HttpURLConnection conn = (HttpURLConnection)getUrl("/api/settings/values.protobuf").openConnection(); conn.connect...
#fixed code public void waitForReady() throws MalformedURLException { LOGGER.info("Waiting for SonarQube to be available at {}", getUrl()); Awaitility .await("SonarQube is ready") .atMost(3, TimeUnit.MINUTES) .pollInterval(5, TimeUnit.SECONDS) .ignor...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int run(String[] args) throws Exception { final FileSystem fs = FileSystem.get(getConf()); Options options = new Options(); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); // create the parser CommandLinePars...
#fixed code public int run(String[] args) throws Exception { final FileSystem fs = FileSystem.get(getConf()); Options options = new Options(); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); // create the parser CommandLineParser par...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void map(IntWritable key, WeightedVectorWritable value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { Vector v = value.getVector(); if (v instanceof NamedVector) { String name = ((N...
#fixed code public void map(IntWritable key, WeightedVectorWritable value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { Vector v = value.getVector(); if (v instanceof NamedVector) { String name = ((NamedVe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) {...
#fixed code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public com.flickr4java.flickr.Response get(String path, Map<String, Object> parameters, String apiKey, String sharedSecret) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.GET, getScheme() + "://" + getHost() + path); ...
#fixed code @Override public com.flickr4java.flickr.Response get(String path, Map<String, Object> parameters, String apiKey, String sharedSecret) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.GET, getScheme() + "://" + getHost() + path); for (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) {...
#fixed code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) {...
#fixed code @Override public Response getNonOAuth(String path, Map<String, String> parameters) { InputStream in = null; try { URL url = UrlUtilities.buildUrl(getScheme(), getHost(), getPort(), path, parameters); if (Flickr.debugRequest) { ...
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 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 @JsonIgnore public Set<Aggregation> getAggregations() { return getInnerQuery().getAggregations(); } #location 4 #vulnerability type NULL_DEREFERENCE
#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 List<Interval> getIntervals() { return getInnerQuery().getIntervals(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override @JsonIgnore public List<Interval> getIntervals() { return getInnerQueryUnchecked().getIntervals(); }
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 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 LookbackQuery withIntervals(Collection<Interval> intervals) { return withDataSource(new QueryDataSource(getInnerQuery().withIntervals(intervals))); } #location 3 #vulnerability ty...
#fixed code @Override public LookbackQuery withIntervals(Collection<Interval> intervals) { return withDataSource(new QueryDataSource(getInnerQueryUnchecked().withIntervals(intervals))); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @JsonIgnore public Filter getFilter() { return getInnerQuery().getFilter(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override @JsonIgnore public Filter getFilter() { return getInnerQueryUnchecked().getFilter(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LookbackQuery withFilter(Filter filter) { return withDataSource(new QueryDataSource(getInnerQuery().withFilter(filter))); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public LookbackQuery withFilter(Filter filter) { return withDataSource(new QueryDataSource(getInnerQueryUnchecked().withFilter(filter))); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Pagination<DimensionRow> getResultsPage(Query query, PaginationParameters paginationParameters) throws PageNotFoundException { int perPage = paginationParameters.getPerPage(); validatePerPage(perPage); TreeSet<DimensionRow...
#fixed code protected Pagination<DimensionRow> getResultsPage(Query query, PaginationParameters paginationParameters) throws PageNotFoundException { int perPage = paginationParameters.getPerPage(); validatePerPage(perPage); TreeSet<DimensionRow> filt...
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 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 clearDimension() { Set<DimensionRow> dimensionRows = findAllDimensionRows(); IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer).setRAMBufferSizeMB(BUFFER_SIZE); lock.writeLock().lock(); try { ...
#fixed code @Override public void clearDimension() { Set<DimensionRow> dimensionRows = findAllDimensionRows(); IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer).setRAMBufferSizeMB(BUFFER_SIZE); writeLock(); try { try (In...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LookbackQuery withAggregations(Collection<Aggregation> aggregations) { return withDataSource(new QueryDataSource(getInnerQuery().withAggregations(aggregations))); } #location 3 #v...
#fixed code @Override public LookbackQuery withAggregations(Collection<Aggregation> aggregations) { return withDataSource(new QueryDataSource(getInnerQueryUnchecked().withAggregations(aggregations))); }
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 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 clearDimension() { Set<DimensionRow> dimensionRows = findAllDimensionRows(); IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer).setRAMBufferSizeMB(BUFFER_SIZE); lock.writeLock().lock(); try { ...
#fixed code @Override public void clearDimension() { Set<DimensionRow> dimensionRows = findAllDimensionRows(); IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer).setRAMBufferSizeMB(BUFFER_SIZE); writeLock(); try { try (In...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LookbackQuery withGranularity(Granularity granularity) { return withDataSource(new QueryDataSource(getInnerQuery().withGranularity(granularity))); } #location 3 #vulnerability typ...
#fixed code @Override public LookbackQuery withGranularity(Granularity granularity) { return withDataSource(new QueryDataSource(getInnerQueryUnchecked().withGranularity(granularity))); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @JsonIgnore public Collection<Dimension> getDimensions() { return getInnerQuery().getDimensions(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override @JsonIgnore public Collection<Dimension> getDimensions() { return getInnerQueryUnchecked().getDimensions(); }
Below is the vulnerable code, please generate the patch based on the following information.